-
Notifications
You must be signed in to change notification settings - Fork 9.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: aws_lambda_function version attribute always changing #33955
Comments
Community NoteVoting for Prioritization
Volunteering to Work on This Issue
|
Hi, I was struggling with this too and experimented last week. I am sure this is not a bug. There are probably various ways to get it right, I’ll show my approach. The "what to do" became clear, even though it was obvious in the proven implementation of Anton Babenko’s lambda module https://github.com/terraform-aws-modules/terraform-aws-lambda/tree/v7.2.2/examples/code-signing But that didn't help me in the beginning. You need to remove source_code_hash from your lambda. Your intention is totally right, and I was doing the same. Make use of the source_hash in the s3 object resource (see below) of the unsigned object, which will trigger a new signing job, whenever it is not matching the previous hash. The signing job will create a new signed zip file (which looks like, this pattern 87336-27636-266462-27726.zip). Because the key changes (on change of the source file's hash), your lambda function will be updated with the new zip package and a new version is created. No need to add more - as the goal is achieved. If the source hash is the same, no signing job will be created, hence no version change.
If I remember right data.aws_s3_object.signed[0].checksum_sha256 is empty. The signer job is not populating/activating this to be filled. Check its value with an output resource, this helped me. As a general note, I didn’t know that: The checksum-sha256 is not necessarily a guarantee that it will contain the sha256 of the uploaded file, as for multipart uploads it is calculated differently.. As per https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html larger files (>=16mb are uploaded as multipart, I am sure there are variations). If you see the checksum having a dash number at the end e.g. -7 you know that the file was uploaded as 7 multipart objects. Which happened when I tried to make use of that. Concerning the “lifecycle ignore” changes part, this confuses many. In this case at least the “last modified” is ignored if 8 remember right, at least not a cause of triggering a new version to be created. I didn’t lookup that part up for this comment. But I would remove it, and it didn't make a difference either. Closing, I think this - data "aws_s3_object" "signed" - can be removed. For the unsigned s3 object I see a data resource in the code example, but I’d focus on the resource as such and if this is right, the data resource for unsigned can be used too of course. Let me know if I got something wrong. |
The above is similar to explanations I've seen elsewhere in similar threads. With that in mind, since there's nothing for the team to do in this case, closing. |
Warning This issue has been closed, meaning that any additional comments are hard for our team to see. Please assume that the maintainers will not see them. Ongoing conversations amongst community members are welcome, however, the issue will be locked after 30 days. Moving conversations to another venue, such as the AWS Provider forum, is recommended. If you have additional concerns, please open a new issue, referencing this one where needed. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Terraform Core Version
1.5.7
AWS Provider Version
5.21.0
Affected Resource(s)
We are running terraform apply, and we see the following:
Terraform will perform the following actions:
Expected Behavior
We would like to see no changes in the Terraform plan when there are no changes to the terraform or s3 object.
From the plan result, it seems that the only change is the
version
of the aws_lambda_function.We added:
But still, we have the
version
updated.Actual Behavior
No changes in plan if there are no terraform or s3 object change.
Relevant Error/Panic Output Snippet
We believe this is only relevant with the lambda signature feature.
Steps to Reproduce
Use the code above with lambda signature.
Debug Output
Debug log did not show why the version is updated
Panic Output
No response
Important Factoids
No response
References
No response
Would you like to implement a fix?
None
The text was updated successfully, but these errors were encountered: