Skip to content

Commit a37dc44

Browse files
Merge pull request #126 from NHSDigital/feature/CCM-12059_Improve_Eventpub_Lambda_Build
CCM-12059: Improve Eventpub Lambda Build
2 parents aef67db + c056252 commit a37dc44

3 files changed

Lines changed: 17 additions & 7 deletions

File tree

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
resource "archive_file" "lambda" {
2-
type = "zip"
3-
source_dir = "${path.module}/../../../lambda/eventpub/src"
1+
data "archive_file" "lambda" {
2+
type = "zip"
3+
source_dir = "${path.module}/lambda/eventpub/src"
4+
output_path = "${path.module}/lambda/${local.csi}_eventpub.zip"
45

5-
# Timestamp in path to resolve https://github.com/hashicorp/terraform-provider-archive/issues/39
6-
output_path = "${path.module}/../../../lambda/eventpub_${timestamp()}.zip"
76
excludes = [
87
# NodeJS Exclusions
98
"**/__tests__",
109
"**/node_modules",
1110
"**/package.json",
1211
"**/package-lock.json",
1312
]
13+
14+
depends_on = [null_resource.force_archive]
1415
}

infrastructure/modules/eventpub/lambda_function.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ resource "aws_lambda_function" "main" {
99
memory_size = 128
1010
timeout = 20
1111

12-
filename = archive_file.lambda.output_path
13-
source_code_hash = archive_file.lambda.output_base64sha256
12+
filename = data.archive_file.lambda.output_path
13+
source_code_hash = data.archive_file.lambda.output_base64sha256
1414

1515
logging_config {
1616
application_log_level = var.log_level
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
resource "null_resource" "force_archive" {
2+
triggers = {
3+
always_run = timestamp()
4+
}
5+
6+
provisioner "local-exec" {
7+
command = "true"
8+
}
9+
}

0 commit comments

Comments
 (0)