mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
ensure pip install runs before zip by moving the install command to lambda_with_api_gateway
This commit is contained in:
parent
b55b601c15
commit
93915efd9d
3 changed files with 20 additions and 22 deletions
|
|
@ -47,27 +47,6 @@ locals {
|
|||
# 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
|
||||
############################################
|
||||
|
|
@ -83,6 +62,7 @@ module "fastapi" {
|
|||
timeout = 600
|
||||
memory_size = 512
|
||||
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}"
|
||||
# certificate_arn = data.aws_ssm_parameter.certificate_arn.value
|
||||
|
|
|
|||
|
|
@ -6,6 +6,19 @@ module "role" {
|
|||
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
|
||||
############################################
|
||||
|
|
|
|||
|
|
@ -40,4 +40,9 @@ variable "route53_zone_id" {
|
|||
type = string
|
||||
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