Skip to content

Commit fe5ed10

Browse files
authored
feat(rds): support Aurora Serverless V2 instances (#25437)
Adding support for adding aurora serverless v2 instances to a `DatabaseCluster`. For detailed information on the design decisions see the [adr](https://github.com/corymhall/aws-cdk/blob/corymhall/rds/aurora-serverless-v2/packages/aws-cdk-lib/aws-rds/adr/aurora-serverless-v2.md) This PR adds a lot of validation to try and ensure that the user is configuring the cluster correctly. It also adds some functionality that allows users to have an easier migration experience from the deprecated properties. closes #20197 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 9664515 commit fe5ed10

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+6777
-732
lines changed

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

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,40 @@ vpc.isolatedSubnets.forEach((subnet, idx) => {
1414
cfnSubnet.addDependsOn(ipv6);
1515
});
1616

17+
const instanceProps = {
18+
instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE3, ec2.InstanceSize.MEDIUM),
19+
isFromLegacyInstanceProps: true,
20+
};
1721
new rds.DatabaseCluster(stack, 'DualstackCluster', {
1822
engine: rds.DatabaseClusterEngine.auroraMysql({ version: rds.AuroraMysqlEngineVersion.VER_3_02_0 }),
1923
credentials: rds.Credentials.fromUsername('admin', { password: cdk.SecretValue.unsafePlainText('7959866cacc02c2d243ecfe177464fe6') }),
20-
instanceProps: {
21-
instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE3, ec2.InstanceSize.MEDIUM),
22-
vpcSubnets: { subnetType: ec2.SubnetType.PRIVATE_ISOLATED },
23-
vpc,
24-
},
24+
writer: rds.ClusterInstance.provisioned('Instance1', {
25+
...instanceProps,
26+
}),
27+
readers: [
28+
rds.ClusterInstance.provisioned('Instance2', {
29+
...instanceProps,
30+
}),
31+
],
32+
vpcSubnets: { subnetType: ec2.SubnetType.PRIVATE_ISOLATED },
33+
vpc,
2534
networkType: rds.NetworkType.DUAL,
2635
removalPolicy: cdk.RemovalPolicy.DESTROY,
2736
});
2837

2938
new rds.DatabaseCluster(stack, 'Ipv4Cluster', {
3039
engine: rds.DatabaseClusterEngine.auroraMysql({ version: rds.AuroraMysqlEngineVersion.VER_3_02_0 }),
3140
credentials: rds.Credentials.fromUsername('admin', { password: cdk.SecretValue.unsafePlainText('7959866cacc02c2d243ecfe177464fe6') }),
32-
instanceProps: {
33-
instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE3, ec2.InstanceSize.MEDIUM),
34-
vpcSubnets: { subnetType: ec2.SubnetType.PRIVATE_ISOLATED },
35-
vpc,
36-
},
41+
vpcSubnets: { subnetType: ec2.SubnetType.PRIVATE_ISOLATED },
42+
vpc,
43+
writer: rds.ClusterInstance.provisioned('Instance1', {
44+
...instanceProps,
45+
}),
46+
readers: [
47+
rds.ClusterInstance.provisioned('Instance2', {
48+
...instanceProps,
49+
}),
50+
],
3751
networkType: rds.NetworkType.IPV4,
3852
removalPolicy: cdk.RemovalPolicy.DESTROY,
3953
});

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
2-
"version": "30.1.0",
2+
"version": "31.0.0",
33
"files": {
4-
"f1be03db0810455e897d5600a00d7d089273d1f89b9a319be25928bf241a9490": {
4+
"a633d33a056f9a9a775353c3902b2da4fa8318b43707e565b45a591da0888305": {
55
"source": {
66
"path": "aws-cdk-rds-cluster-rotation.template.json",
77
"packaging": "file"
88
},
99
"destinations": {
1010
"current_account-current_region": {
1111
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12-
"objectKey": "f1be03db0810455e897d5600a00d7d089273d1f89b9a319be25928bf241a9490.json",
12+
"objectKey": "a633d33a056f9a9a775353c3902b2da4fa8318b43707e565b45a591da0888305.json",
1313
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
1414
}
1515
}

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

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -646,10 +646,12 @@
646646
"Type": "AWS::RDS::DBCluster",
647647
"Properties": {
648648
"CopyTagsToSnapshot": true,
649+
"DBClusterParameterGroupName": "default.aurora-mysql8.0",
649650
"DBSubnetGroupName": {
650651
"Ref": "DatabaseSubnets56F17B9A"
651652
},
652-
"Engine": "aurora",
653+
"Engine": "aurora-mysql",
654+
"EngineVersion": "8.0.mysql_aurora.3.03.0",
653655
"MasterUsername": {
654656
"Fn::Join": [
655657
"",
@@ -692,11 +694,11 @@
692694
"DBClusterIdentifier": {
693695
"Ref": "DatabaseB269D8BB"
694696
},
695-
"DBInstanceClass": "db.t3.small",
697+
"DBInstanceClass": "db.t3.medium",
696698
"DBSubnetGroupName": {
697699
"Ref": "DatabaseSubnets56F17B9A"
698700
},
699-
"Engine": "aurora"
701+
"Engine": "aurora-mysql"
700702
},
701703
"DependsOn": [
702704
"VPCPrivateSubnet1DefaultRouteAE1D6490",
@@ -713,11 +715,11 @@
713715
"DBClusterIdentifier": {
714716
"Ref": "DatabaseB269D8BB"
715717
},
716-
"DBInstanceClass": "db.t3.small",
718+
"DBInstanceClass": "db.t3.medium",
717719
"DBSubnetGroupName": {
718720
"Ref": "DatabaseSubnets56F17B9A"
719721
},
720-
"Engine": "aurora"
722+
"Engine": "aurora-mysql"
721723
},
722724
"DependsOn": [
723725
"VPCPrivateSubnet1DefaultRouteAE1D6490",
@@ -964,10 +966,12 @@
964966
"Type": "AWS::RDS::DBCluster",
965967
"Properties": {
966968
"CopyTagsToSnapshot": true,
969+
"DBClusterParameterGroupName": "default.aurora-mysql8.0",
967970
"DBSubnetGroupName": {
968971
"Ref": "CustomRotationOptionsSubnets52AEBCED"
969972
},
970-
"Engine": "aurora",
973+
"Engine": "aurora-mysql",
974+
"EngineVersion": "8.0.mysql_aurora.3.03.0",
971975
"MasterUsername": {
972976
"Fn::Join": [
973977
"",
@@ -1010,11 +1014,11 @@
10101014
"DBClusterIdentifier": {
10111015
"Ref": "CustomRotationOptions7CA9E132"
10121016
},
1013-
"DBInstanceClass": "db.t3.small",
1017+
"DBInstanceClass": "db.t3.medium",
10141018
"DBSubnetGroupName": {
10151019
"Ref": "CustomRotationOptionsSubnets52AEBCED"
10161020
},
1017-
"Engine": "aurora"
1021+
"Engine": "aurora-mysql"
10181022
},
10191023
"DependsOn": [
10201024
"VPCPrivateSubnet1DefaultRouteAE1D6490",
@@ -1031,11 +1035,11 @@
10311035
"DBClusterIdentifier": {
10321036
"Ref": "CustomRotationOptions7CA9E132"
10331037
},
1034-
"DBInstanceClass": "db.t3.small",
1038+
"DBInstanceClass": "db.t3.medium",
10351039
"DBSubnetGroupName": {
10361040
"Ref": "CustomRotationOptionsSubnets52AEBCED"
10371041
},
1038-
"Engine": "aurora"
1042+
"Engine": "aurora-mysql"
10391043
},
10401044
"DependsOn": [
10411045
"VPCPrivateSubnet1DefaultRouteAE1D6490",
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version":"30.1.0"}
1+
{"version":"31.0.0"}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "30.1.0",
2+
"version": "31.0.0",
33
"testCases": {
44
"integ.cluster-rotation.lit": {
55
"stacks": [

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

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "30.1.0",
2+
"version": "31.0.0",
33
"artifacts": {
44
"aws-cdk-rds-cluster-rotation.assets": {
55
"type": "cdk:asset-manifest",
@@ -17,7 +17,7 @@
1717
"validateOnSynth": false,
1818
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
1919
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
20-
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/f1be03db0810455e897d5600a00d7d089273d1f89b9a319be25928bf241a9490.json",
20+
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/a633d33a056f9a9a775353c3902b2da4fa8318b43707e565b45a591da0888305.json",
2121
"requiresBootstrapStackVersion": 6,
2222
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
2323
"additionalDependencies": [
@@ -234,19 +234,28 @@
234234
"/aws-cdk-rds-cluster-rotation/Database/Resource": [
235235
{
236236
"type": "aws:cdk:logicalId",
237-
"data": "DatabaseB269D8BB"
237+
"data": "DatabaseB269D8BB",
238+
"trace": [
239+
"!!DESTRUCTIVE_CHANGES: MAY_REPLACE"
240+
]
238241
}
239242
],
240243
"/aws-cdk-rds-cluster-rotation/Database/Instance1": [
241244
{
242245
"type": "aws:cdk:logicalId",
243-
"data": "DatabaseInstance1844F58FD"
246+
"data": "DatabaseInstance1844F58FD",
247+
"trace": [
248+
"!!DESTRUCTIVE_CHANGES: MAY_REPLACE"
249+
]
244250
}
245251
],
246252
"/aws-cdk-rds-cluster-rotation/Database/Instance2": [
247253
{
248254
"type": "aws:cdk:logicalId",
249-
"data": "DatabaseInstance2AA380DEE"
255+
"data": "DatabaseInstance2AA380DEE",
256+
"trace": [
257+
"!!DESTRUCTIVE_CHANGES: MAY_REPLACE"
258+
]
250259
}
251260
],
252261
"/aws-cdk-rds-cluster-rotation/Database/RotationSingleUser/SecurityGroup/Resource": [
@@ -312,19 +321,28 @@
312321
"/aws-cdk-rds-cluster-rotation/CustomRotationOptions/Resource": [
313322
{
314323
"type": "aws:cdk:logicalId",
315-
"data": "CustomRotationOptions7CA9E132"
324+
"data": "CustomRotationOptions7CA9E132",
325+
"trace": [
326+
"!!DESTRUCTIVE_CHANGES: MAY_REPLACE"
327+
]
316328
}
317329
],
318330
"/aws-cdk-rds-cluster-rotation/CustomRotationOptions/Instance1": [
319331
{
320332
"type": "aws:cdk:logicalId",
321-
"data": "CustomRotationOptionsInstance1D693E87C"
333+
"data": "CustomRotationOptionsInstance1D693E87C",
334+
"trace": [
335+
"!!DESTRUCTIVE_CHANGES: MAY_REPLACE"
336+
]
322337
}
323338
],
324339
"/aws-cdk-rds-cluster-rotation/CustomRotationOptions/Instance2": [
325340
{
326341
"type": "aws:cdk:logicalId",
327-
"data": "CustomRotationOptionsInstance2A21FADD8"
342+
"data": "CustomRotationOptionsInstance2A21FADD8",
343+
"trace": [
344+
"!!DESTRUCTIVE_CHANGES: MAY_REPLACE"
345+
]
328346
}
329347
],
330348
"/aws-cdk-rds-cluster-rotation/CustomRotationOptions/RotationSingleUser/SARMapping": [
@@ -350,24 +368,6 @@
350368
"type": "aws:cdk:logicalId",
351369
"data": "CheckBootstrapVersion"
352370
}
353-
],
354-
"DatabaseSecretAttachmentPolicy5ACFE6CA": [
355-
{
356-
"type": "aws:cdk:logicalId",
357-
"data": "DatabaseSecretAttachmentPolicy5ACFE6CA",
358-
"trace": [
359-
"!!DESTRUCTIVE_CHANGES: WILL_DESTROY"
360-
]
361-
}
362-
],
363-
"CustomRotationOptionsSecretAttachmentPolicyAB818C64": [
364-
{
365-
"type": "aws:cdk:logicalId",
366-
"data": "CustomRotationOptionsSecretAttachmentPolicyAB818C64",
367-
"trace": [
368-
"!!DESTRUCTIVE_CHANGES: WILL_DESTROY"
369-
]
370-
}
371371
]
372372
},
373373
"displayName": "aws-cdk-rds-cluster-rotation"

0 commit comments

Comments
 (0)