-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
aws_lambda_function is unable to detect code changes #5150
Comments
If I may add, about aws lambda specifics - when using the AWS API to 'update' the code of an existing function, new versions are created (also called aliases) and old ones can still be targeted. This is different from destroying/recreating the lambda function. |
Related to #4897 |
I noticed the same thing. I had a look at the source code, although I'm pretty new to GoLang, so I may have missed something. It looks like it should be saving the source_code_hash in the state file. In terraform/builtin/providers/aws/resource_aws_lambda_function.go I see followed by So far as I can tell, invoking the ResourceData.Set method should add it to a map to be output in the state file. Evidently it's not that simple. I tried adding source_code_hash to the state file manually, but this had no effect either, so it seems this is being filtered for some reason. |
I admit to not grokking Terraform's resource plugin model all that well. Wild guess is that at the very least |
+1 for fixing this. |
#5239 is now finished, waiting for review & merge. Feel free to test the bugfix/functionality from that branch. |
Hi, It will be possible to trigger an update of a Lambda function by specifying an optional attribute resource "aws_lambda_function" "test_lambda" {
filename = "lambda_function_payload.zip"
function_name = "lambda_function_name"
role = "${aws_iam_role.iam_for_lambda.arn}"
handler = "exports.test"
source_code_hash = "${base64sha256(file("lambda_function_payload.zip"))}"
} The update mechanism is also documented and docs update will be released along with the next version which makes it possible to update Lambda function. In regards to use of Lambda aliases as versioning mechanisms, I'd be happy to discuss suggestions and ideas on how to approach that problem in a separate issue if there's any interest. |
|
@alexissmirnov seeing the same behavior here with v0.9.2. |
An alternative way to update lambda function on code change, when sourced from S3, would be to set S3 bucket versioning and set lambda zip version:
|
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. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
The aws_lambda_function resource look like it supports hashing the code file:
But the source_code_hash does not appear in the state file. Changes to the source file does not trigger a lambda function code update. Tainting the resource manually seems to be the only way.
The text was updated successfully, but these errors were encountered: