-
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
Lambda Layers - Terraform deploys new version and removes the old one #7552
Comments
+1 for this. It creates a really undesirable situation where Lambdas with old versions of layers will break when the layer is updated. |
+1 |
Just arrived at a similar issue. In my case I have the code deployment stage separated from the infrastructure deployment stage, so when creating the lambda infrastructure I don't have access to the actual code. In my case, deploying a version and then updating it with ansible results in a layer version that terraform is unaware of. My solution, which maybe good for your usecase too, is to manage layer versions outside terraform, and import them using Data Sources, like this:
There is a tradeoff in it though. You won't be managing a part of your infrastructure with it though, at least not directly, but at least the older layer versions won't be in jeopardy when updating lambda layer code. A workaround for this would be to trigger code when deleting a function, so that its layers are also deleted, like so:
From the documentation, however, it is stated that "when you delete a layer version, you can no longer configure functions to use it. However, any function that already uses the version continues to have access to it."[1] So it should not interfere with functions already configured with older layer versions when terraform deletes layer versions in order to update code. [1] https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html#configuration-layers-manage |
That is indeed true. However it will prevent you to redeploy existing lambda. E.g. if you have some CI/CD routines that deploy some lambdas automatically, you would actually have to go and modify the layer requirements for all of them, otherwise all deploys will crash. Furthermore, if the new version of layer brings some incompatibility issues (e.g. the lambdas working with layer-v1 would be broken after being updated to layer-v2) there would be no easy way to resolve the problem. @CGreenburg I saw you've pushed a PR 👍👍 |
Hi Team, when this fix will be released? |
It's waiting on integration tests I think. I haven't added them in that merge request which is why it can't move forward. If anyone is willing to add them, feel free to fork and submit a new pull request. Thanks! |
Thanks for the information! the fix is much needed for our Organization. Will you be able to work on this or can you help me where/what the impacted component is and the necessary changes (on a high level) -as i haven't worked on this earlier. |
For now one can make use of terraform command |
ETA on the MR :) ? |
Hi, we encounter the issue and this is damageable for us. Is someone is working on this? |
The only viable workaround for us so far is to call However, in general you will want to do this only if there is a modification planned so you would want to do Unfortunately, there is then no longer a way of automating the removal of all versions of a layer upon I think the real problem here is that @apparentlymart is there anything that can be done to solve this issue? I'm not familiar enough with the regression testing system to help or I would. |
Any update on this? |
This functionality has been released in v3.66.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
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. |
Community Note
Terraform Version
Terraform v0.11.11
Affected Resource(s)
Terraform Configuration Files
Debug Output
Panic Output
Expected Behavior
If something changes in the code It should just add lambda layer new version and keep the old one
Actual Behavior
If something changes in the code, It adds lambda layer new version but everytime it also deletes the old one.
Steps to Reproduce
terraform apply
Important Factoids
References
The text was updated successfully, but these errors were encountered: