[rds]: specify a name for the secret will destroy the old cluster and create a new one
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 74
Description
After specify the name of the secret that saves the admin password, the deploy cause the cluster to be destroyed and then create a new one.
### Reproduction Steps
1. Create an RDS cluster without specify the name for the secret and deploy. A secret for the admin password is created with a generated name like `DatabaseSecret3B817195-CjKSXGL6fXiP`
```typescript
const vpc = new ec2.Vpc(stack, 'VPC')
new rds.DatabaseCluster(stack, 'Database', {
engine: rds.DatabaseClusterEngine.auroraMysql({ version: rds.AuroraMysqlEngineVersion.VER_2_08_1 }),
instances: 3,
instanceProps: {
vpcSubnets: {
subnetType: ec2.SubnetType.PUBLIC,
},
vpc,
},
})
```
2. Update the code to specify a name for the secret and deploy.
```typescript
const vpc = new ec2.Vpc(stack, 'VPC')
new rds.DatabaseCluster(stack, 'Database', {
engine: rds.DatabaseClusterEngine.auroraMysql({ version: rds.AuroraMysqlEngineVersion.VER_2_08_1 }),
instances: 3,
instanceProps: {
vpcSubnets: {
subnetType: ec2.SubnetType.PUBLIC,
},
vpc,
},
+ credentials: rds.Credentials.fromGeneratedSecret('admin', {
+ secretName: 'my-secret-name',
+ }),
})
```
### What did you expect to happen?
The secret name changed from `DatabaseSecret3B817195-CjKSXGL6fXiP` to the `my-secret-name`. Or `DatabaseSecret3B817195-CjKSXGL6fXiP` was deleted and `my-secret-name` was created with the same content. The cluster is kept unchanged.
### What actually happened?
The cluster was destroyed and a new cluster was created
### Environment
- **CDK CLI Version :**1.92.0
- **Framework Version:**1.95.1
- **Node.js Version:** v14.13.0
- **OS :**Mac
- **Language (Version):** TypeScript (3.9.7)
### Other
---
This is :bug: Bug Report
Contributor guide
Research direction
Start at the rds.DatabaseCluster credentials handling shown in the reproduction and inspect the synthesized CloudFormation diff for the secret and cluster resources. Trace why changing secretName causes the cluster replacement; done means the secret can be renamed or recreated with the same content without replacing the existing cluster.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, mysql, typescript
- Domain
- cloud, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100