aws / aws/aws-cdk

(core): improve decoupling dependent stacks (currently can cause deploy failure)

Open
#19,032 7 comments 1 reaction 0 assignees View on GitHub
@aws-cdk/core effort/medium feature-request feature/enhancement p1
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### What is the problem?

I have a dependency between two stacks (stack A imports X which stack B exports). When I try to remove this dependency (stack A no longer imports X), it break if CDK decides to deploy stack B before stack A.

### Reproduction Steps

N/A

### What did you expect to happen?

CDK is clever enough to deploy stack A before stack B, and thus removing the import before removing the export.

### What actually happened?

CDK deployed stack B before stack A, and deployment failed:
```
StackB | 0/2 | 8:34:25 AM | UPDATE_ROLLBACK_IN_P | AWS::CloudFormation::Stack | Stack B Export StackB:X cannot be deleted as it is in use by StackA
```

### CDK CLI Version

2.12.0 (build c9786db)

### Framework Version

_No response_

### Node.js Version

v16.13.0

### OS

Linux

### Language

Java

### Language Version

11

### Other information

A workaround is to force a specific deployment order by adding an explicit dependency:
```
stackB.addDependency(stackA);
```

Contributor guide

Open the contributing guide

Research direction

Start by tracing how CDK determines deployment order for dependent stacks when an import is removed, using the StackA/StackB scenario described in the issue. Reproduce the transition without the explicit stackB.addDependency(stackA) workaround, and consider the issue complete when the export can be removed without deployment failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.