Skip to content

Commit

Permalink
fix(lambda): use output_base64sha256 directly instead of function fil…
Browse files Browse the repository at this point in the history
…ebase64sha256

"source_code_hash = filebase64sha256(data.archive_file.this.output_path)"
can be called before the "data.archive_file.this" resource has created
the zip file and may fails because the file does not exist.

The cause of the issue here is calling a function with a known argument,
the workaround would be to directly use the output_base64sha256
attribute of the data source instead of calling filebase64sha256.

this commit replaces the "filebase64sha256" function by the "output_base64sha256"

Thanks to @pvillaverde for pointing this out!
  • Loading branch information
diodonfrost committed Aug 8, 2023
1 parent 3d8ebf9 commit a7c348f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ data "archive_file" "this" {
# Create Lambda function for stop or start aws resources
resource "aws_lambda_function" "this" {
filename = data.archive_file.this.output_path
source_code_hash = filebase64sha256(data.archive_file.this.output_path)
source_code_hash = data.archive_file.this.output_base64sha256
function_name = var.name
role = var.custom_iam_role_arn == null ? aws_iam_role.this[0].arn : var.custom_iam_role_arn
handler = "scheduler.main.lambda_handler"
Expand Down

0 comments on commit a7c348f

Please sign in to comment.