I have the stack called stack-layer, which exports an ARN of a Lambda layer, and another stack called stack-lambda, which contains a Lambda, which references that Lambda layer.
When I try to update stack-layer, I get an error: Export layer-arn cannot be deleted as it is in use by stack-lambda, which is totally understandable. However, I don't see how to proceed with an update from here.
Is there any way to update such dependent stacks? Amazon's walkthrough does not seem to touch this topic at all.
As the other answer suggested method looks a bit longer, here is what I did to overcome this problem after reading this guide:
stack-lambda) to use actual value of exported parameter(I did that using AWS console so that I don't have to make change in my yml code, submit and deploy)stack-layer) and make sure that the issue is goneThis was done quite quickly w/o changing source code and interrupting service run. Hope this will be useful, feel free to comment your questions.
As described in Fn::ImportValue documentation, being unable to modify a referenced output is indeed expected behavior:
Note
The following restrictions apply to cross-stack references:
[...]
- You can't modify or remove an output value that is referenced by another stack.
In order to work around this when updating the output, you can use a second, temporary Output value to handle the transition:
stack-layer to add a second Output containing the new value (e.g., layer-arn-2);stack-lambda, changing the "Fn::ImportValue": "layer-arn" reference to instead reference layer-arn-2.stack-layer to remove the now-unused layer-arn Output.stack-layer to set layer-arn to the same value as layer-arn-2; update stack-lambda to reference layer-arn; then finally update stack-layer to remove the layer-arn-2 Output.It's a bit tedious, but it should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With