Skip to content

Commit 1fd22a7

Browse files
authored
fix(rds): prevent rendering deprecated credentials when creating a database cluster from a snapshot (under feature flag) (#27174)
This PR fixes a bug where an extra database secret is being generated when an RDS database cluster is being created from a snapshot. On the `DatabaseClusterFromSnapshotProps` interface, we deprecated the `credentials` property and, at the same, introduced `snapshotCredentials` as the recommended replacement. However, the default behavior associated with the `credentials` property was not removed as doing so would introduce a breaking change for some users as detailed in this [PR](#20777). As a result, users just using the recommended `snapshotCredentials` property to create a new RDS database cluster are seeing an extra, unwanted secret being created. Closes #23815 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 3d9ca8d commit 1fd22a7

File tree

10 files changed

+180
-163
lines changed

10 files changed

+180
-163
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-rds/test/integ.cluster-snapshot.js.snapshot/cdk-integ-cluster-snapshot.assets.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-rds/test/integ.cluster-snapshot.js.snapshot/cdk-integ-cluster-snapshot.template.json

+8-44
Original file line numberDiff line numberDiff line change
@@ -426,12 +426,12 @@
426426
"Type": "AWS::RDS::DBCluster",
427427
"Properties": {
428428
"CopyTagsToSnapshot": true,
429-
"DBClusterParameterGroupName": "default.aurora-mysql5.7",
429+
"DBClusterParameterGroupName": "default.aurora-mysql8.0",
430430
"DBSubnetGroupName": {
431431
"Ref": "ClusterSubnetsDCFA5CB7"
432432
},
433433
"Engine": "aurora-mysql",
434-
"EngineVersion": "5.7.mysql_aurora.2.10.2",
434+
"EngineVersion": "8.0.mysql_aurora.3.04.0",
435435
"MasterUserPassword": {
436436
"Fn::Join": [
437437
"",
@@ -474,7 +474,7 @@
474474
"DBClusterIdentifier": {
475475
"Ref": "ClusterEB0386A7"
476476
},
477-
"DBInstanceClass": "db.t3.small",
477+
"DBInstanceClass": "db.t3.medium",
478478
"DBSubnetGroupName": {
479479
"Ref": "ClusterSubnetsDCFA5CB7"
480480
},
@@ -495,7 +495,7 @@
495495
"DBClusterIdentifier": {
496496
"Ref": "ClusterEB0386A7"
497497
},
498-
"DBInstanceClass": "db.t3.small",
498+
"DBInstanceClass": "db.t3.medium",
499499
"DBSubnetGroupName": {
500500
"Ref": "ClusterSubnetsDCFA5CB7"
501501
},
@@ -1357,42 +1357,6 @@
13571357
}
13581358
}
13591359
},
1360-
"FromSnapshotSecret9100F61C": {
1361-
"Type": "AWS::SecretsManager::Secret",
1362-
"Properties": {
1363-
"Description": {
1364-
"Fn::Join": [
1365-
"",
1366-
[
1367-
"Generated by the CDK for stack: ",
1368-
{
1369-
"Ref": "AWS::StackName"
1370-
}
1371-
]
1372-
]
1373-
},
1374-
"GenerateSecretString": {
1375-
"ExcludeCharacters": " %+~`#$&*()|[]{}:;<>?!'/@\"\\",
1376-
"GenerateStringKey": "password",
1377-
"PasswordLength": 30,
1378-
"SecretStringTemplate": "{\"username\":\"admin\"}"
1379-
}
1380-
},
1381-
"UpdateReplacePolicy": "Delete",
1382-
"DeletionPolicy": "Delete"
1383-
},
1384-
"FromSnapshotSecretAttachmentB62DA1C6": {
1385-
"Type": "AWS::SecretsManager::SecretTargetAttachment",
1386-
"Properties": {
1387-
"SecretId": {
1388-
"Ref": "FromSnapshotSecret9100F61C"
1389-
},
1390-
"TargetId": {
1391-
"Ref": "FromSnapshotEE0682C5"
1392-
},
1393-
"TargetType": "AWS::RDS::DBCluster"
1394-
}
1395-
},
13961360
"cdkintegclustersnapshotFromSnapshotSnapshotSecretD93327943fdaad7efa858a3daf9490cf0a702aeb": {
13971361
"Type": "AWS::SecretsManager::Secret",
13981362
"Properties": {
@@ -1486,12 +1450,12 @@
14861450
"Type": "AWS::RDS::DBCluster",
14871451
"Properties": {
14881452
"CopyTagsToSnapshot": true,
1489-
"DBClusterParameterGroupName": "default.aurora-mysql5.7",
1453+
"DBClusterParameterGroupName": "default.aurora-mysql8.0",
14901454
"DBSubnetGroupName": {
14911455
"Ref": "FromSnapshotSubnets9ED4B8EE"
14921456
},
14931457
"Engine": "aurora-mysql",
1494-
"EngineVersion": "5.7.mysql_aurora.2.10.2",
1458+
"EngineVersion": "8.0.mysql_aurora.3.04.0",
14951459
"MasterUserPassword": {
14961460
"Fn::Join": [
14971461
"",
@@ -1528,7 +1492,7 @@
15281492
"DBClusterIdentifier": {
15291493
"Ref": "FromSnapshotEE0682C5"
15301494
},
1531-
"DBInstanceClass": "db.t3.small",
1495+
"DBInstanceClass": "db.t3.medium",
15321496
"DBSubnetGroupName": {
15331497
"Ref": "FromSnapshotSubnets9ED4B8EE"
15341498
},
@@ -1549,7 +1513,7 @@
15491513
"DBClusterIdentifier": {
15501514
"Ref": "FromSnapshotEE0682C5"
15511515
},
1552-
"DBInstanceClass": "db.t3.small",
1516+
"DBInstanceClass": "db.t3.medium",
15531517
"DBSubnetGroupName": {
15541518
"Ref": "FromSnapshotSubnets9ED4B8EE"
15551519
},

packages/@aws-cdk-testing/framework-integ/test/aws-rds/test/integ.cluster-snapshot.js.snapshot/manifest.json

+19-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-rds/test/integ.cluster-snapshot.js.snapshot/tree.json

+8-78
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-rds/test/integ.cluster-snapshot.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ class TestStack extends Stack {
1717
const vpc = new ec2.Vpc(this, 'Vpc', { maxAzs: 2, natGateways: 1, restrictDefaultSecurityGroup: false });
1818

1919
const instanceProps = {
20-
instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE3, ec2.InstanceSize.SMALL),
20+
instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE3, ec2.InstanceSize.MEDIUM),
2121
isFromLegacyInstanceProps: true,
2222
};
2323
const cluster = new rds.DatabaseCluster(this, 'Cluster', {
24-
engine: rds.DatabaseClusterEngine.auroraMysql({ version: rds.AuroraMysqlEngineVersion.VER_2_10_2 }),
24+
engine: rds.DatabaseClusterEngine.auroraMysql({ version: rds.AuroraMysqlEngineVersion.VER_3_04_0 }),
2525
writer: ClusterInstance.provisioned('Instance1', {
2626
...instanceProps,
2727
}),
@@ -42,7 +42,7 @@ class TestStack extends Stack {
4242
const fromSnapshot = new rds.DatabaseClusterFromSnapshot(this, 'FromSnapshot', {
4343
snapshotIdentifier: snapshoter.snapshotArn,
4444
snapshotCredentials: rds.SnapshotCredentials.fromGeneratedSecret('admin'),
45-
engine: rds.DatabaseClusterEngine.auroraMysql({ version: rds.AuroraMysqlEngineVersion.VER_2_10_2 }),
45+
engine: rds.DatabaseClusterEngine.auroraMysql({ version: rds.AuroraMysqlEngineVersion.VER_3_04_0 }),
4646
writer: ClusterInstance.provisioned('Instance1', {
4747
...instanceProps,
4848
}),

0 commit comments

Comments
 (0)