Skip to content

fix: Resolve issue with building function package separately fails with Terraform v1.13 & later #728

Closed
anioool wants to merge 2 commits intoterraform-aws-modules:masterfrom
anioool:master
Closed

fix: Resolve issue with building function package separately fails with Terraform v1.13 & later #728
anioool wants to merge 2 commits intoterraform-aws-modules:masterfrom
anioool:master

Conversation

@anioool
Copy link

@anioool anioool commented Jan 26, 2026

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.

@anioool anioool changed the title Resolve issue with building function package separately fails with Terraform v1.13 & later fix: Resolve issue with building function package separately fails with Terraform v1.13 & later Jan 26, 2026

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.

@morganchorlton3
Copy link
Contributor

Any update on getting this one in or is there another work around?

@antonbabenko
Copy link
Member

This PR is included in version 8.5.1 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants