From 5d933b73f686ff588f3299537d36359c31524eb6 Mon Sep 17 00:00:00 2001 From: Jun-te Kim Date: Wed, 11 Mar 2026 18:00:00 +0000 Subject: [PATCH] save --- .../terraform/lambda/fast-api/main.tf | 34 ++++++++++++++++++- infrastructure/terraform/shared/main.tf | 3 +- sfr/principal_pitch/2_export_data.py | 8 ++--- 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/infrastructure/terraform/lambda/fast-api/main.tf b/infrastructure/terraform/lambda/fast-api/main.tf index c9058fb7..6915ba85 100644 --- a/infrastructure/terraform/lambda/fast-api/main.tf +++ b/infrastructure/terraform/lambda/fast-api/main.tf @@ -68,11 +68,43 @@ resource "null_resource" "pip_install" { } } +############################################ +# Create deployment zip +############################################ +data "archive_file" "fastapi_zip" { + type = "zip" + source_dir = "${path.root}/../../../../" + output_path = "${path.module}/fastapi_lambda_${var.stage}.zip" + excludes = [ + "**/__pycache__/**", + "**/*.pyc", + "**/.pytest_cache/**", + "**/tests/**", + "**/.git/**", + "**/.terraform/**", + "**/node_modules/**", + "**/.env*", + "**/*.xlsx", + "**/*.pdf" + ] + depends_on = [null_resource.pip_install] +} + +############################################ +# Upload zip to S3 +############################################ +resource "aws_s3_object" "fastapi_zip" { + bucket = "ara-fast-api-terraform-state" + key = "fastapi-lambda/${var.stage}/fastapi_lambda_${var.stage}_${data.archive_file.fastapi_zip.output_base64sha256}.zip" + source = data.archive_file.fastapi_zip.output_path + etag = filemd5(data.archive_file.fastapi_zip.output_path) +} + ############################################ # FastAPI Lambda + API Gateway ############################################ module "fastapi" { - depends_on = [null_resource.pip_install] + depends_on = [aws_s3_object.fastapi_zip] source = "../../modules/lambda_with_api_gateway" name = "fastapi" diff --git a/infrastructure/terraform/shared/main.tf b/infrastructure/terraform/shared/main.tf index 1e88435d..13e94c80 100644 --- a/infrastructure/terraform/shared/main.tf +++ b/infrastructure/terraform/shared/main.tf @@ -550,7 +550,8 @@ module "fast_api_s3_read_and_write" { "arn:aws:s3:::${module.retrofit_heat_predictions.bucket_name}", "arn:aws:s3:::${module.retrofit_heating_kwh_predictions.bucket_name}", "arn:aws:s3:::${module.retrofit_hotwater_kwh_predictions.bucket_name}", - "arn:aws:s3:::${module.retrofit_energy_assessments.bucket_name}" + "arn:aws:s3:::${module.retrofit_energy_assessments.bucket_name}", + "arn:aws:s3:::ara-fast-api-terraform-state" ] actions = ["s3:GetObject", "s3:ListBucket"] resource_paths = ["/*"] diff --git a/sfr/principal_pitch/2_export_data.py b/sfr/principal_pitch/2_export_data.py index 519636be..641c87da 100644 --- a/sfr/principal_pitch/2_export_data.py +++ b/sfr/principal_pitch/2_export_data.py @@ -28,13 +28,13 @@ from sqlalchemy import func # PORTFOLIO_ID = 206 # SCENARIOS = [389] -PORTFOLIO_ID = 581 -SCENARIOS = [1124] +PORTFOLIO_ID = 625 +SCENARIOS = [1134] scenario_names = { - 1124: "EPC C - Solar Focused", + 1134: "EPC C", } -project_name = "WCHG EPC D rated properties" +project_name = "Fortem Solutions - Ara-Software-Partnership" def get_data(portfolio_id, scenario_ids):