Reputation: 913
We have Lambda functions that rely on values set within Lambda environment variables, and we are deploying both of these using Terraform. Sometimes we need to change the code and add new environment variables that it requires. There are distinct AWS API calls for updating Lambda function code, and the function configuration, so we assume these are distinct actions.
Does anybody know which order the two actions are performed?
If the environment variables are set first, then presumably new containers could be spun up with new vars and old code. If it's the other way around, then we may have new code failing because expected env vars are not present.
I'm fairly certain that Lambda function versioning is the answer to all this, but I'd like to know if I'm worrying unnecessarily before we go down that route.
Upvotes: 0
Views: 1790
Reputation: 56877
Configuration gets updated before function code during an update.
You can see this yourself by looking at the source code for the aws_lambda_function
resource and seeing the order of the relative API calls in the resourceAwsLambdaFunctionUpdate
method.
The configuration update happens on line 763 while the function code update happens on line 818.
Upvotes: 1