v0.9.11
resource "aws_lambda_function" "main" {
filename = "${data.archive_file.main.output_path}"
source_code_hash = "${data.archive_file.main.output_base64sha256}"
publish = true
# ...
}
resource "aws_cloudfront_distribution" "main" {
default_cache_behavior {
lambda_function_association {
event_type = "origin-request"
lambda_arn = "${aws_lambda_function.main.qualified_arn}"
}
# ...
}
# ...
}
Any updates to the function source code should update the lambda function (and increment the version), then apply the new version to the CloudFront distribution in a single apply.
It only updates the function during the first apply. You have to run terraform apply again to update the CF distro with the new function version.
Also, if you change the contents of the function two times in a row (before applying twice so it goes to the CF distro), Terraform crashes on the second apply.
Run terraform apply twice.
I can confirm I am seeing similar behavior. Only difference I see is that even if I run terraform apply twice the cloudfront trigger does not get set on the new version of the lambda function. The only time I have seen the lambda cloudfront trigger get set was on the initial creation of the lambda function.
I can confirm I am seeing the error when running apply with two changes to the lambda function in a row.
Hi again, just want to give an update, it turns out my cloudfront triggers were being added like @jsonmaur was describing, however due to what I assume is a bug in the AWS console they do not appear in the "triggers" section in the lambda configuration but they do appear in the cloudfront behavior in the console.
So I am seeing the exact same behavior as @jsonmaur.
Thanks!
+1 also running into this issue
Thanks to @mdlavin the fix for this has been merged into master and will be released in v1.10.0 of the AWS provider, likely later today or Monday. 🎉
This has been released in version 1.10.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.
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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!
Most helpful comment
Thanks to @mdlavin the fix for this has been merged into master and will be released in v1.10.0 of the AWS provider, likely later today or Monday. 🎉