Terraform v0.8.9-dev (8173c76a782c3c8fc0e3b295cbf344d237602ede)
resource "aws_lambda_function" "lambda" {
environment = {
variables = {
FOO = "bar"
}
}
publish = true
# everything else required to make the lambda work
}
A new version of the lambda is published whenever any of the lambda configuration changes.
When only the environment variables were changed, a new version of the lambda was not published. $LATEST was updated.
terraform apply
terraform apply
Looking at the code for Terraform's lambda support, and the AWS SDK, it looks like Terraform is relying on the publish option for CreateFunction
calls, but doing nothing about publishing when there's a pure update. UpdateFunctionConfiguration
doesn't have a publish option available. UpdateFunctionCode
does, and Terraform makes use of that, but it'll only do it _before_ calling UpdateFunctionConfiguration
, and if UpdateFunctionCode
is never called, the publish never happens.
I believe that the use of publish in UpdateFunctionCode
may need to be removed in favour of calling PublishVersion
explicitly when both update operations have been completed. Although this is just from reading the code today, so I may be mistaken about exactly what's going on here in terms of timing. But it certainly looks like if you don't cause a code update you don't get a new lambda version, and it also looks like that new version may miss updates to the function configuration if they're also being done in the same Terraform run.
I encountered this problem today as well. Do we know if there are any plans to get this addressed? Thanks!
Most helpful comment
I encountered this problem today as well. Do we know if there are any plans to get this addressed? Thanks!