Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ resource "aws_lambda_function" "this" {
}

filename = local.filename
source_code_hash = var.ignore_source_code_hash ? null : (local.filename == null ? false : fileexists(local.filename)) ? filebase64sha256(local.filename) : null
source_code_hash = var.ignore_source_code_hash ? null : (local.filename == null ? false : try(filebase64sha256(local.filename), null))
Copy link
Contributor

@lorengordon lorengordon Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will return false when local.filename == null, which changes the meaning of the original logic. It should return null in that condition. I suggest rewriting:

Suggested change
source_code_hash = var.ignore_source_code_hash ? null : (local.filename == null ? false : try(filebase64sha256(local.filename), null))
source_code_hash = var.ignore_source_code_hash || local.filename == null ? null : try(filebase64sha256(local.filename), null)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case when local.filename == null then the logic remain unchanged and false is going to be returned. The change touches the false path where local.filename != null and change the logic in a way that we no longer do the pre check if the file exists but we tries to generate hash with eventual fallback to null value. It's the same logic but with no fileexists function involved

Copy link
Contributor

@lorengordon lorengordon Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It never returned false before. It returned null. The logic was quite convoluted. Where you are seeing the false, was actually the "test" for the third ternary operator. When the test returned false, the ternary was written to return null.


s3_bucket = local.s3_bucket
s3_key = local.s3_key
Expand Down Expand Up @@ -187,7 +187,7 @@ resource "aws_lambda_layer_version" "this" {
skip_destroy = var.layer_skip_destroy

filename = local.filename
source_code_hash = var.ignore_source_code_hash ? null : (local.filename == null ? false : fileexists(local.filename)) ? filebase64sha256(local.filename) : null
source_code_hash = var.ignore_source_code_hash ? null : (local.filename == null ? false : try(filebase64sha256(local.filename), null))

s3_bucket = local.s3_bucket
s3_key = local.s3_key
Expand Down
Loading