From 0319492d8b61480d00697fb0c7a66e532bc3b33e Mon Sep 17 00:00:00 2001 From: Jonathan Goldwasser Date: Thu, 10 Nov 2022 17:58:05 +0100 Subject: [PATCH 1/6] feat(rds): General Purpose gp3 storage volumes for database instance Add support for GP3 storage type. See https://aws.amazon.com/about-aws/whats-new/2022/11/amazon-rds-general-purpose-gp3-storage-volumes/ --- packages/@aws-cdk/aws-rds/README.md | 26 +- packages/@aws-cdk/aws-rds/lib/instance.ts | 24 +- .../@aws-cdk/aws-rds/test/instance.test.ts | 13 + ...efaultTestDeployAssert21C147A7.assets.json | 19 + ...aultTestDeployAssert21C147A7.template.json | 36 + .../cdk-integ-rds-instance-gp3.assets.json | 19 + .../cdk-integ-rds-instance-gp3.template.json | 507 ++++++++++ .../integ.instance-gp3.js.snapshot/cdk.out | 1 + .../integ.instance-gp3.js.snapshot/integ.json | 12 + .../manifest.json | 261 +++++ .../integ.instance-gp3.js.snapshot/tree.json | 896 ++++++++++++++++++ .../aws-rds/test/integ.instance-gp3.ts | 29 + 12 files changed, 1839 insertions(+), 4 deletions(-) create mode 100644 packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/InstanceGp3TestDefaultTestDeployAssert21C147A7.assets.json create mode 100644 packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/InstanceGp3TestDefaultTestDeployAssert21C147A7.template.json create mode 100644 packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/cdk-integ-rds-instance-gp3.assets.json create mode 100644 packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/cdk-integ-rds-instance-gp3.template.json create mode 100644 packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/cdk.out create mode 100644 packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/integ.json create mode 100644 packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/manifest.json create mode 100644 packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/tree.json create mode 100644 packages/@aws-cdk/aws-rds/test/integ.instance-gp3.ts diff --git a/packages/@aws-cdk/aws-rds/README.md b/packages/@aws-cdk/aws-rds/README.md index 35ea8fff042ad..df4bdf8e97768 100644 --- a/packages/@aws-cdk/aws-rds/README.md +++ b/packages/@aws-cdk/aws-rds/README.md @@ -81,7 +81,7 @@ new rds.DatabaseClusterFromSnapshot(this, 'Database', { ### Updating the database instances in a cluster -Database cluster instances may be updated in bulk or on a rolling basis. +Database cluster instances may be updated in bulk or on a rolling basis. An update to all instances in a cluster may cause significant downtime. To reduce the downtime, set the `instanceUpdateBehavior` property in `DatabaseClusterBaseProps` to `InstanceUpdateBehavior.ROLLING`. This adds a dependency between each instance so the update is performed on only one instance at a time. @@ -188,6 +188,26 @@ Creating a "production" Oracle database instance with option and parameter group [example of setting up a production oracle instance](test/integ.instance.lit.ts) +Use the `storageType` property to specify the [type of storage](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_Storage.html) +to use for the instance: + +```ts +declare const vpc: ec2.Vpc; + +const iopsInstance = new rds.DatabaseInstance(this, 'IopsInstance', { + engine: rds.DatabaseInstanceEngine.mysql({ version: MysqlEngineVersion.VER_8_0_30 }), + vpc, + storateType: rds.StorageType.IO1, + iops: 5000, +}); + +const gp3Instance = new rds.DatabaseInstance(this, 'Gp3Instance', { + engine: rds.DatabaseInstanceEngine.mysql({ version: MysqlEngineVersion.VER_8_0_30 }), + vpc, + storateType: rds.StorageType.GP3, +}); +``` + ## Setting Public Accessibility You can set public accessibility for the database instance or cluster using the `publiclyAccessible` property. @@ -737,8 +757,8 @@ To learn more about using the Data API, see the [documentation](https://docs.aws ### Default VPC -The `vpc` parameter is optional. +The `vpc` parameter is optional. If not provided, the cluster will be created in the default VPC of the account and region. -As this VPC is not deployed with AWS CDK, you can't configure the `vpcSubnets`, `subnetGroup` or `securityGroups` of the Aurora Serverless Cluster. +As this VPC is not deployed with AWS CDK, you can't configure the `vpcSubnets`, `subnetGroup` or `securityGroups` of the Aurora Serverless Cluster. If you want to provide one of `vpcSubnets`, `subnetGroup` or `securityGroups` parameter, please provide a `vpc`. diff --git a/packages/@aws-cdk/aws-rds/lib/instance.ts b/packages/@aws-cdk/aws-rds/lib/instance.ts index f25d53747835a..5e4d7e00ddc8f 100644 --- a/packages/@aws-cdk/aws-rds/lib/instance.ts +++ b/packages/@aws-cdk/aws-rds/lib/instance.ts @@ -256,20 +256,42 @@ export interface ProcessorFeatures { /** * The type of storage. + * + * @see https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_Storage.html */ export enum StorageType { /** * Standard. + * + * Amazon RDS supports magnetic storage for backward compatibility. It is recommended to use + * General Purpose SSD or Provisioned IOPS SSD for any new storage needs. + * + * @see https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_Storage.html#CHAP_Storage.Magnetic */ STANDARD = 'standard', /** - * General purpose (SSD). + * General purpose SSD (gp2). + * + * Baseline performance determined by volume size + * + * @see https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_Storage.html#Concepts.Storage.GeneralSSD */ GP2 = 'gp2', + /** + * General purpose SSD (gp3). + * + * Performance scales independently from storage + * + * @see https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_Storage.html#Concepts.Storage.GeneralSSD + */ + GP3 = 'gp3', + /** * Provisioned IOPS (SSD). + * + * @see https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_Storage.html#USER_PIOPS */ IO1 = 'io1' } diff --git a/packages/@aws-cdk/aws-rds/test/instance.test.ts b/packages/@aws-cdk/aws-rds/test/instance.test.ts index 14c26071f9926..e8faa149af158 100644 --- a/packages/@aws-cdk/aws-rds/test/instance.test.ts +++ b/packages/@aws-cdk/aws-rds/test/instance.test.ts @@ -1708,6 +1708,19 @@ describe('instance', () => { Engine: 'postgres', }); }); + + test('gp3 storage type', () => { + new rds.DatabaseInstance(stack, 'Instance', { + engine: rds.DatabaseInstanceEngine.mysql({ version: rds.MysqlEngineVersion.VER_8_0_30 }), + instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE3, ec2.InstanceSize.SMALL), + vpc, + storageType: rds.StorageType.GP3, + }); + + Template.fromStack(stack).hasResourceProperties('AWS::RDS::DBInstance', { + StorageType: 'gp3', + }); + }); }); test.each([ diff --git a/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/InstanceGp3TestDefaultTestDeployAssert21C147A7.assets.json b/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/InstanceGp3TestDefaultTestDeployAssert21C147A7.assets.json new file mode 100644 index 0000000000000..7bd94933f2458 --- /dev/null +++ b/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/InstanceGp3TestDefaultTestDeployAssert21C147A7.assets.json @@ -0,0 +1,19 @@ +{ + "version": "21.0.0", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "InstanceGp3TestDefaultTestDeployAssert21C147A7.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/InstanceGp3TestDefaultTestDeployAssert21C147A7.template.json b/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/InstanceGp3TestDefaultTestDeployAssert21C147A7.template.json new file mode 100644 index 0000000000000..ad9d0fb73d1dd --- /dev/null +++ b/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/InstanceGp3TestDefaultTestDeployAssert21C147A7.template.json @@ -0,0 +1,36 @@ +{ + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/cdk-integ-rds-instance-gp3.assets.json b/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/cdk-integ-rds-instance-gp3.assets.json new file mode 100644 index 0000000000000..5c6f13abed340 --- /dev/null +++ b/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/cdk-integ-rds-instance-gp3.assets.json @@ -0,0 +1,19 @@ +{ + "version": "21.0.0", + "files": { + "1e4562be1c7ae8012b9410e312a395770f1a31653d4faa57ddec4ae724b1a087": { + "source": { + "path": "cdk-integ-rds-instance-gp3.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "1e4562be1c7ae8012b9410e312a395770f1a31653d4faa57ddec4ae724b1a087.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/cdk-integ-rds-instance-gp3.template.json b/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/cdk-integ-rds-instance-gp3.template.json new file mode 100644 index 0000000000000..a86660ab2311d --- /dev/null +++ b/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/cdk-integ-rds-instance-gp3.template.json @@ -0,0 +1,507 @@ +{ + "Resources": { + "Vpc8378EB38": { + "Type": "AWS::EC2::VPC", + "Properties": { + "CidrBlock": "10.0.0.0/16", + "EnableDnsHostnames": true, + "EnableDnsSupport": true, + "InstanceTenancy": "default", + "Tags": [ + { + "Key": "Name", + "Value": "cdk-integ-rds-instance-gp3/Vpc" + } + ] + } + }, + "VpcPublicSubnet1Subnet5C2D37C4": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "AvailabilityZone": { + "Fn::Select": [ + 0, + { + "Fn::GetAZs": "" + } + ] + }, + "CidrBlock": "10.0.0.0/18", + "MapPublicIpOnLaunch": true, + "Tags": [ + { + "Key": "aws-cdk:subnet-name", + "Value": "Public" + }, + { + "Key": "aws-cdk:subnet-type", + "Value": "Public" + }, + { + "Key": "Name", + "Value": "cdk-integ-rds-instance-gp3/Vpc/PublicSubnet1" + } + ] + } + }, + "VpcPublicSubnet1RouteTable6C95E38E": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "Tags": [ + { + "Key": "Name", + "Value": "cdk-integ-rds-instance-gp3/Vpc/PublicSubnet1" + } + ] + } + }, + "VpcPublicSubnet1RouteTableAssociation97140677": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VpcPublicSubnet1RouteTable6C95E38E" + }, + "SubnetId": { + "Ref": "VpcPublicSubnet1Subnet5C2D37C4" + } + } + }, + "VpcPublicSubnet1DefaultRoute3DA9E72A": { + "Type": "AWS::EC2::Route", + "Properties": { + "RouteTableId": { + "Ref": "VpcPublicSubnet1RouteTable6C95E38E" + }, + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": { + "Ref": "VpcIGWD7BA715C" + } + }, + "DependsOn": [ + "VpcVPCGWBF912B6E" + ] + }, + "VpcPublicSubnet1EIPD7E02669": { + "Type": "AWS::EC2::EIP", + "Properties": { + "Domain": "vpc", + "Tags": [ + { + "Key": "Name", + "Value": "cdk-integ-rds-instance-gp3/Vpc/PublicSubnet1" + } + ] + } + }, + "VpcPublicSubnet1NATGateway4D7517AA": { + "Type": "AWS::EC2::NatGateway", + "Properties": { + "SubnetId": { + "Ref": "VpcPublicSubnet1Subnet5C2D37C4" + }, + "AllocationId": { + "Fn::GetAtt": [ + "VpcPublicSubnet1EIPD7E02669", + "AllocationId" + ] + }, + "Tags": [ + { + "Key": "Name", + "Value": "cdk-integ-rds-instance-gp3/Vpc/PublicSubnet1" + } + ] + }, + "DependsOn": [ + "VpcPublicSubnet1DefaultRoute3DA9E72A", + "VpcPublicSubnet1RouteTableAssociation97140677" + ] + }, + "VpcPublicSubnet2Subnet691E08A3": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "AvailabilityZone": { + "Fn::Select": [ + 1, + { + "Fn::GetAZs": "" + } + ] + }, + "CidrBlock": "10.0.64.0/18", + "MapPublicIpOnLaunch": true, + "Tags": [ + { + "Key": "aws-cdk:subnet-name", + "Value": "Public" + }, + { + "Key": "aws-cdk:subnet-type", + "Value": "Public" + }, + { + "Key": "Name", + "Value": "cdk-integ-rds-instance-gp3/Vpc/PublicSubnet2" + } + ] + } + }, + "VpcPublicSubnet2RouteTable94F7E489": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "Tags": [ + { + "Key": "Name", + "Value": "cdk-integ-rds-instance-gp3/Vpc/PublicSubnet2" + } + ] + } + }, + "VpcPublicSubnet2RouteTableAssociationDD5762D8": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VpcPublicSubnet2RouteTable94F7E489" + }, + "SubnetId": { + "Ref": "VpcPublicSubnet2Subnet691E08A3" + } + } + }, + "VpcPublicSubnet2DefaultRoute97F91067": { + "Type": "AWS::EC2::Route", + "Properties": { + "RouteTableId": { + "Ref": "VpcPublicSubnet2RouteTable94F7E489" + }, + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": { + "Ref": "VpcIGWD7BA715C" + } + }, + "DependsOn": [ + "VpcVPCGWBF912B6E" + ] + }, + "VpcPrivateSubnet1Subnet536B997A": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "AvailabilityZone": { + "Fn::Select": [ + 0, + { + "Fn::GetAZs": "" + } + ] + }, + "CidrBlock": "10.0.128.0/18", + "MapPublicIpOnLaunch": false, + "Tags": [ + { + "Key": "aws-cdk:subnet-name", + "Value": "Private" + }, + { + "Key": "aws-cdk:subnet-type", + "Value": "Private" + }, + { + "Key": "Name", + "Value": "cdk-integ-rds-instance-gp3/Vpc/PrivateSubnet1" + } + ] + } + }, + "VpcPrivateSubnet1RouteTableB2C5B500": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "Tags": [ + { + "Key": "Name", + "Value": "cdk-integ-rds-instance-gp3/Vpc/PrivateSubnet1" + } + ] + } + }, + "VpcPrivateSubnet1RouteTableAssociation70C59FA6": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VpcPrivateSubnet1RouteTableB2C5B500" + }, + "SubnetId": { + "Ref": "VpcPrivateSubnet1Subnet536B997A" + } + } + }, + "VpcPrivateSubnet1DefaultRouteBE02A9ED": { + "Type": "AWS::EC2::Route", + "Properties": { + "RouteTableId": { + "Ref": "VpcPrivateSubnet1RouteTableB2C5B500" + }, + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": { + "Ref": "VpcPublicSubnet1NATGateway4D7517AA" + } + } + }, + "VpcPrivateSubnet2Subnet3788AAA1": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "AvailabilityZone": { + "Fn::Select": [ + 1, + { + "Fn::GetAZs": "" + } + ] + }, + "CidrBlock": "10.0.192.0/18", + "MapPublicIpOnLaunch": false, + "Tags": [ + { + "Key": "aws-cdk:subnet-name", + "Value": "Private" + }, + { + "Key": "aws-cdk:subnet-type", + "Value": "Private" + }, + { + "Key": "Name", + "Value": "cdk-integ-rds-instance-gp3/Vpc/PrivateSubnet2" + } + ] + } + }, + "VpcPrivateSubnet2RouteTableA678073B": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "Tags": [ + { + "Key": "Name", + "Value": "cdk-integ-rds-instance-gp3/Vpc/PrivateSubnet2" + } + ] + } + }, + "VpcPrivateSubnet2RouteTableAssociationA89CAD56": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VpcPrivateSubnet2RouteTableA678073B" + }, + "SubnetId": { + "Ref": "VpcPrivateSubnet2Subnet3788AAA1" + } + } + }, + "VpcPrivateSubnet2DefaultRoute060D2087": { + "Type": "AWS::EC2::Route", + "Properties": { + "RouteTableId": { + "Ref": "VpcPrivateSubnet2RouteTableA678073B" + }, + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": { + "Ref": "VpcPublicSubnet1NATGateway4D7517AA" + } + } + }, + "VpcIGWD7BA715C": { + "Type": "AWS::EC2::InternetGateway", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": "cdk-integ-rds-instance-gp3/Vpc" + } + ] + } + }, + "VpcVPCGWBF912B6E": { + "Type": "AWS::EC2::VPCGatewayAttachment", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "InternetGatewayId": { + "Ref": "VpcIGWD7BA715C" + } + } + }, + "InstanceSubnetGroupF2CBA54F": { + "Type": "AWS::RDS::DBSubnetGroup", + "Properties": { + "DBSubnetGroupDescription": "Subnet group for Instance database", + "SubnetIds": [ + { + "Ref": "VpcPrivateSubnet1Subnet536B997A" + }, + { + "Ref": "VpcPrivateSubnet2Subnet3788AAA1" + } + ] + } + }, + "InstanceSecurityGroupB4E5FA83": { + "Type": "AWS::EC2::SecurityGroup", + "Properties": { + "GroupDescription": "Security group for Instance database", + "SecurityGroupEgress": [ + { + "CidrIp": "0.0.0.0/0", + "Description": "Allow all outbound traffic by default", + "IpProtocol": "-1" + } + ], + "VpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "InstanceSecret478E0A47": { + "Type": "AWS::SecretsManager::Secret", + "Properties": { + "Description": { + "Fn::Join": [ + "", + [ + "Generated by the CDK for stack: ", + { + "Ref": "AWS::StackName" + } + ] + ] + }, + "GenerateSecretString": { + "ExcludeCharacters": " %+~`#$&*()|[]{}:;<>?!'/@\"\\", + "GenerateStringKey": "password", + "PasswordLength": 30, + "SecretStringTemplate": "{\"username\":\"admin\"}" + } + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "InstanceSecretAttachment83BEE581": { + "Type": "AWS::SecretsManager::SecretTargetAttachment", + "Properties": { + "SecretId": { + "Ref": "InstanceSecret478E0A47" + }, + "TargetId": { + "Ref": "InstanceC1063A87" + }, + "TargetType": "AWS::RDS::DBInstance" + } + }, + "InstanceC1063A87": { + "Type": "AWS::RDS::DBInstance", + "Properties": { + "AllocatedStorage": "100", + "CopyTagsToSnapshot": true, + "DBInstanceClass": "db.t3.small", + "DBSubnetGroupName": { + "Ref": "InstanceSubnetGroupF2CBA54F" + }, + "Engine": "mysql", + "EngineVersion": "8.0.30", + "MasterUsername": { + "Fn::Join": [ + "", + [ + "{{resolve:secretsmanager:", + { + "Ref": "InstanceSecret478E0A47" + }, + ":SecretString:username::}}" + ] + ] + }, + "MasterUserPassword": { + "Fn::Join": [ + "", + [ + "{{resolve:secretsmanager:", + { + "Ref": "InstanceSecret478E0A47" + }, + ":SecretString:password::}}" + ] + ] + }, + "StorageType": "gp3", + "VPCSecurityGroups": [ + { + "Fn::GetAtt": [ + "InstanceSecurityGroupB4E5FA83", + "GroupId" + ] + } + ] + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + } + }, + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/cdk.out b/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/cdk.out new file mode 100644 index 0000000000000..8ecc185e9dbee --- /dev/null +++ b/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/cdk.out @@ -0,0 +1 @@ +{"version":"21.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/integ.json b/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/integ.json new file mode 100644 index 0000000000000..9422990458f2d --- /dev/null +++ b/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/integ.json @@ -0,0 +1,12 @@ +{ + "version": "21.0.0", + "testCases": { + "InstanceGp3Test/DefaultTest": { + "stacks": [ + "cdk-integ-rds-instance-gp3" + ], + "assertionStack": "InstanceGp3Test/DefaultTest/DeployAssert", + "assertionStackName": "InstanceGp3TestDefaultTestDeployAssert21C147A7" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/manifest.json b/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/manifest.json new file mode 100644 index 0000000000000..8fa819e815f14 --- /dev/null +++ b/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/manifest.json @@ -0,0 +1,261 @@ +{ + "version": "21.0.0", + "artifacts": { + "cdk-integ-rds-instance-gp3.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "cdk-integ-rds-instance-gp3.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "cdk-integ-rds-instance-gp3": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "cdk-integ-rds-instance-gp3.template.json", + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/1e4562be1c7ae8012b9410e312a395770f1a31653d4faa57ddec4ae724b1a087.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "cdk-integ-rds-instance-gp3.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "cdk-integ-rds-instance-gp3.assets" + ], + "metadata": { + "/cdk-integ-rds-instance-gp3/Vpc/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "Vpc8378EB38" + } + ], + "/cdk-integ-rds-instance-gp3/Vpc/PublicSubnet1/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet1Subnet5C2D37C4" + } + ], + "/cdk-integ-rds-instance-gp3/Vpc/PublicSubnet1/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet1RouteTable6C95E38E" + } + ], + "/cdk-integ-rds-instance-gp3/Vpc/PublicSubnet1/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet1RouteTableAssociation97140677" + } + ], + "/cdk-integ-rds-instance-gp3/Vpc/PublicSubnet1/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet1DefaultRoute3DA9E72A" + } + ], + "/cdk-integ-rds-instance-gp3/Vpc/PublicSubnet1/EIP": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet1EIPD7E02669" + } + ], + "/cdk-integ-rds-instance-gp3/Vpc/PublicSubnet1/NATGateway": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet1NATGateway4D7517AA" + } + ], + "/cdk-integ-rds-instance-gp3/Vpc/PublicSubnet2/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet2Subnet691E08A3" + } + ], + "/cdk-integ-rds-instance-gp3/Vpc/PublicSubnet2/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet2RouteTable94F7E489" + } + ], + "/cdk-integ-rds-instance-gp3/Vpc/PublicSubnet2/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet2RouteTableAssociationDD5762D8" + } + ], + "/cdk-integ-rds-instance-gp3/Vpc/PublicSubnet2/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet2DefaultRoute97F91067" + } + ], + "/cdk-integ-rds-instance-gp3/Vpc/PrivateSubnet1/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPrivateSubnet1Subnet536B997A" + } + ], + "/cdk-integ-rds-instance-gp3/Vpc/PrivateSubnet1/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPrivateSubnet1RouteTableB2C5B500" + } + ], + "/cdk-integ-rds-instance-gp3/Vpc/PrivateSubnet1/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPrivateSubnet1RouteTableAssociation70C59FA6" + } + ], + "/cdk-integ-rds-instance-gp3/Vpc/PrivateSubnet1/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPrivateSubnet1DefaultRouteBE02A9ED" + } + ], + "/cdk-integ-rds-instance-gp3/Vpc/PrivateSubnet2/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPrivateSubnet2Subnet3788AAA1" + } + ], + "/cdk-integ-rds-instance-gp3/Vpc/PrivateSubnet2/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPrivateSubnet2RouteTableA678073B" + } + ], + "/cdk-integ-rds-instance-gp3/Vpc/PrivateSubnet2/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPrivateSubnet2RouteTableAssociationA89CAD56" + } + ], + "/cdk-integ-rds-instance-gp3/Vpc/PrivateSubnet2/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPrivateSubnet2DefaultRoute060D2087" + } + ], + "/cdk-integ-rds-instance-gp3/Vpc/IGW": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcIGWD7BA715C" + } + ], + "/cdk-integ-rds-instance-gp3/Vpc/VPCGW": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcVPCGWBF912B6E" + } + ], + "/cdk-integ-rds-instance-gp3/Instance/SubnetGroup/Default": [ + { + "type": "aws:cdk:logicalId", + "data": "InstanceSubnetGroupF2CBA54F" + } + ], + "/cdk-integ-rds-instance-gp3/Instance/SecurityGroup/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "InstanceSecurityGroupB4E5FA83" + } + ], + "/cdk-integ-rds-instance-gp3/Instance/Secret/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "InstanceSecret478E0A47" + } + ], + "/cdk-integ-rds-instance-gp3/Instance/Secret/Attachment/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "InstanceSecretAttachment83BEE581" + } + ], + "/cdk-integ-rds-instance-gp3/Instance/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "InstanceC1063A87" + } + ], + "/cdk-integ-rds-instance-gp3/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/cdk-integ-rds-instance-gp3/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "cdk-integ-rds-instance-gp3" + }, + "InstanceGp3TestDefaultTestDeployAssert21C147A7.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "InstanceGp3TestDefaultTestDeployAssert21C147A7.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "InstanceGp3TestDefaultTestDeployAssert21C147A7": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "InstanceGp3TestDefaultTestDeployAssert21C147A7.template.json", + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "InstanceGp3TestDefaultTestDeployAssert21C147A7.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "InstanceGp3TestDefaultTestDeployAssert21C147A7.assets" + ], + "metadata": { + "/InstanceGp3Test/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/InstanceGp3Test/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "InstanceGp3Test/DefaultTest/DeployAssert" + }, + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + } + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/tree.json b/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/tree.json new file mode 100644 index 0000000000000..50c219448f2b0 --- /dev/null +++ b/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/tree.json @@ -0,0 +1,896 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "cdk-integ-rds-instance-gp3": { + "id": "cdk-integ-rds-instance-gp3", + "path": "cdk-integ-rds-instance-gp3", + "children": { + "Vpc": { + "id": "Vpc", + "path": "cdk-integ-rds-instance-gp3/Vpc", + "children": { + "Resource": { + "id": "Resource", + "path": "cdk-integ-rds-instance-gp3/Vpc/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::VPC", + "aws:cdk:cloudformation:props": { + "cidrBlock": "10.0.0.0/16", + "enableDnsHostnames": true, + "enableDnsSupport": true, + "instanceTenancy": "default", + "tags": [ + { + "key": "Name", + "value": "cdk-integ-rds-instance-gp3/Vpc" + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnVPC", + "version": "0.0.0" + } + }, + "PublicSubnet1": { + "id": "PublicSubnet1", + "path": "cdk-integ-rds-instance-gp3/Vpc/PublicSubnet1", + "children": { + "Subnet": { + "id": "Subnet", + "path": "cdk-integ-rds-instance-gp3/Vpc/PublicSubnet1/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "vpcId": { + "Ref": "Vpc8378EB38" + }, + "availabilityZone": { + "Fn::Select": [ + 0, + { + "Fn::GetAZs": "" + } + ] + }, + "cidrBlock": "10.0.0.0/18", + "mapPublicIpOnLaunch": true, + "tags": [ + { + "key": "aws-cdk:subnet-name", + "value": "Public" + }, + { + "key": "aws-cdk:subnet-type", + "value": "Public" + }, + { + "key": "Name", + "value": "cdk-integ-rds-instance-gp3/Vpc/PublicSubnet1" + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnSubnet", + "version": "0.0.0" + } + }, + "Acl": { + "id": "Acl", + "path": "cdk-integ-rds-instance-gp3/Vpc/PublicSubnet1/Acl", + "constructInfo": { + "fqn": "@aws-cdk/core.Resource", + "version": "0.0.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "cdk-integ-rds-instance-gp3/Vpc/PublicSubnet1/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "vpcId": { + "Ref": "Vpc8378EB38" + }, + "tags": [ + { + "key": "Name", + "value": "cdk-integ-rds-instance-gp3/Vpc/PublicSubnet1" + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnRouteTable", + "version": "0.0.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "cdk-integ-rds-instance-gp3/Vpc/PublicSubnet1/RouteTableAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SubnetRouteTableAssociation", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VpcPublicSubnet1RouteTable6C95E38E" + }, + "subnetId": { + "Ref": "VpcPublicSubnet1Subnet5C2D37C4" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnSubnetRouteTableAssociation", + "version": "0.0.0" + } + }, + "DefaultRoute": { + "id": "DefaultRoute", + "path": "cdk-integ-rds-instance-gp3/Vpc/PublicSubnet1/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VpcPublicSubnet1RouteTable6C95E38E" + }, + "destinationCidrBlock": "0.0.0.0/0", + "gatewayId": { + "Ref": "VpcIGWD7BA715C" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnRoute", + "version": "0.0.0" + } + }, + "EIP": { + "id": "EIP", + "path": "cdk-integ-rds-instance-gp3/Vpc/PublicSubnet1/EIP", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::EIP", + "aws:cdk:cloudformation:props": { + "domain": "vpc", + "tags": [ + { + "key": "Name", + "value": "cdk-integ-rds-instance-gp3/Vpc/PublicSubnet1" + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnEIP", + "version": "0.0.0" + } + }, + "NATGateway": { + "id": "NATGateway", + "path": "cdk-integ-rds-instance-gp3/Vpc/PublicSubnet1/NATGateway", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::NatGateway", + "aws:cdk:cloudformation:props": { + "subnetId": { + "Ref": "VpcPublicSubnet1Subnet5C2D37C4" + }, + "allocationId": { + "Fn::GetAtt": [ + "VpcPublicSubnet1EIPD7E02669", + "AllocationId" + ] + }, + "tags": [ + { + "key": "Name", + "value": "cdk-integ-rds-instance-gp3/Vpc/PublicSubnet1" + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnNatGateway", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.PublicSubnet", + "version": "0.0.0" + } + }, + "PublicSubnet2": { + "id": "PublicSubnet2", + "path": "cdk-integ-rds-instance-gp3/Vpc/PublicSubnet2", + "children": { + "Subnet": { + "id": "Subnet", + "path": "cdk-integ-rds-instance-gp3/Vpc/PublicSubnet2/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "vpcId": { + "Ref": "Vpc8378EB38" + }, + "availabilityZone": { + "Fn::Select": [ + 1, + { + "Fn::GetAZs": "" + } + ] + }, + "cidrBlock": "10.0.64.0/18", + "mapPublicIpOnLaunch": true, + "tags": [ + { + "key": "aws-cdk:subnet-name", + "value": "Public" + }, + { + "key": "aws-cdk:subnet-type", + "value": "Public" + }, + { + "key": "Name", + "value": "cdk-integ-rds-instance-gp3/Vpc/PublicSubnet2" + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnSubnet", + "version": "0.0.0" + } + }, + "Acl": { + "id": "Acl", + "path": "cdk-integ-rds-instance-gp3/Vpc/PublicSubnet2/Acl", + "constructInfo": { + "fqn": "@aws-cdk/core.Resource", + "version": "0.0.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "cdk-integ-rds-instance-gp3/Vpc/PublicSubnet2/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "vpcId": { + "Ref": "Vpc8378EB38" + }, + "tags": [ + { + "key": "Name", + "value": "cdk-integ-rds-instance-gp3/Vpc/PublicSubnet2" + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnRouteTable", + "version": "0.0.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "cdk-integ-rds-instance-gp3/Vpc/PublicSubnet2/RouteTableAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SubnetRouteTableAssociation", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VpcPublicSubnet2RouteTable94F7E489" + }, + "subnetId": { + "Ref": "VpcPublicSubnet2Subnet691E08A3" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnSubnetRouteTableAssociation", + "version": "0.0.0" + } + }, + "DefaultRoute": { + "id": "DefaultRoute", + "path": "cdk-integ-rds-instance-gp3/Vpc/PublicSubnet2/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VpcPublicSubnet2RouteTable94F7E489" + }, + "destinationCidrBlock": "0.0.0.0/0", + "gatewayId": { + "Ref": "VpcIGWD7BA715C" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnRoute", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.PublicSubnet", + "version": "0.0.0" + } + }, + "PrivateSubnet1": { + "id": "PrivateSubnet1", + "path": "cdk-integ-rds-instance-gp3/Vpc/PrivateSubnet1", + "children": { + "Subnet": { + "id": "Subnet", + "path": "cdk-integ-rds-instance-gp3/Vpc/PrivateSubnet1/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "vpcId": { + "Ref": "Vpc8378EB38" + }, + "availabilityZone": { + "Fn::Select": [ + 0, + { + "Fn::GetAZs": "" + } + ] + }, + "cidrBlock": "10.0.128.0/18", + "mapPublicIpOnLaunch": false, + "tags": [ + { + "key": "aws-cdk:subnet-name", + "value": "Private" + }, + { + "key": "aws-cdk:subnet-type", + "value": "Private" + }, + { + "key": "Name", + "value": "cdk-integ-rds-instance-gp3/Vpc/PrivateSubnet1" + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnSubnet", + "version": "0.0.0" + } + }, + "Acl": { + "id": "Acl", + "path": "cdk-integ-rds-instance-gp3/Vpc/PrivateSubnet1/Acl", + "constructInfo": { + "fqn": "@aws-cdk/core.Resource", + "version": "0.0.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "cdk-integ-rds-instance-gp3/Vpc/PrivateSubnet1/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "vpcId": { + "Ref": "Vpc8378EB38" + }, + "tags": [ + { + "key": "Name", + "value": "cdk-integ-rds-instance-gp3/Vpc/PrivateSubnet1" + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnRouteTable", + "version": "0.0.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "cdk-integ-rds-instance-gp3/Vpc/PrivateSubnet1/RouteTableAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SubnetRouteTableAssociation", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VpcPrivateSubnet1RouteTableB2C5B500" + }, + "subnetId": { + "Ref": "VpcPrivateSubnet1Subnet536B997A" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnSubnetRouteTableAssociation", + "version": "0.0.0" + } + }, + "DefaultRoute": { + "id": "DefaultRoute", + "path": "cdk-integ-rds-instance-gp3/Vpc/PrivateSubnet1/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VpcPrivateSubnet1RouteTableB2C5B500" + }, + "destinationCidrBlock": "0.0.0.0/0", + "natGatewayId": { + "Ref": "VpcPublicSubnet1NATGateway4D7517AA" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnRoute", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.PrivateSubnet", + "version": "0.0.0" + } + }, + "PrivateSubnet2": { + "id": "PrivateSubnet2", + "path": "cdk-integ-rds-instance-gp3/Vpc/PrivateSubnet2", + "children": { + "Subnet": { + "id": "Subnet", + "path": "cdk-integ-rds-instance-gp3/Vpc/PrivateSubnet2/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "vpcId": { + "Ref": "Vpc8378EB38" + }, + "availabilityZone": { + "Fn::Select": [ + 1, + { + "Fn::GetAZs": "" + } + ] + }, + "cidrBlock": "10.0.192.0/18", + "mapPublicIpOnLaunch": false, + "tags": [ + { + "key": "aws-cdk:subnet-name", + "value": "Private" + }, + { + "key": "aws-cdk:subnet-type", + "value": "Private" + }, + { + "key": "Name", + "value": "cdk-integ-rds-instance-gp3/Vpc/PrivateSubnet2" + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnSubnet", + "version": "0.0.0" + } + }, + "Acl": { + "id": "Acl", + "path": "cdk-integ-rds-instance-gp3/Vpc/PrivateSubnet2/Acl", + "constructInfo": { + "fqn": "@aws-cdk/core.Resource", + "version": "0.0.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "cdk-integ-rds-instance-gp3/Vpc/PrivateSubnet2/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "vpcId": { + "Ref": "Vpc8378EB38" + }, + "tags": [ + { + "key": "Name", + "value": "cdk-integ-rds-instance-gp3/Vpc/PrivateSubnet2" + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnRouteTable", + "version": "0.0.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "cdk-integ-rds-instance-gp3/Vpc/PrivateSubnet2/RouteTableAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SubnetRouteTableAssociation", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VpcPrivateSubnet2RouteTableA678073B" + }, + "subnetId": { + "Ref": "VpcPrivateSubnet2Subnet3788AAA1" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnSubnetRouteTableAssociation", + "version": "0.0.0" + } + }, + "DefaultRoute": { + "id": "DefaultRoute", + "path": "cdk-integ-rds-instance-gp3/Vpc/PrivateSubnet2/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VpcPrivateSubnet2RouteTableA678073B" + }, + "destinationCidrBlock": "0.0.0.0/0", + "natGatewayId": { + "Ref": "VpcPublicSubnet1NATGateway4D7517AA" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnRoute", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.PrivateSubnet", + "version": "0.0.0" + } + }, + "IGW": { + "id": "IGW", + "path": "cdk-integ-rds-instance-gp3/Vpc/IGW", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::InternetGateway", + "aws:cdk:cloudformation:props": { + "tags": [ + { + "key": "Name", + "value": "cdk-integ-rds-instance-gp3/Vpc" + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnInternetGateway", + "version": "0.0.0" + } + }, + "VPCGW": { + "id": "VPCGW", + "path": "cdk-integ-rds-instance-gp3/Vpc/VPCGW", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::VPCGatewayAttachment", + "aws:cdk:cloudformation:props": { + "vpcId": { + "Ref": "Vpc8378EB38" + }, + "internetGatewayId": { + "Ref": "VpcIGWD7BA715C" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnVPCGatewayAttachment", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.Vpc", + "version": "0.0.0" + } + }, + "Instance": { + "id": "Instance", + "path": "cdk-integ-rds-instance-gp3/Instance", + "children": { + "SubnetGroup": { + "id": "SubnetGroup", + "path": "cdk-integ-rds-instance-gp3/Instance/SubnetGroup", + "children": { + "Default": { + "id": "Default", + "path": "cdk-integ-rds-instance-gp3/Instance/SubnetGroup/Default", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::RDS::DBSubnetGroup", + "aws:cdk:cloudformation:props": { + "dbSubnetGroupDescription": "Subnet group for Instance database", + "subnetIds": [ + { + "Ref": "VpcPrivateSubnet1Subnet536B997A" + }, + { + "Ref": "VpcPrivateSubnet2Subnet3788AAA1" + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-rds.CfnDBSubnetGroup", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-rds.SubnetGroup", + "version": "0.0.0" + } + }, + "SecurityGroup": { + "id": "SecurityGroup", + "path": "cdk-integ-rds-instance-gp3/Instance/SecurityGroup", + "children": { + "Resource": { + "id": "Resource", + "path": "cdk-integ-rds-instance-gp3/Instance/SecurityGroup/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SecurityGroup", + "aws:cdk:cloudformation:props": { + "groupDescription": "Security group for Instance database", + "securityGroupEgress": [ + { + "cidrIp": "0.0.0.0/0", + "description": "Allow all outbound traffic by default", + "ipProtocol": "-1" + } + ], + "vpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnSecurityGroup", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.SecurityGroup", + "version": "0.0.0" + } + }, + "Secret": { + "id": "Secret", + "path": "cdk-integ-rds-instance-gp3/Instance/Secret", + "children": { + "Resource": { + "id": "Resource", + "path": "cdk-integ-rds-instance-gp3/Instance/Secret/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::SecretsManager::Secret", + "aws:cdk:cloudformation:props": { + "description": { + "Fn::Join": [ + "", + [ + "Generated by the CDK for stack: ", + { + "Ref": "AWS::StackName" + } + ] + ] + }, + "generateSecretString": { + "passwordLength": 30, + "secretStringTemplate": "{\"username\":\"admin\"}", + "generateStringKey": "password", + "excludeCharacters": " %+~`#$&*()|[]{}:;<>?!'/@\"\\" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-secretsmanager.CfnSecret", + "version": "0.0.0" + } + }, + "Attachment": { + "id": "Attachment", + "path": "cdk-integ-rds-instance-gp3/Instance/Secret/Attachment", + "children": { + "Resource": { + "id": "Resource", + "path": "cdk-integ-rds-instance-gp3/Instance/Secret/Attachment/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::SecretsManager::SecretTargetAttachment", + "aws:cdk:cloudformation:props": { + "secretId": { + "Ref": "InstanceSecret478E0A47" + }, + "targetId": { + "Ref": "InstanceC1063A87" + }, + "targetType": "AWS::RDS::DBInstance" + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-secretsmanager.CfnSecretTargetAttachment", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-secretsmanager.SecretTargetAttachment", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-rds.DatabaseSecret", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "cdk-integ-rds-instance-gp3/Instance/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::RDS::DBInstance", + "aws:cdk:cloudformation:props": { + "allocatedStorage": "100", + "copyTagsToSnapshot": true, + "dbInstanceClass": "db.t3.small", + "dbSubnetGroupName": { + "Ref": "InstanceSubnetGroupF2CBA54F" + }, + "engine": "mysql", + "engineVersion": "8.0.30", + "masterUsername": { + "Fn::Join": [ + "", + [ + "{{resolve:secretsmanager:", + { + "Ref": "InstanceSecret478E0A47" + }, + ":SecretString:username::}}" + ] + ] + }, + "masterUserPassword": { + "Fn::Join": [ + "", + [ + "{{resolve:secretsmanager:", + { + "Ref": "InstanceSecret478E0A47" + }, + ":SecretString:password::}}" + ] + ] + }, + "storageType": "gp3", + "vpcSecurityGroups": [ + { + "Fn::GetAtt": [ + "InstanceSecurityGroupB4E5FA83", + "GroupId" + ] + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-rds.CfnDBInstance", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-rds.DatabaseInstance", + "version": "0.0.0" + } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "cdk-integ-rds-instance-gp3/BootstrapVersion", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "cdk-integ-rds-instance-gp3/CheckBootstrapVersion", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/core.Stack", + "version": "0.0.0" + } + }, + "InstanceGp3Test": { + "id": "InstanceGp3Test", + "path": "InstanceGp3Test", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "InstanceGp3Test/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "InstanceGp3Test/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.1.154" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "InstanceGp3Test/DefaultTest/DeployAssert", + "children": { + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "InstanceGp3Test/DefaultTest/DeployAssert/BootstrapVersion", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "InstanceGp3Test/DefaultTest/DeployAssert/CheckBootstrapVersion", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/core.Stack", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests.IntegTestCase", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests.IntegTest", + "version": "0.0.0" + } + }, + "Tree": { + "id": "Tree", + "path": "Tree", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.1.154" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/core.App", + "version": "0.0.0" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.ts b/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.ts new file mode 100644 index 0000000000000..eae425dfdcd64 --- /dev/null +++ b/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.ts @@ -0,0 +1,29 @@ +import { InstanceClass, InstanceSize, InstanceType, Vpc } from '@aws-cdk/aws-ec2'; +import { App, RemovalPolicy, Stack } from '@aws-cdk/core'; +import * as integ from '@aws-cdk/integ-tests'; +import { Construct } from 'constructs'; +import { DatabaseInstance, DatabaseInstanceEngine, MysqlEngineVersion, StorageType } from '../lib'; + +class TestStack extends Stack { + constructor(scope: Construct, id: string) { + super(scope, id); + + const vpc = new Vpc(this, 'Vpc', { maxAzs: 2, natGateways: 1 }); + + new DatabaseInstance(this, 'Instance', { + engine: DatabaseInstanceEngine.mysql({ version: MysqlEngineVersion.VER_8_0_30 }), + instanceType: InstanceType.of(InstanceClass.BURSTABLE3, InstanceSize.SMALL), + vpc, + storageType: StorageType.GP3, + removalPolicy: RemovalPolicy.DESTROY, + }); + } +} + +const app = new App(); + +new integ.IntegTest(app, 'InstanceGp3Test', { + testCases: [new TestStack(app, 'cdk-integ-rds-instance-gp3')], +}); + +app.synth(); From e26b6bc16653d00a69406dd35678a4139c791e8c Mon Sep 17 00:00:00 2001 From: Jonathan Goldwasser Date: Mon, 14 Nov 2022 10:16:20 +0100 Subject: [PATCH 2/6] storage throughput --- packages/@aws-cdk/aws-rds/README.md | 6 ++++-- packages/@aws-cdk/aws-rds/lib/instance.ts | 15 +++++++++++++++ packages/@aws-cdk/aws-rds/test/instance.test.ts | 13 +++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/packages/@aws-cdk/aws-rds/README.md b/packages/@aws-cdk/aws-rds/README.md index df4bdf8e97768..10bcd713a5c7d 100644 --- a/packages/@aws-cdk/aws-rds/README.md +++ b/packages/@aws-cdk/aws-rds/README.md @@ -197,14 +197,16 @@ declare const vpc: ec2.Vpc; const iopsInstance = new rds.DatabaseInstance(this, 'IopsInstance', { engine: rds.DatabaseInstanceEngine.mysql({ version: MysqlEngineVersion.VER_8_0_30 }), vpc, - storateType: rds.StorageType.IO1, + storageType: rds.StorageType.IO1, iops: 5000, }); const gp3Instance = new rds.DatabaseInstance(this, 'Gp3Instance', { engine: rds.DatabaseInstanceEngine.mysql({ version: MysqlEngineVersion.VER_8_0_30 }), vpc, - storateType: rds.StorageType.GP3, + allocatedStorage: 500, + storageType: rds.StorageType.GP3, + storageThroughput: 500, // only applicable for GP3 }); ``` diff --git a/packages/@aws-cdk/aws-rds/lib/instance.ts b/packages/@aws-cdk/aws-rds/lib/instance.ts index 5e4d7e00ddc8f..112e028a4b1c5 100644 --- a/packages/@aws-cdk/aws-rds/lib/instance.ts +++ b/packages/@aws-cdk/aws-rds/lib/instance.ts @@ -338,6 +338,17 @@ export interface DatabaseInstanceNewProps { */ readonly storageType?: StorageType; + /** + * The storage throughput, specified in mibibytes per second (MiBps). + * + * Only applicable for GP3. + * + * @see https://docs.aws.amazon.com//AmazonRDS/latest/UserGuide/CHAP_Storage.html#gp3-storage + * + * @default 125 + */ + readonly storageThroughput?: number; + /** * The number of I/O operations per second (IOPS) that the database provisions. * The value must be equal to or greater than 1000. @@ -736,6 +747,9 @@ abstract class DatabaseInstanceNew extends DatabaseInstanceBase implements IData const storageType = props.storageType || StorageType.GP2; const iops = storageType === StorageType.IO1 ? (props.iops || 1000) : undefined; + if (props.storageThroughput && storageType !== StorageType.GP3) { + throw new Error(`The storage throughput can only be specified with GP3 storage type. Got ${storageType}.`); + } this.cloudwatchLogsExports = props.cloudwatchLogsExports; this.cloudwatchLogsRetention = props.cloudwatchLogsRetention; @@ -799,6 +813,7 @@ abstract class DatabaseInstanceNew extends DatabaseInstanceBase implements IData processorFeatures: props.processorFeatures && renderProcessorFeatures(props.processorFeatures), publiclyAccessible: props.publiclyAccessible ?? (this.vpcPlacement && this.vpcPlacement.subnetType === ec2.SubnetType.PUBLIC), storageType, + storageThroughput: props.storageThroughput, vpcSecurityGroups: securityGroups.map(s => s.securityGroupId), maxAllocatedStorage: props.maxAllocatedStorage, domain: this.domainId, diff --git a/packages/@aws-cdk/aws-rds/test/instance.test.ts b/packages/@aws-cdk/aws-rds/test/instance.test.ts index e8faa149af158..9ab575a5c5d27 100644 --- a/packages/@aws-cdk/aws-rds/test/instance.test.ts +++ b/packages/@aws-cdk/aws-rds/test/instance.test.ts @@ -1714,13 +1714,26 @@ describe('instance', () => { engine: rds.DatabaseInstanceEngine.mysql({ version: rds.MysqlEngineVersion.VER_8_0_30 }), instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE3, ec2.InstanceSize.SMALL), vpc, + allocatedStorage: 500, storageType: rds.StorageType.GP3, + storageThroughput: 500, }); Template.fromStack(stack).hasResourceProperties('AWS::RDS::DBInstance', { StorageType: 'gp3', + StorageThroughput: 500, }); }); + + test('throw with storage throughput and not GP3', () => { + expect(() => new rds.DatabaseInstance(stack, 'Instance', { + engine: rds.DatabaseInstanceEngine.mysql({ version: rds.MysqlEngineVersion.VER_8_0_30 }), + instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE3, ec2.InstanceSize.SMALL), + vpc, + storageType: rds.StorageType.GP2, + storageThroughput: 500, + })).toThrow(/storage throughput can only be specified with GP3 storage type/); + }); }); test.each([ From b499c29122467852b7035d0448eb49a71d6bd2fb Mon Sep 17 00:00:00 2001 From: Jonathan Goldwasser Date: Mon, 14 Nov 2022 10:26:05 +0100 Subject: [PATCH 3/6] typo --- packages/@aws-cdk/aws-rds/lib/instance.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@aws-cdk/aws-rds/lib/instance.ts b/packages/@aws-cdk/aws-rds/lib/instance.ts index 112e028a4b1c5..6f5951e59c4a7 100644 --- a/packages/@aws-cdk/aws-rds/lib/instance.ts +++ b/packages/@aws-cdk/aws-rds/lib/instance.ts @@ -339,7 +339,7 @@ export interface DatabaseInstanceNewProps { readonly storageType?: StorageType; /** - * The storage throughput, specified in mibibytes per second (MiBps). + * The storage throughput, specified in mebibytes per second (MiBps). * * Only applicable for GP3. * From d0af8c7a7c95a07b38db4400b64185e6c3610843 Mon Sep 17 00:00:00 2001 From: Jonathan Goldwasser Date: Mon, 14 Nov 2022 11:04:41 +0100 Subject: [PATCH 4/6] correct default doc for storage throughput --- packages/@aws-cdk/aws-rds/lib/instance.ts | 3 ++- .../cdk-integ-rds-instance-gp3.assets.json | 4 ++-- .../cdk-integ-rds-instance-gp3.template.json | 2 +- .../aws-rds/test/integ.instance-gp3.js.snapshot/manifest.json | 2 +- .../aws-rds/test/integ.instance-gp3.js.snapshot/tree.json | 2 +- packages/@aws-cdk/aws-rds/test/integ.instance-gp3.ts | 1 + 6 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/@aws-cdk/aws-rds/lib/instance.ts b/packages/@aws-cdk/aws-rds/lib/instance.ts index 6f5951e59c4a7..40216aaac2624 100644 --- a/packages/@aws-cdk/aws-rds/lib/instance.ts +++ b/packages/@aws-cdk/aws-rds/lib/instance.ts @@ -345,7 +345,8 @@ export interface DatabaseInstanceNewProps { * * @see https://docs.aws.amazon.com//AmazonRDS/latest/UserGuide/CHAP_Storage.html#gp3-storage * - * @default 125 + * @default - 125 MiBps if allocated storage is less than 400 GiB for MariaDB, MySQL, and PostgreSQL + * less than 200 GiB for Oracle and less than 20 GiB for SQL Server. 500 MiBps otherwise. */ readonly storageThroughput?: number; diff --git a/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/cdk-integ-rds-instance-gp3.assets.json b/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/cdk-integ-rds-instance-gp3.assets.json index 5c6f13abed340..bf908f21a6348 100644 --- a/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/cdk-integ-rds-instance-gp3.assets.json +++ b/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/cdk-integ-rds-instance-gp3.assets.json @@ -1,7 +1,7 @@ { "version": "21.0.0", "files": { - "1e4562be1c7ae8012b9410e312a395770f1a31653d4faa57ddec4ae724b1a087": { + "fcd2d721206458838590e53d084bf2c4ecb08d40f957ba8c2813e1832d5c8aa8": { "source": { "path": "cdk-integ-rds-instance-gp3.template.json", "packaging": "file" @@ -9,7 +9,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "1e4562be1c7ae8012b9410e312a395770f1a31653d4faa57ddec4ae724b1a087.json", + "objectKey": "fcd2d721206458838590e53d084bf2c4ecb08d40f957ba8c2813e1832d5c8aa8.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/cdk-integ-rds-instance-gp3.template.json b/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/cdk-integ-rds-instance-gp3.template.json index a86660ab2311d..82e98dff43850 100644 --- a/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/cdk-integ-rds-instance-gp3.template.json +++ b/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/cdk-integ-rds-instance-gp3.template.json @@ -424,7 +424,7 @@ "InstanceC1063A87": { "Type": "AWS::RDS::DBInstance", "Properties": { - "AllocatedStorage": "100", + "AllocatedStorage": "1000", "CopyTagsToSnapshot": true, "DBInstanceClass": "db.t3.small", "DBSubnetGroupName": { diff --git a/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/manifest.json b/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/manifest.json index 8fa819e815f14..8ab34ac699b66 100644 --- a/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/manifest.json +++ b/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/manifest.json @@ -17,7 +17,7 @@ "validateOnSynth": false, "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/1e4562be1c7ae8012b9410e312a395770f1a31653d4faa57ddec4ae724b1a087.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/fcd2d721206458838590e53d084bf2c4ecb08d40f957ba8c2813e1832d5c8aa8.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ diff --git a/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/tree.json b/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/tree.json index 50c219448f2b0..ab7362115420a 100644 --- a/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/tree.json +++ b/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.js.snapshot/tree.json @@ -749,7 +749,7 @@ "attributes": { "aws:cdk:cloudformation:type": "AWS::RDS::DBInstance", "aws:cdk:cloudformation:props": { - "allocatedStorage": "100", + "allocatedStorage": "1000", "copyTagsToSnapshot": true, "dbInstanceClass": "db.t3.small", "dbSubnetGroupName": { diff --git a/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.ts b/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.ts index eae425dfdcd64..d93bc8c9f8d52 100644 --- a/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.ts +++ b/packages/@aws-cdk/aws-rds/test/integ.instance-gp3.ts @@ -14,6 +14,7 @@ class TestStack extends Stack { engine: DatabaseInstanceEngine.mysql({ version: MysqlEngineVersion.VER_8_0_30 }), instanceType: InstanceType.of(InstanceClass.BURSTABLE3, InstanceSize.SMALL), vpc, + allocatedStorage: 1000, storageType: StorageType.GP3, removalPolicy: RemovalPolicy.DESTROY, }); From b2bb65a92e644bd4f714ffec1d40c9cad20743da Mon Sep 17 00:00:00 2001 From: Jonathan Goldwasser Date: Mon, 14 Nov 2022 11:22:27 +0100 Subject: [PATCH 5/6] jsdoc --- packages/@aws-cdk/aws-rds/lib/instance.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/@aws-cdk/aws-rds/lib/instance.ts b/packages/@aws-cdk/aws-rds/lib/instance.ts index 40216aaac2624..494d2b506218d 100644 --- a/packages/@aws-cdk/aws-rds/lib/instance.ts +++ b/packages/@aws-cdk/aws-rds/lib/instance.ts @@ -345,8 +345,9 @@ export interface DatabaseInstanceNewProps { * * @see https://docs.aws.amazon.com//AmazonRDS/latest/UserGuide/CHAP_Storage.html#gp3-storage * - * @default - 125 MiBps if allocated storage is less than 400 GiB for MariaDB, MySQL, and PostgreSQL - * less than 200 GiB for Oracle and less than 20 GiB for SQL Server. 500 MiBps otherwise. + * @default - 125 MiBps if allocated storage is less than 400 GiB for MariaDB, MySQL, and PostgreSQL, + * less than 200 GiB for Oracle and less than 20 GiB for SQL Server. 500 MiBps otherwise (except for + * SQL Server where the default is always 125 MiBps). */ readonly storageThroughput?: number; @@ -354,7 +355,10 @@ export interface DatabaseInstanceNewProps { * The number of I/O operations per second (IOPS) that the database provisions. * The value must be equal to or greater than 1000. * - * @default - no provisioned iops + * @default - no provisioned iops if storage type is not specified. For GP3: 3,000 IOPS if allocated + * storage is less than 400 GiB for MariaDB, MySQL, and PostgreSQL, less than 200 GiB for Oracle and + * less than 20 GiB for SQL Server. 12,000 IOPS otherwise (except for SQL Server where the default is + * always 3,000 IOPS). */ readonly iops?: number; From 964ef7bce3341236c23c1fb204a7cae049cf1046 Mon Sep 17 00:00:00 2001 From: Jonathan Goldwasser Date: Mon, 14 Nov 2022 12:11:43 +0100 Subject: [PATCH 6/6] correct iops and check ratio --- packages/@aws-cdk/aws-rds/lib/instance.ts | 21 +++++++++++++++++-- .../@aws-cdk/aws-rds/test/instance.test.ts | 16 +++++++++++++- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/packages/@aws-cdk/aws-rds/lib/instance.ts b/packages/@aws-cdk/aws-rds/lib/instance.ts index 494d2b506218d..05fb58d35f7c2 100644 --- a/packages/@aws-cdk/aws-rds/lib/instance.ts +++ b/packages/@aws-cdk/aws-rds/lib/instance.ts @@ -750,11 +750,16 @@ abstract class DatabaseInstanceNew extends DatabaseInstanceBase implements IData }); } - const storageType = props.storageType || StorageType.GP2; - const iops = storageType === StorageType.IO1 ? (props.iops || 1000) : undefined; + const storageType = props.storageType ?? StorageType.GP2; + const iops = defaultIops(storageType, props.iops); if (props.storageThroughput && storageType !== StorageType.GP3) { throw new Error(`The storage throughput can only be specified with GP3 storage type. Got ${storageType}.`); } + if (storageType === StorageType.GP3 && props.storageThroughput && iops + && !Token.isUnresolved(props.storageThroughput) && !Token.isUnresolved(iops) + && props.storageThroughput/iops > 0.25) { + throw new Error(`The maximum ratio of storage throughput to IOPS is 0.25. Got ${props.storageThroughput/iops}.`); + } this.cloudwatchLogsExports = props.cloudwatchLogsExports; this.cloudwatchLogsRetention = props.cloudwatchLogsRetention; @@ -1276,3 +1281,15 @@ function renderProcessorFeatures(features: ProcessorFeatures): CfnDBInstance.Pro return featuresList.length === 0 ? undefined : featuresList; } + +function defaultIops(storageType: StorageType, iops?: number): number | undefined { + switch (storageType) { + case StorageType.STANDARD: + case StorageType.GP2: + return undefined; + case StorageType.GP3: + return iops; + case StorageType.IO1: + return iops ?? 1000; + } +} diff --git a/packages/@aws-cdk/aws-rds/test/instance.test.ts b/packages/@aws-cdk/aws-rds/test/instance.test.ts index 9ab575a5c5d27..2f9108a2bc6f2 100644 --- a/packages/@aws-cdk/aws-rds/test/instance.test.ts +++ b/packages/@aws-cdk/aws-rds/test/instance.test.ts @@ -1717,15 +1717,17 @@ describe('instance', () => { allocatedStorage: 500, storageType: rds.StorageType.GP3, storageThroughput: 500, + iops: 4000, }); Template.fromStack(stack).hasResourceProperties('AWS::RDS::DBInstance', { StorageType: 'gp3', StorageThroughput: 500, + Iops: 4000, }); }); - test('throw with storage throughput and not GP3', () => { + test('throws with storage throughput and not GP3', () => { expect(() => new rds.DatabaseInstance(stack, 'Instance', { engine: rds.DatabaseInstanceEngine.mysql({ version: rds.MysqlEngineVersion.VER_8_0_30 }), instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE3, ec2.InstanceSize.SMALL), @@ -1734,6 +1736,18 @@ describe('instance', () => { storageThroughput: 500, })).toThrow(/storage throughput can only be specified with GP3 storage type/); }); + + test('throws with a ratio of storage throughput to IOPS greater than 0.25', () => { + expect(() => new rds.DatabaseInstance(stack, 'Instance', { + engine: rds.DatabaseInstanceEngine.mysql({ version: rds.MysqlEngineVersion.VER_8_0_30 }), + instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE3, ec2.InstanceSize.SMALL), + vpc, + allocatedStorage: 1000, + storageType: rds.StorageType.GP3, + iops: 5000, + storageThroughput: 2500, + })).toThrow(/maximum ratio of storage throughput to IOPS is 0.25/); + }); }); test.each([