aws / aws/aws-cdk

aws-rds: export value from network-stack cannot be deleted as it is in use by database-stack

Open
#26,135 7 comments 0 reactions 0 assignees View on GitHub
@aws-cdk/aws-rds bug effort/medium p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
1d 19h
Merged PRs (30d)
71

Description

### Describe the bug

i have created a network stack with 3 subnets: one public, one private with egress, and one isolated.
in a separate database stack i'm creating a database cluster (Aurora Serverless V2 Postgres) and initially used the public subnet by setting `vpcSubnets: { subnetType: SubnetType.PUBLIC }`.

Now I would like to move the database to the isolated subnet by setting `vpcSubnets: { subnetType: SubnetType.PRIVATE_ISOLATED }`, however this results in an error: ExportsOutputRefnetworkstackvpcingressSubnet3SubnetCD2EA007C4DD55EA cannot be deleted as it is in use by database-stack.

I have tried doing a deployment that adds the new isolated subnets without removing the public ones, and that succeeded. But when I try to remove the public subnets I face the same error.

### Expected Behavior

the cdk should be able to reassign the subnets without errors

### Current Behavior

deployment fails with an error: ExportsOutputRefnetworkstackvpcingressSubnet3SubnetCD2EA007C4DD55EA cannot be deleted as it is in use by database-stack.

### Reproduction Steps

create a vpc with public and isolated subnets.
create a database cluster in a vpc with `vpcSubnets: { subnetType: SubnetType.PUBLIC }`.
then deploy again with `vpcSubnets: { subnetType: SubnetType.PRIVATE_ISOLATED }`

### Possible Solution

_No response_

### Additional Information/Context

_No response_

### CDK CLI Version

2.85.0

### Framework Version

_No response_

### Node.js Version

18.15.0

### OS

macOS

### Language

Typescript

### Language Version

TypeScript (5.1.3)

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the TypeScript reproduction using the database cluster's vpcSubnets setting and the PUBLIC-to-PRIVATE_ISOLATED transition. Trace how the network-stack subnet export is referenced by database-stack and why the old export remains in use. Done means redeploying the reproduced stacks succeeds without the export-deletion error.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.