fix: Resolve issue with building function package separately fails with Terraform v1.13 & later #728
fix: Resolve issue with building function package separately fails with Terraform v1.13 & later #728anioool wants to merge 2 commits intoterraform-aws-modules:masterfrom
Conversation
|
|
||
| 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)) |
There was a problem hiding this comment.
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:
| 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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
|
Any update on getting this one in or is there another work around? |
|
This PR is included in version 8.5.1 🎉 |
Description
This PR possibly solves the issue reported #727
Breaking Changes
No
How Has This Been Tested?
Tested with terraform definition where the directory is archived through data.archive_file upfront. The archive path is passed to the terraform module with the fixed implementation. Arguments create_package set to false,, local_existing_package points to outputs from data.archive_file.