Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Updating dependent stacks

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.

like image 580
mephi42 Avatar asked Mar 03 '19 12:03

mephi42


2 Answers

As the other answer suggested method looks a bit longer, here is what I did to overcome this problem after reading this guide:

  1. I have updated importing stack (i.e. 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)
  2. Deploy exporting stack (i.e. stack-layer) and make sure that the issue is gone
  3. Deploy importing stack from code base.

This was done quite quickly w/o changing source code and interrupting service run. Hope this will be useful, feel free to comment your questions.

like image 52
miradham Avatar answered Oct 19 '22 02:10

miradham


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:

  1. Update stack-layer to add a second Output containing the new value (e.g., layer-arn-2);
  2. Update stack-lambda, changing the "Fn::ImportValue": "layer-arn" reference to instead reference layer-arn-2.
  3. Update stack-layer to remove the now-unused layer-arn Output.
    (Or alternately: update 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.

like image 42
wjordan Avatar answered Oct 19 '22 02:10

wjordan