From 7fdd0be1e558a7b2c1e8127b2c568b501817aba3 Mon Sep 17 00:00:00 2001 From: jamesthompson26-nhs Date: Fri, 26 Sep 2025 14:48:50 +0100 Subject: [PATCH 1/3] CCM-12059: Improve Eventpub Lambda Build --- .../modules/eventpub/archive_file_lambda.tf | 11 ++++++----- .../modules/eventpub/null_resource_force_archive.tf | 9 +++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 infrastructure/modules/eventpub/null_resource_force_archive.tf diff --git a/infrastructure/modules/eventpub/archive_file_lambda.tf b/infrastructure/modules/eventpub/archive_file_lambda.tf index 30f972f..a1a3fe5 100644 --- a/infrastructure/modules/eventpub/archive_file_lambda.tf +++ b/infrastructure/modules/eventpub/archive_file_lambda.tf @@ -1,9 +1,8 @@ -resource "archive_file" "lambda" { - type = "zip" - source_dir = "${path.module}/../../../lambda/eventpub/src" +data "archive_file" "lambda" { + type = "zip" + source_dir = "${path.module}/../../../lambda/eventpub/src" + output_path = "${path.module}/../../../lambda/${local.csi}_eventpub.zip" - # Timestamp in path to resolve https://github.com/hashicorp/terraform-provider-archive/issues/39 - output_path = "${path.module}/../../../lambda/eventpub_${timestamp()}.zip" excludes = [ # NodeJS Exclusions "**/__tests__", @@ -11,4 +10,6 @@ resource "archive_file" "lambda" { "**/package.json", "**/package-lock.json", ] + + depends_on = [null_resource.force_archive] } diff --git a/infrastructure/modules/eventpub/null_resource_force_archive.tf b/infrastructure/modules/eventpub/null_resource_force_archive.tf new file mode 100644 index 0000000..ec485ca --- /dev/null +++ b/infrastructure/modules/eventpub/null_resource_force_archive.tf @@ -0,0 +1,9 @@ +resource "null_resource" "force_archive" { + triggers = { + always_run = timestamp() + } + + provisioner "local-exec" { + command = "true" + } +} From 4930d225999a77b9f4fb3eefa800b3aca050f897 Mon Sep 17 00:00:00 2001 From: jamesthompson26-nhs Date: Fri, 26 Sep 2025 15:08:50 +0100 Subject: [PATCH 2/3] CCM-12059: Improve Eventpub Lambda Build --- infrastructure/modules/eventpub/lambda_function.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/infrastructure/modules/eventpub/lambda_function.tf b/infrastructure/modules/eventpub/lambda_function.tf index 1cadfc4..db7f925 100644 --- a/infrastructure/modules/eventpub/lambda_function.tf +++ b/infrastructure/modules/eventpub/lambda_function.tf @@ -9,8 +9,8 @@ resource "aws_lambda_function" "main" { memory_size = 128 timeout = 20 - filename = archive_file.lambda.output_path - source_code_hash = archive_file.lambda.output_base64sha256 + filename = data.archive_file.lambda.output_path + source_code_hash = data.archive_file.lambda.output_base64sha256 logging_config { application_log_level = var.log_level From c0562528df0ebb219a9daa1dd14d0319c84f850e Mon Sep 17 00:00:00 2001 From: jamesthompson26-nhs Date: Mon, 29 Sep 2025 11:50:28 +0100 Subject: [PATCH 3/3] CCM-12059: Improve Eventpub Lambda Build --- infrastructure/modules/eventpub/archive_file_lambda.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/infrastructure/modules/eventpub/archive_file_lambda.tf b/infrastructure/modules/eventpub/archive_file_lambda.tf index a1a3fe5..4424faa 100644 --- a/infrastructure/modules/eventpub/archive_file_lambda.tf +++ b/infrastructure/modules/eventpub/archive_file_lambda.tf @@ -1,7 +1,7 @@ data "archive_file" "lambda" { type = "zip" - source_dir = "${path.module}/../../../lambda/eventpub/src" - output_path = "${path.module}/../../../lambda/${local.csi}_eventpub.zip" + source_dir = "${path.module}/lambda/eventpub/src" + output_path = "${path.module}/lambda/${local.csi}_eventpub.zip" excludes = [ # NodeJS Exclusions