fix: Fix error with inconsistent values for fileexists when setting the source code hash#734
Conversation
|
This appears to implement option (4) from my proposal in this message thread: #727 (comment). Seems pretty reasonable to me. |
|
This PR cause some logic is gone , ie. You cannot pass already created package by other terraform resource and made the decision about deployment based on calculated source_code_hash. |
|
You are right, thanks for catching that! I will work to improve. |
|
That would be option (2) from my proposal. :)
Idea being to add an output for |
…he source_code_hash attribute of layers
…kage to not use the deprecated null_data_source data resource
8e937a3 to
9fa8fc7
Compare
|
@lorengordon and @anioool I have replaced completely the initial version with a better option that doesn't require the users of the module to make changes to their code. I would appreciate if you would take a look too, thanks! |
|
@flora-five Intriguing! I'll try to run it through a few of my use cases as soon as I get a chance. Probably Thursday. |
|
@flora-five First issue I see is a diff after apply, when the
|
|
Also, here is a scenario that generates a diff after apply, that also fails on second apply... To reproduce:
|
|
Also a bit odd workflow for one more scenario:
|
9fa8fc7 to
1ba9d35
Compare
|
Thank you @lorengordon for the checks! Indeed, the resource added to obtain the hash caused more diffs. I have been able to simplify the code to work as before for your test cases. |
|
I've added a small optimization to avoid the creation of the resource used for calculating the zip archive hash if changes to source code hash should be ignored. |
… if changes to source code hash should be ignored
17b213e to
ba57954
Compare
|
@flora-five Nicely done... Ok, I tested all my scenarios again and it appears to be working. @antonbabenko I think this is good to go, whenever you have a chance to review. |
## [8.5.1](v8.5.0...v8.5.1) (2026-02-18) ### Bug Fixes * Fix error with inconsistent values for fileexists when setting the source code hash ([#734](#734)) ([99a1bc5](99a1bc5))
|
This PR is included in version 8.5.1 🎉 |
Description
Ensure that the local package has been created before computing its hash by using a
terraform_dataresource that depends onnull_resource.archive.fileexistsis not used anymore, integrating the change from #728.Other changes:
was_missingfrom package.py because it is not used anymorecode_sha256attribute for functions and layers, outputs the value ofsource_code_hashattribute for layersnull_data_sourcein the example code for creating a function from a downloaded packageMotivation and Context
The
source_code_hashwas obtained with an expression that used thefileexistsandfilebase64sha256functions and, because the package file may have not been created yet, their values changed between plan and apply. In newer Terraform versions those functions must not change their result between plan and apply. The apply failed with an error about inconsistent values returned by the functions.Fixes #727
Fixes #733
Closes #728
Breaking Changes
No
How Has This Been Tested?
examples/*to demonstrate and validate my change(s)examples/*projectspre-commit run -aon my pull request