diff --git a/infrastructure/modules/eventpub/archive_file_lambda.tf b/infrastructure/modules/eventpub/archive_file_lambda.tf index 30f972f..4424faa 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/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 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" + } +}