question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No longer accessing another stack's resource causes deadly embrace

See original GitHub issue

CDK’s automatic determination and synthesis of exports to imports can get locked into a deadly embrace that cannot be resolved without destroying your stacks.

Reproduction Steps

Stack1 creates a common Security Group, sg1. Stack2 uses sg1.

CDK’s automatic determination and synthesis described here, will generate an export output from Stack1 for sg1 and an Fn:ImportValue into Stack2.

Then you deploy these stacks.

Later, you decide that Stack2 really needs it’s own more specific Security Group, so you create it’s own sg2. Again, CDK’s automatic determination and synthesis realizes that sg1 is no longer referenced by Stack2 (or any other stack) and attempts to delete the Export of sg1 from Stack1.

This will fail and cannot be deployed.

CloudFormation will be prevented from deleting sg1 as an export from Stack1 since it is currently being used as an Import in the (existing) Stack2. Ironically, you were trying to update Stack2 to no longer reference Stack1’s sg1.

Error Log

UPDATE_ROLLBACK_IN_P | AWS::CloudFormation::Stack  | Stack1 Export Stack1:ExportsOutputFnGetAtt-sg1-C785ABD5GroupId30372C66 cannot be deleted as it is in use by Stack2

Environment

  • **CLI Version : aws-cli/1.16.223 Python/3.7.4 Darwin/18.7.0 botocore/1.12.213
  • **Framework Version: 1.34.1 (build 7b21aa0)
  • **OS : macOS 10.14.6
  • **Language : Python3

Other


This is 🐛 Bug Report

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:16
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
austinbvcommented, May 7, 2020

Our solution is to deploy the substack with the -e flag then deploy the parent stack.

Even some documentation around that would be stronger than just two immutable stacks. Could you always update leaf nodes first, then update the full stack again

1reaction
skinny85commented, Oct 20, 2020

@Dzhuneyt while dealing with removing cross-stack references can be tricky in the CDK, there is actually a way to do it. Check out this article: https://www.endoflineblog.com/cdk-tips-03-how-to-unblock-cross-stack-references for a step-by-step guide on how to unblock yourself.

Thanks, Adam

Read more comments on GitHub >

github_iconTop Results From Across the Web

CDK tips, part 3 – how to unblock cross-stack references
All you have to do is pass an object from one Stack to another, and reference it there. The CDK will generate a...
Read more >
CDK Deployment Best Practices : r/aws - Reddit
The reason is that cross-stack resources are super difficult to maintain over ... deadly embrace which means you cannot deploy either stack.
Read more >
AWS CDK cross-stack references and deployment order
First I deploy the stack that uses the export so it doesn't use it anymore. Then I deploy the stack that creates the...
Read more >
Update CloudFormation stacks that are failing because of ...
If you delete a resource that was created by a CloudFormation stack, then your stack fails to update, and you get an error...
Read more >
Encounter deadlock even when there is no relation between ...
Deadlocks occur when 2 or more sessions are waiting on each other. It doesn't matter if the deadlocked resources are rows in the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found