mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-30 13:10:47 +00:00
Merge pull request #857 from Hestia-Homes/deploy-fastapi-with-terraform
Deploy fastapi with terraform: actually install packages and exclude infrastructure code from zip
This commit is contained in:
commit
2cf3db81fe
3 changed files with 27 additions and 23 deletions
|
|
@ -47,27 +47,6 @@ locals {
|
||||||
# name = var.domain_name
|
# name = var.domain_name
|
||||||
# }
|
# }
|
||||||
|
|
||||||
############################################
|
|
||||||
# Install Python requirements
|
|
||||||
############################################
|
|
||||||
resource "null_resource" "pip_install" {
|
|
||||||
triggers = {
|
|
||||||
requirements_hash = filemd5("${path.root}/../../../../backend/app/requirements/requirements.txt")
|
|
||||||
}
|
|
||||||
|
|
||||||
provisioner "local-exec" {
|
|
||||||
command = <<EOT
|
|
||||||
pip install \
|
|
||||||
-r ${path.root}/../../../../backend/app/requirements/requirements.txt \
|
|
||||||
-t ${path.root}/../../../../backend/app/packages \
|
|
||||||
--platform manylinux2014_x86_64 \
|
|
||||||
--implementation cp \
|
|
||||||
--python-version 3.11 \
|
|
||||||
--only-binary=:all: \
|
|
||||||
EOT
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
############################################
|
############################################
|
||||||
# FastAPI Lambda + API Gateway
|
# FastAPI Lambda + API Gateway
|
||||||
############################################
|
############################################
|
||||||
|
|
@ -83,6 +62,7 @@ module "fastapi" {
|
||||||
timeout = 600
|
timeout = 600
|
||||||
memory_size = 512
|
memory_size = 512
|
||||||
artifact_bucket = data.terraform_remote_state.shared.outputs.ara_fast_api_state_bucket
|
artifact_bucket = data.terraform_remote_state.shared.outputs.ara_fast_api_state_bucket
|
||||||
|
requirements_file = "${path.root}/../../../../backend/app/requirements/requirements.txt"
|
||||||
|
|
||||||
# domain_name = "api.${var.domain_name}"
|
# domain_name = "api.${var.domain_name}"
|
||||||
# certificate_arn = data.aws_ssm_parameter.certificate_arn.value
|
# certificate_arn = data.aws_ssm_parameter.certificate_arn.value
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,19 @@ module "role" {
|
||||||
name = "${var.name}-lambda-${var.stage}"
|
name = "${var.name}-lambda-${var.stage}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
############################################
|
||||||
|
# Install python packages
|
||||||
|
############################################
|
||||||
|
resource "null_resource" "pip_install" {
|
||||||
|
triggers = {
|
||||||
|
requirements_hash = filemd5("${var.requirements_file}")
|
||||||
|
}
|
||||||
|
|
||||||
|
provisioner "local-exec" {
|
||||||
|
command = "pip install -r ${var.requirements_file} -t ${var.source_dir} --platform manylinux2014_x86_64 --implementation cp --python-version 3.11 --only-binary=:all: --upgrade"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
############################################
|
############################################
|
||||||
# Zip the source code
|
# Zip the source code
|
||||||
############################################
|
############################################
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,13 @@ variable "runtime" { type = string }
|
||||||
|
|
||||||
variable "zip_excludes" {
|
variable "zip_excludes" {
|
||||||
type = list(string)
|
type = list(string)
|
||||||
default = ["**/__pycache__/**", "**/*.pyc", "**/.pytest_cache/**", "**/tests/**"]
|
default = [
|
||||||
|
"**/__pycache__/**",
|
||||||
|
"**/*.pyc",
|
||||||
|
"**/.pytest_cache/**",
|
||||||
|
"**/tests/**",
|
||||||
|
"**/infrastructure/**"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "timeout" {
|
variable "timeout" {
|
||||||
|
|
@ -34,4 +40,9 @@ variable "route53_zone_id" {
|
||||||
type = string
|
type = string
|
||||||
default = null
|
default = null
|
||||||
}
|
}
|
||||||
variable "artifact_bucket" { type = string }
|
variable "artifact_bucket" { type = string }
|
||||||
|
|
||||||
|
variable "requirements_file" {
|
||||||
|
type = string
|
||||||
|
default = null
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue