diff --git a/infrastructure/terraform/lambda/fast-api/main.tf b/infrastructure/terraform/lambda/fast-api/main.tf index 4bf88720..c4769f41 100644 --- a/infrastructure/terraform/lambda/fast-api/main.tf +++ b/infrastructure/terraform/lambda/fast-api/main.tf @@ -51,7 +51,6 @@ locals { # FastAPI Lambda + API Gateway ############################################ module "fastapi" { - depends_on = [null_resource.pip_install] source = "../../modules/lambda_with_api_gateway" name = "fastapi" diff --git a/infrastructure/terraform/modules/lambda_with_api_gateway/main.tf b/infrastructure/terraform/modules/lambda_with_api_gateway/main.tf index 92c7c7f5..8af51420 100644 --- a/infrastructure/terraform/modules/lambda_with_api_gateway/main.tf +++ b/infrastructure/terraform/modules/lambda_with_api_gateway/main.tf @@ -10,6 +10,8 @@ module "role" { # Install python packages ############################################ resource "null_resource" "pip_install" { + count = var.requirements_file != null ? 1 : 0 + triggers = { requirements_hash = filemd5("${var.requirements_file}") } @@ -23,6 +25,7 @@ resource "null_resource" "pip_install" { # Zip the source code ############################################ data "archive_file" "this" { + depends_on = [null_resource.pip_install] type = "zip" source_dir = var.source_dir output_path = "${path.module}/lambda_package.zip"