aws / aws/aws-cdk

aws-cdk-lib: automatic dependency creation for L1 constructs

Open
#34,225 2 comments 2 reactions 0 assignees View on GitHub
aws-cdk-lib effort/medium feature-request p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the feature

When an L1 construct is pointing at another (L2?) construct cdk should automatically create the dependency example below:

### Use Case

```
const crawler = new glue.CfnCrawler(
this,
`GlueCrawler-${dynamoDbTableName}`,
{
databaseName: dbName,
role: crawlerIamRole.roleArn,
targets: {
dynamoDbTargets: [{ path: dynamoDbTableName }],
},
},
);

```

here the glue construct depends on the IAM role, even though its pointing at the role Arn we still need to create a manual dependency for the IAM role to be created first as below

```
crawler.node.addDependency(crawlerIamRole);
```

CDK should see this reference and create the dependency under the hood.

This is very similar to how terraform behaves as well. Terraform sees a dependency and makes sure the dependent resource is created first.

### Proposed Solution

_No response_

### Other Information

_No response_

### Acknowledgements

- [ ] I may be able to implement this feature request
- [ ] This feature might incur a breaking change

### CDK version used

2.150.0

### Environment details (OS name and version, etc.)

MacOS 15.4.1 (24E263)

Contributor guide

Open the contributing guide

Research direction

Start by tracing how L1 constructs represent references to other constructs and how node.addDependency is currently used in the example. Determine how automatic ordering should work across the L1 and L2 constructs; done means the shown Glue crawler example no longer needs the manual dependency while preserving correct resource creation order.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud, infrastructure
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.