rds: refreshing VPC context generates inconsistent ordering that causes unnecessary DBProxy resource replacement
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the bug
We do a subnet selection to get our subnets. The behaviour is non-deterministic. Cfn is too stupid to treat the list as a set, so... we get stuff like this. As you can see below it wants to replace our proxy but can't because it's a named resource. The reason it wants to replace the resource is that the order of the subnets in the list changed.
```
[~] AWS::RDS::DBProxy GlobalStagingUsWest2/DochistoryAuroraStg/Or1DochistoryStg/Proxy Or1DochistoryStgProxy87EB58B0 replace
└─ [~] VpcSubnetIds (requires replacement)
└─ @@ -4,9 +4,9 @@
[ ] "subnet-07260952ef7787a6d",
[ ] "subnet-0b868f96519464bdb",
[ ] "subnet-0d9a398b9a31f6fcc",
+ [+] "subnet-09a4826d4eb84d03c",
[ ] "subnet-0c8fd644d2a2f91c0",
[ ] "subnet-0656782790830be94",
- [-] "subnet-08a104b7791c32f08",
- [-] "subnet-09a4826d4eb84d03c",
- [-] "subnet-029c625dae0eb4783"
+ [+] "subnet-029c625dae0eb4783",
+ [+] "subnet-08a104b7791c32f08"
[ ] ]
```
As a result, the stack update is broken and we can't roll forward actual changes.
### Expected Behavior
Cfn shouldn't differentiate between sets and lists and not treat sets like the order matters.
CDK should compensate for Cfn's incompetence by always providing sets as ordered lists. Unfortunately this is probably a breaking change. But you could put it behind a feature flag, I guess.
### Current Behavior
No idea what caused the order of the subnets to change.
### Reproduction Steps
No idea what caused the order of the subnets to change.
### Possible Solution
_No response_
### Additional Information/Context
_No response_
### CDK CLI Version
2.78.0
### Framework Version
_No response_
### Node.js Version
16.20
### OS
Mac
### Language
Typescript
### Language Version
4.9.5
### Other information
_No response_
Contributor guide
Research direction
The issue names no files or tests; begin with the subnet selection feeding AWS::RDS::DBProxy and its VpcSubnetIds, using the reported CDK CLI version as context. Compare synthesized subnet ordering across repeated runs and define done as stable ordering that avoids unnecessary replacement, with a regression test if the project provides one.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cloud, database, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100