From 7986dcd4f5b16ab6783016f5e65adce3c50b12ea Mon Sep 17 00:00:00 2001 From: Kazuho CryerShinozuka Date: Sun, 3 Nov 2024 01:01:20 +0900 Subject: [PATCH 1/4] update integ test --- .../@aws-cdk/aws-redshift-alpha/README.md | 42 + .../aws-redshift-alpha/lib/cluster.ts | 30 + .../aws-redshift-alpha/test/cluster.test.ts | 17 +- ...efaultTestDeployAssert086BABC4.assets.json | 19 + ...aultTestDeployAssert086BABC4.template.json | 36 + .../ResourceActionStack.assets.json | 19 + .../ResourceActionStack.template.json | 479 +++++++++++ .../cdk.out | 1 + .../integ.json | 12 + .../manifest.json | 241 ++++++ .../tree.json | 800 ++++++++++++++++++ .../test/integ.cluster-resource-action.ts | 36 + 12 files changed, 1731 insertions(+), 1 deletion(-) create mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.cluster-resource-action.js.snapshot/ResourceActionIntegDefaultTestDeployAssert086BABC4.assets.json create mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.cluster-resource-action.js.snapshot/ResourceActionIntegDefaultTestDeployAssert086BABC4.template.json create mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.cluster-resource-action.js.snapshot/ResourceActionStack.assets.json create mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.cluster-resource-action.js.snapshot/ResourceActionStack.template.json create mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.cluster-resource-action.js.snapshot/cdk.out create mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.cluster-resource-action.js.snapshot/integ.json create mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.cluster-resource-action.js.snapshot/manifest.json create mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.cluster-resource-action.js.snapshot/tree.json create mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.cluster-resource-action.ts diff --git a/packages/@aws-cdk/aws-redshift-alpha/README.md b/packages/@aws-cdk/aws-redshift-alpha/README.md index 247061f2378a5..ce1673a2d8c9f 100644 --- a/packages/@aws-cdk/aws-redshift-alpha/README.md +++ b/packages/@aws-cdk/aws-redshift-alpha/README.md @@ -448,6 +448,48 @@ cluster.addToParameterGroup('enable_user_activity_logging', 'true'); cluster.enableRebootForParameterChanges() ``` +## Resource Action + +You can perform various actions on the Redshift resource by specifying the `resourceAction` property, +including [pausing and resuming the cluster](https://docs.aws.amazon.com/redshift/latest/mgmt/rs-mgmt-pause-resume-cluster.html), as well as initiating [failover for Multi-AZ clusters](https://docs.aws.amazon.com/redshift/latest/mgmt/test-cluster-multi-az.html). + +```ts +import * as ec2 from 'aws-cdk-lib/aws-ec2'; +import { ResourceAction } from '@aws-cdk/aws-redshift-alpha'; + +declare const vpc: ec2.IVpc; + +// Pause the cluster +new Cluster(this, 'PausedCluster', { + masterUser: { + masterUsername: 'admin', + }, + vpc, + resourceAction: ResourceAction.PAUSE, +}); + +// Resume the cluster +new Cluster(this, 'ResumedCluster', { + masterUser: { + masterUsername: 'admin', + }, + vpc, + resourceAction: ResourceAction.RESUME, +}); + +// Failover the cluster +new Cluster(this, 'FailOverCluster', { + masterUser: { + masterUsername: 'admin', + }, + // VPC must have 3 AZs for the cluster which executes failover action + vpc, + // Must be a multi-AZ cluster to failover + multiAz: true, + resourceAction: ResourceAction.FAILOVER_PRIMARY_COMPUTE, +}); +``` + ## Elastic IP If you configure your cluster to be publicly accessible, you can optionally select an *elastic IP address* to use for the external IP address. An elastic IP address is a static IP address that is associated with your AWS account. You can use an elastic IP address to connect to your cluster from outside the VPC. An elastic IP address gives you the ability to change your underlying configuration without affecting the IP address that clients use to connect to your cluster. This approach can be helpful for situations such as recovery after a failure. diff --git a/packages/@aws-cdk/aws-redshift-alpha/lib/cluster.ts b/packages/@aws-cdk/aws-redshift-alpha/lib/cluster.ts index a47841324456d..d5ac5e25ba8ef 100644 --- a/packages/@aws-cdk/aws-redshift-alpha/lib/cluster.ts +++ b/packages/@aws-cdk/aws-redshift-alpha/lib/cluster.ts @@ -80,6 +80,28 @@ export enum ClusterType { MULTI_NODE = 'multi-node', } +/** + * The Amazon Redshift operation to be performed + */ +export enum ResourceAction { + /** + * Pause the cluster + */ + PAUSE_CLUSTER = 'pause-cluster', + + /** + * Resume the cluster + */ + RESUME_CLUSTER = 'resume-cluster', + + /** + * Failing over to the other availability zone + * + * @see https://docs.aws.amazon.com/redshift/latest/mgmt/test-cluster-multi-az.html + */ + FAILOVER_PRIMARY_COMPUTE = 'failover-primary-compute', +} + /** * Username and password combination */ @@ -399,6 +421,13 @@ export interface ClusterProps { * @default - false */ readonly multiAz?: boolean; + + /** + * The Amazon Redshift operation to be performed. + * + * @default - no operation + */ + readonly resourceAction?: ResourceAction; } /** @@ -613,6 +642,7 @@ export class Cluster extends ClusterBase { elasticIp: props.elasticIp, enhancedVpcRouting: props.enhancedVpcRouting, multiAz: props.multiAz, + resourceAction: props.resourceAction, }); this.cluster.applyRemovalPolicy(removalPolicy, { diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/cluster.test.ts b/packages/@aws-cdk/aws-redshift-alpha/test/cluster.test.ts index 0d4ee8ba951a2..a9720b8d46f21 100644 --- a/packages/@aws-cdk/aws-redshift-alpha/test/cluster.test.ts +++ b/packages/@aws-cdk/aws-redshift-alpha/test/cluster.test.ts @@ -4,7 +4,7 @@ import * as iam from 'aws-cdk-lib/aws-iam'; import * as kms from 'aws-cdk-lib/aws-kms'; import * as s3 from 'aws-cdk-lib/aws-s3'; import * as cdk from 'aws-cdk-lib'; -import { Cluster, ClusterParameterGroup, ClusterSubnetGroup, ClusterType, NodeType } from '../lib'; +import { Cluster, ClusterParameterGroup, ClusterSubnetGroup, ClusterType, NodeType, ResourceAction } from '../lib'; import { CfnCluster } from 'aws-cdk-lib/aws-redshift'; let stack: cdk.Stack; @@ -479,6 +479,21 @@ test('can create a cluster with logging enabled', () => { }); }); +test.each([ + ResourceAction.PAUSE_CLUSTER, + ResourceAction.RESUME_CLUSTER, + ResourceAction.FAILOVER_PRIMARY_COMPUTE, +])('specify resource action %s', (resourceAction) => { + // WHEN + new Cluster(stack, 'Redshift', { + masterUser: { + masterUsername: 'admin', + }, + vpc, + resourceAction, + }); +}); + test('throws when trying to add rotation to a cluster without secret', () => { // WHEN const cluster = new Cluster(stack, 'Redshift', { diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.cluster-resource-action.js.snapshot/ResourceActionIntegDefaultTestDeployAssert086BABC4.assets.json b/packages/@aws-cdk/aws-redshift-alpha/test/integ.cluster-resource-action.js.snapshot/ResourceActionIntegDefaultTestDeployAssert086BABC4.assets.json new file mode 100644 index 0000000000000..bbe7ea616e780 --- /dev/null +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.cluster-resource-action.js.snapshot/ResourceActionIntegDefaultTestDeployAssert086BABC4.assets.json @@ -0,0 +1,19 @@ +{ + "version": "38.0.1", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "ResourceActionIntegDefaultTestDeployAssert086BABC4.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-redshift-alpha/test/integ.cluster-resource-action.js.snapshot/ResourceActionIntegDefaultTestDeployAssert086BABC4.template.json b/packages/@aws-cdk/aws-redshift-alpha/test/integ.cluster-resource-action.js.snapshot/ResourceActionIntegDefaultTestDeployAssert086BABC4.template.json new file mode 100644 index 0000000000000..ad9d0fb73d1dd --- /dev/null +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.cluster-resource-action.js.snapshot/ResourceActionIntegDefaultTestDeployAssert086BABC4.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-redshift-alpha/test/integ.cluster-resource-action.js.snapshot/ResourceActionStack.assets.json b/packages/@aws-cdk/aws-redshift-alpha/test/integ.cluster-resource-action.js.snapshot/ResourceActionStack.assets.json new file mode 100644 index 0000000000000..fc8eb7387e86f --- /dev/null +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.cluster-resource-action.js.snapshot/ResourceActionStack.assets.json @@ -0,0 +1,19 @@ +{ + "version": "38.0.1", + "files": { + "95f18dd9888a8c9146a3108900c4497f124924c75380bf34102334ec31777da1": { + "source": { + "path": "ResourceActionStack.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "95f18dd9888a8c9146a3108900c4497f124924c75380bf34102334ec31777da1.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-redshift-alpha/test/integ.cluster-resource-action.js.snapshot/ResourceActionStack.template.json b/packages/@aws-cdk/aws-redshift-alpha/test/integ.cluster-resource-action.js.snapshot/ResourceActionStack.template.json new file mode 100644 index 0000000000000..c1fe88791c3f4 --- /dev/null +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.cluster-resource-action.js.snapshot/ResourceActionStack.template.json @@ -0,0 +1,479 @@ +{ + "Resources": { + "Vpc8378EB38": { + "Type": "AWS::EC2::VPC", + "Properties": { + "CidrBlock": "10.0.0.0/16", + "EnableDnsHostnames": true, + "EnableDnsSupport": true, + "InstanceTenancy": "default", + "Tags": [ + { + "Key": "Name", + "Value": "ResourceActionStack/Vpc" + } + ] + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "VpcPublicSubnet1Subnet5C2D37C4": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "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": "ResourceActionStack/Vpc/PublicSubnet1" + } + ], + "VpcId": { + "Ref": "Vpc8378EB38" + } + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "VpcPublicSubnet1RouteTable6C95E38E": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": "ResourceActionStack/Vpc/PublicSubnet1" + } + ], + "VpcId": { + "Ref": "Vpc8378EB38" + } + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "VpcPublicSubnet1RouteTableAssociation97140677": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VpcPublicSubnet1RouteTable6C95E38E" + }, + "SubnetId": { + "Ref": "VpcPublicSubnet1Subnet5C2D37C4" + } + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "VpcPublicSubnet1DefaultRoute3DA9E72A": { + "Type": "AWS::EC2::Route", + "Properties": { + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": { + "Ref": "VpcIGWD7BA715C" + }, + "RouteTableId": { + "Ref": "VpcPublicSubnet1RouteTable6C95E38E" + } + }, + "DependsOn": [ + "VpcVPCGWBF912B6E" + ], + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "VpcPublicSubnet2Subnet691E08A3": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "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": "ResourceActionStack/Vpc/PublicSubnet2" + } + ], + "VpcId": { + "Ref": "Vpc8378EB38" + } + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "VpcPublicSubnet2RouteTable94F7E489": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": "ResourceActionStack/Vpc/PublicSubnet2" + } + ], + "VpcId": { + "Ref": "Vpc8378EB38" + } + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "VpcPublicSubnet2RouteTableAssociationDD5762D8": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VpcPublicSubnet2RouteTable94F7E489" + }, + "SubnetId": { + "Ref": "VpcPublicSubnet2Subnet691E08A3" + } + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "VpcPublicSubnet2DefaultRoute97F91067": { + "Type": "AWS::EC2::Route", + "Properties": { + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": { + "Ref": "VpcIGWD7BA715C" + }, + "RouteTableId": { + "Ref": "VpcPublicSubnet2RouteTable94F7E489" + } + }, + "DependsOn": [ + "VpcVPCGWBF912B6E" + ], + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "VpcIsolatedSubnet1SubnetE48C5737": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "AvailabilityZone": { + "Fn::Select": [ + 0, + { + "Fn::GetAZs": "" + } + ] + }, + "CidrBlock": "10.0.128.0/18", + "MapPublicIpOnLaunch": false, + "Tags": [ + { + "Key": "aws-cdk:subnet-name", + "Value": "Isolated" + }, + { + "Key": "aws-cdk:subnet-type", + "Value": "Isolated" + }, + { + "Key": "Name", + "Value": "ResourceActionStack/Vpc/IsolatedSubnet1" + } + ], + "VpcId": { + "Ref": "Vpc8378EB38" + } + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "VpcIsolatedSubnet1RouteTable4771E3E5": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": "ResourceActionStack/Vpc/IsolatedSubnet1" + } + ], + "VpcId": { + "Ref": "Vpc8378EB38" + } + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "VpcIsolatedSubnet1RouteTableAssociationD300FCBB": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VpcIsolatedSubnet1RouteTable4771E3E5" + }, + "SubnetId": { + "Ref": "VpcIsolatedSubnet1SubnetE48C5737" + } + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "VpcIsolatedSubnet2Subnet16364B91": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "AvailabilityZone": { + "Fn::Select": [ + 1, + { + "Fn::GetAZs": "" + } + ] + }, + "CidrBlock": "10.0.192.0/18", + "MapPublicIpOnLaunch": false, + "Tags": [ + { + "Key": "aws-cdk:subnet-name", + "Value": "Isolated" + }, + { + "Key": "aws-cdk:subnet-type", + "Value": "Isolated" + }, + { + "Key": "Name", + "Value": "ResourceActionStack/Vpc/IsolatedSubnet2" + } + ], + "VpcId": { + "Ref": "Vpc8378EB38" + } + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "VpcIsolatedSubnet2RouteTable1D30AF7D": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": "ResourceActionStack/Vpc/IsolatedSubnet2" + } + ], + "VpcId": { + "Ref": "Vpc8378EB38" + } + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "VpcIsolatedSubnet2RouteTableAssociationF7B18CCA": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VpcIsolatedSubnet2RouteTable1D30AF7D" + }, + "SubnetId": { + "Ref": "VpcIsolatedSubnet2Subnet16364B91" + } + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "VpcIGWD7BA715C": { + "Type": "AWS::EC2::InternetGateway", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": "ResourceActionStack/Vpc" + } + ] + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "VpcVPCGWBF912B6E": { + "Type": "AWS::EC2::VPCGatewayAttachment", + "Properties": { + "InternetGatewayId": { + "Ref": "VpcIGWD7BA715C" + }, + "VpcId": { + "Ref": "Vpc8378EB38" + } + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "ClusterSubnetsDCFA5CB7": { + "Type": "AWS::Redshift::ClusterSubnetGroup", + "Properties": { + "Description": "Subnets for Cluster Redshift cluster", + "SubnetIds": [ + { + "Ref": "VpcPublicSubnet1Subnet5C2D37C4" + }, + { + "Ref": "VpcPublicSubnet2Subnet691E08A3" + } + ] + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "ClusterSecurityGroup0921994B": { + "Type": "AWS::EC2::SecurityGroup", + "Properties": { + "GroupDescription": "Redshift security group", + "SecurityGroupEgress": [ + { + "CidrIp": "0.0.0.0/0", + "Description": "Allow all outbound traffic by default", + "IpProtocol": "-1" + } + ], + "VpcId": { + "Ref": "Vpc8378EB38" + } + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "ClusterSecret6368BD0F": { + "Type": "AWS::SecretsManager::Secret", + "Properties": { + "GenerateSecretString": { + "ExcludeCharacters": "\"@/\\ '", + "GenerateStringKey": "password", + "PasswordLength": 30, + "SecretStringTemplate": "{\"username\":\"admin\"}" + } + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "ClusterSecretAttachment769E6258": { + "Type": "AWS::SecretsManager::SecretTargetAttachment", + "Properties": { + "SecretId": { + "Ref": "ClusterSecret6368BD0F" + }, + "TargetId": { + "Ref": "ClusterEB0386A7" + }, + "TargetType": "AWS::Redshift::Cluster" + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "ClusterEB0386A7": { + "Type": "AWS::Redshift::Cluster", + "Properties": { + "AllowVersionUpgrade": true, + "AutomatedSnapshotRetentionPeriod": 1, + "ClusterSubnetGroupName": { + "Ref": "ClusterSubnetsDCFA5CB7" + }, + "ClusterType": "multi-node", + "DBName": "default_db", + "Encrypted": true, + "MasterUserPassword": { + "Fn::Join": [ + "", + [ + "{{resolve:secretsmanager:", + { + "Ref": "ClusterSecret6368BD0F" + }, + ":SecretString:password::}}" + ] + ] + }, + "MasterUsername": { + "Fn::Join": [ + "", + [ + "{{resolve:secretsmanager:", + { + "Ref": "ClusterSecret6368BD0F" + }, + ":SecretString:username::}}" + ] + ] + }, + "NodeType": "dc2.large", + "NumberOfNodes": 2, + "PubliclyAccessible": true, + "ResourceAction": "pause-cluster", + "VpcSecurityGroupIds": [ + { + "Fn::GetAtt": [ + "ClusterSecurityGroup0921994B", + "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-redshift-alpha/test/integ.cluster-resource-action.js.snapshot/cdk.out b/packages/@aws-cdk/aws-redshift-alpha/test/integ.cluster-resource-action.js.snapshot/cdk.out new file mode 100644 index 0000000000000..c6e612584e352 --- /dev/null +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.cluster-resource-action.js.snapshot/cdk.out @@ -0,0 +1 @@ +{"version":"38.0.1"} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.cluster-resource-action.js.snapshot/integ.json b/packages/@aws-cdk/aws-redshift-alpha/test/integ.cluster-resource-action.js.snapshot/integ.json new file mode 100644 index 0000000000000..f285cb2d81e8a --- /dev/null +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.cluster-resource-action.js.snapshot/integ.json @@ -0,0 +1,12 @@ +{ + "version": "38.0.1", + "testCases": { + "ResourceActionInteg/DefaultTest": { + "stacks": [ + "ResourceActionStack" + ], + "assertionStack": "ResourceActionInteg/DefaultTest/DeployAssert", + "assertionStackName": "ResourceActionIntegDefaultTestDeployAssert086BABC4" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.cluster-resource-action.js.snapshot/manifest.json b/packages/@aws-cdk/aws-redshift-alpha/test/integ.cluster-resource-action.js.snapshot/manifest.json new file mode 100644 index 0000000000000..0ea87a2614438 --- /dev/null +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.cluster-resource-action.js.snapshot/manifest.json @@ -0,0 +1,241 @@ +{ + "version": "38.0.1", + "artifacts": { + "ResourceActionStack.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "ResourceActionStack.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "ResourceActionStack": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "ResourceActionStack.template.json", + "terminationProtection": false, + "validateOnSynth": false, + "notificationArns": [], + "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}/95f18dd9888a8c9146a3108900c4497f124924c75380bf34102334ec31777da1.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "ResourceActionStack.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": [ + "ResourceActionStack.assets" + ], + "metadata": { + "/ResourceActionStack/Vpc/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "Vpc8378EB38" + } + ], + "/ResourceActionStack/Vpc/PublicSubnet1/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet1Subnet5C2D37C4" + } + ], + "/ResourceActionStack/Vpc/PublicSubnet1/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet1RouteTable6C95E38E" + } + ], + "/ResourceActionStack/Vpc/PublicSubnet1/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet1RouteTableAssociation97140677" + } + ], + "/ResourceActionStack/Vpc/PublicSubnet1/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet1DefaultRoute3DA9E72A" + } + ], + "/ResourceActionStack/Vpc/PublicSubnet2/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet2Subnet691E08A3" + } + ], + "/ResourceActionStack/Vpc/PublicSubnet2/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet2RouteTable94F7E489" + } + ], + "/ResourceActionStack/Vpc/PublicSubnet2/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet2RouteTableAssociationDD5762D8" + } + ], + "/ResourceActionStack/Vpc/PublicSubnet2/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcPublicSubnet2DefaultRoute97F91067" + } + ], + "/ResourceActionStack/Vpc/IsolatedSubnet1/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcIsolatedSubnet1SubnetE48C5737" + } + ], + "/ResourceActionStack/Vpc/IsolatedSubnet1/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcIsolatedSubnet1RouteTable4771E3E5" + } + ], + "/ResourceActionStack/Vpc/IsolatedSubnet1/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcIsolatedSubnet1RouteTableAssociationD300FCBB" + } + ], + "/ResourceActionStack/Vpc/IsolatedSubnet2/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcIsolatedSubnet2Subnet16364B91" + } + ], + "/ResourceActionStack/Vpc/IsolatedSubnet2/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcIsolatedSubnet2RouteTable1D30AF7D" + } + ], + "/ResourceActionStack/Vpc/IsolatedSubnet2/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcIsolatedSubnet2RouteTableAssociationF7B18CCA" + } + ], + "/ResourceActionStack/Vpc/IGW": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcIGWD7BA715C" + } + ], + "/ResourceActionStack/Vpc/VPCGW": [ + { + "type": "aws:cdk:logicalId", + "data": "VpcVPCGWBF912B6E" + } + ], + "/ResourceActionStack/Cluster/Subnets/Default": [ + { + "type": "aws:cdk:logicalId", + "data": "ClusterSubnetsDCFA5CB7" + } + ], + "/ResourceActionStack/Cluster/SecurityGroup/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "ClusterSecurityGroup0921994B" + } + ], + "/ResourceActionStack/Cluster/Secret/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "ClusterSecret6368BD0F" + } + ], + "/ResourceActionStack/Cluster/Secret/Attachment/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "ClusterSecretAttachment769E6258" + } + ], + "/ResourceActionStack/Cluster/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "ClusterEB0386A7" + } + ], + "/ResourceActionStack/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/ResourceActionStack/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "ResourceActionStack" + }, + "ResourceActionIntegDefaultTestDeployAssert086BABC4.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "ResourceActionIntegDefaultTestDeployAssert086BABC4.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "ResourceActionIntegDefaultTestDeployAssert086BABC4": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "ResourceActionIntegDefaultTestDeployAssert086BABC4.template.json", + "terminationProtection": false, + "validateOnSynth": false, + "notificationArns": [], + "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": [ + "ResourceActionIntegDefaultTestDeployAssert086BABC4.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": [ + "ResourceActionIntegDefaultTestDeployAssert086BABC4.assets" + ], + "metadata": { + "/ResourceActionInteg/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/ResourceActionInteg/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "ResourceActionInteg/DefaultTest/DeployAssert" + }, + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + } + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.cluster-resource-action.js.snapshot/tree.json b/packages/@aws-cdk/aws-redshift-alpha/test/integ.cluster-resource-action.js.snapshot/tree.json new file mode 100644 index 0000000000000..80a30001d6965 --- /dev/null +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.cluster-resource-action.js.snapshot/tree.json @@ -0,0 +1,800 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "ResourceActionStack": { + "id": "ResourceActionStack", + "path": "ResourceActionStack", + "children": { + "Vpc": { + "id": "Vpc", + "path": "ResourceActionStack/Vpc", + "children": { + "Resource": { + "id": "Resource", + "path": "ResourceActionStack/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": "ResourceActionStack/Vpc" + } + ] + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "PublicSubnet1": { + "id": "PublicSubnet1", + "path": "ResourceActionStack/Vpc/PublicSubnet1", + "children": { + "Subnet": { + "id": "Subnet", + "path": "ResourceActionStack/Vpc/PublicSubnet1/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "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": "ResourceActionStack/Vpc/PublicSubnet1" + } + ], + "vpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "Acl": { + "id": "Acl", + "path": "ResourceActionStack/Vpc/PublicSubnet1/Acl", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "ResourceActionStack/Vpc/PublicSubnet1/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "tags": [ + { + "key": "Name", + "value": "ResourceActionStack/Vpc/PublicSubnet1" + } + ], + "vpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "ResourceActionStack/Vpc/PublicSubnet1/RouteTableAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SubnetRouteTableAssociation", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VpcPublicSubnet1RouteTable6C95E38E" + }, + "subnetId": { + "Ref": "VpcPublicSubnet1Subnet5C2D37C4" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "DefaultRoute": { + "id": "DefaultRoute", + "path": "ResourceActionStack/Vpc/PublicSubnet1/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "destinationCidrBlock": "0.0.0.0/0", + "gatewayId": { + "Ref": "VpcIGWD7BA715C" + }, + "routeTableId": { + "Ref": "VpcPublicSubnet1RouteTable6C95E38E" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "PublicSubnet2": { + "id": "PublicSubnet2", + "path": "ResourceActionStack/Vpc/PublicSubnet2", + "children": { + "Subnet": { + "id": "Subnet", + "path": "ResourceActionStack/Vpc/PublicSubnet2/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "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": "ResourceActionStack/Vpc/PublicSubnet2" + } + ], + "vpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "Acl": { + "id": "Acl", + "path": "ResourceActionStack/Vpc/PublicSubnet2/Acl", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "ResourceActionStack/Vpc/PublicSubnet2/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "tags": [ + { + "key": "Name", + "value": "ResourceActionStack/Vpc/PublicSubnet2" + } + ], + "vpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "ResourceActionStack/Vpc/PublicSubnet2/RouteTableAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SubnetRouteTableAssociation", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VpcPublicSubnet2RouteTable94F7E489" + }, + "subnetId": { + "Ref": "VpcPublicSubnet2Subnet691E08A3" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "DefaultRoute": { + "id": "DefaultRoute", + "path": "ResourceActionStack/Vpc/PublicSubnet2/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "destinationCidrBlock": "0.0.0.0/0", + "gatewayId": { + "Ref": "VpcIGWD7BA715C" + }, + "routeTableId": { + "Ref": "VpcPublicSubnet2RouteTable94F7E489" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "IsolatedSubnet1": { + "id": "IsolatedSubnet1", + "path": "ResourceActionStack/Vpc/IsolatedSubnet1", + "children": { + "Subnet": { + "id": "Subnet", + "path": "ResourceActionStack/Vpc/IsolatedSubnet1/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "availabilityZone": { + "Fn::Select": [ + 0, + { + "Fn::GetAZs": "" + } + ] + }, + "cidrBlock": "10.0.128.0/18", + "mapPublicIpOnLaunch": false, + "tags": [ + { + "key": "aws-cdk:subnet-name", + "value": "Isolated" + }, + { + "key": "aws-cdk:subnet-type", + "value": "Isolated" + }, + { + "key": "Name", + "value": "ResourceActionStack/Vpc/IsolatedSubnet1" + } + ], + "vpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "Acl": { + "id": "Acl", + "path": "ResourceActionStack/Vpc/IsolatedSubnet1/Acl", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "ResourceActionStack/Vpc/IsolatedSubnet1/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "tags": [ + { + "key": "Name", + "value": "ResourceActionStack/Vpc/IsolatedSubnet1" + } + ], + "vpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "ResourceActionStack/Vpc/IsolatedSubnet1/RouteTableAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SubnetRouteTableAssociation", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VpcIsolatedSubnet1RouteTable4771E3E5" + }, + "subnetId": { + "Ref": "VpcIsolatedSubnet1SubnetE48C5737" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "IsolatedSubnet2": { + "id": "IsolatedSubnet2", + "path": "ResourceActionStack/Vpc/IsolatedSubnet2", + "children": { + "Subnet": { + "id": "Subnet", + "path": "ResourceActionStack/Vpc/IsolatedSubnet2/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "availabilityZone": { + "Fn::Select": [ + 1, + { + "Fn::GetAZs": "" + } + ] + }, + "cidrBlock": "10.0.192.0/18", + "mapPublicIpOnLaunch": false, + "tags": [ + { + "key": "aws-cdk:subnet-name", + "value": "Isolated" + }, + { + "key": "aws-cdk:subnet-type", + "value": "Isolated" + }, + { + "key": "Name", + "value": "ResourceActionStack/Vpc/IsolatedSubnet2" + } + ], + "vpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "Acl": { + "id": "Acl", + "path": "ResourceActionStack/Vpc/IsolatedSubnet2/Acl", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "ResourceActionStack/Vpc/IsolatedSubnet2/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "tags": [ + { + "key": "Name", + "value": "ResourceActionStack/Vpc/IsolatedSubnet2" + } + ], + "vpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "ResourceActionStack/Vpc/IsolatedSubnet2/RouteTableAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SubnetRouteTableAssociation", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VpcIsolatedSubnet2RouteTable1D30AF7D" + }, + "subnetId": { + "Ref": "VpcIsolatedSubnet2Subnet16364B91" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "IGW": { + "id": "IGW", + "path": "ResourceActionStack/Vpc/IGW", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::InternetGateway", + "aws:cdk:cloudformation:props": { + "tags": [ + { + "key": "Name", + "value": "ResourceActionStack/Vpc" + } + ] + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "VPCGW": { + "id": "VPCGW", + "path": "ResourceActionStack/Vpc/VPCGW", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::VPCGatewayAttachment", + "aws:cdk:cloudformation:props": { + "internetGatewayId": { + "Ref": "VpcIGWD7BA715C" + }, + "vpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "Cluster": { + "id": "Cluster", + "path": "ResourceActionStack/Cluster", + "children": { + "Subnets": { + "id": "Subnets", + "path": "ResourceActionStack/Cluster/Subnets", + "children": { + "Default": { + "id": "Default", + "path": "ResourceActionStack/Cluster/Subnets/Default", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Redshift::ClusterSubnetGroup", + "aws:cdk:cloudformation:props": { + "description": "Subnets for Cluster Redshift cluster", + "subnetIds": [ + { + "Ref": "VpcPublicSubnet1Subnet5C2D37C4" + }, + { + "Ref": "VpcPublicSubnet2Subnet691E08A3" + } + ] + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-redshift-alpha.ClusterSubnetGroup", + "version": "0.0.0" + } + }, + "SecurityGroup": { + "id": "SecurityGroup", + "path": "ResourceActionStack/Cluster/SecurityGroup", + "children": { + "Resource": { + "id": "Resource", + "path": "ResourceActionStack/Cluster/SecurityGroup/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SecurityGroup", + "aws:cdk:cloudformation:props": { + "groupDescription": "Redshift security group", + "securityGroupEgress": [ + { + "cidrIp": "0.0.0.0/0", + "description": "Allow all outbound traffic by default", + "ipProtocol": "-1" + } + ], + "vpcId": { + "Ref": "Vpc8378EB38" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "Secret": { + "id": "Secret", + "path": "ResourceActionStack/Cluster/Secret", + "children": { + "Resource": { + "id": "Resource", + "path": "ResourceActionStack/Cluster/Secret/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::SecretsManager::Secret", + "aws:cdk:cloudformation:props": { + "generateSecretString": { + "passwordLength": 30, + "secretStringTemplate": "{\"username\":\"admin\"}", + "generateStringKey": "password", + "excludeCharacters": "\"@/\\ '" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "Attachment": { + "id": "Attachment", + "path": "ResourceActionStack/Cluster/Secret/Attachment", + "children": { + "Resource": { + "id": "Resource", + "path": "ResourceActionStack/Cluster/Secret/Attachment/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::SecretsManager::SecretTargetAttachment", + "aws:cdk:cloudformation:props": { + "secretId": { + "Ref": "ClusterSecret6368BD0F" + }, + "targetId": { + "Ref": "ClusterEB0386A7" + }, + "targetType": "AWS::Redshift::Cluster" + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-redshift-alpha.DatabaseSecret", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "ResourceActionStack/Cluster/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Redshift::Cluster", + "aws:cdk:cloudformation:props": { + "allowVersionUpgrade": true, + "automatedSnapshotRetentionPeriod": 1, + "clusterSubnetGroupName": { + "Ref": "ClusterSubnetsDCFA5CB7" + }, + "clusterType": "multi-node", + "dbName": "default_db", + "encrypted": true, + "masterUsername": { + "Fn::Join": [ + "", + [ + "{{resolve:secretsmanager:", + { + "Ref": "ClusterSecret6368BD0F" + }, + ":SecretString:username::}}" + ] + ] + }, + "masterUserPassword": { + "Fn::Join": [ + "", + [ + "{{resolve:secretsmanager:", + { + "Ref": "ClusterSecret6368BD0F" + }, + ":SecretString:password::}}" + ] + ] + }, + "nodeType": "dc2.large", + "numberOfNodes": 2, + "publiclyAccessible": true, + "resourceAction": "pause-cluster", + "vpcSecurityGroupIds": [ + { + "Fn::GetAtt": [ + "ClusterSecurityGroup0921994B", + "GroupId" + ] + } + ] + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-redshift-alpha.Cluster", + "version": "0.0.0" + } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "ResourceActionStack/BootstrapVersion", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "ResourceActionStack/CheckBootstrapVersion", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "ResourceActionInteg": { + "id": "ResourceActionInteg", + "path": "ResourceActionInteg", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "ResourceActionInteg/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "ResourceActionInteg/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "ResourceActionInteg/DefaultTest/DeployAssert", + "children": { + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "ResourceActionInteg/DefaultTest/DeployAssert/BootstrapVersion", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "ResourceActionInteg/DefaultTest/DeployAssert/CheckBootstrapVersion", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTestCase", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTest", + "version": "0.0.0" + } + }, + "Tree": { + "id": "Tree", + "path": "Tree", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.cluster-resource-action.ts b/packages/@aws-cdk/aws-redshift-alpha/test/integ.cluster-resource-action.ts new file mode 100644 index 0000000000000..2d2b9f6307f09 --- /dev/null +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.cluster-resource-action.ts @@ -0,0 +1,36 @@ +import * as ec2 from 'aws-cdk-lib/aws-ec2'; +import * as cdk from 'aws-cdk-lib'; +import * as integ from '@aws-cdk/integ-tests-alpha'; +import * as constructs from 'constructs'; +import * as redshift from '../lib'; + +const app = new cdk.App(); +const stack = new cdk.Stack(app, 'ResourceActionStack'); + +cdk.Aspects.of(stack).add({ + visit(node: constructs.IConstruct) { + if (cdk.CfnResource.isCfnResource(node)) { + node.applyRemovalPolicy(cdk.RemovalPolicy.DESTROY); + } + }, +}); + +const vpc = new ec2.Vpc(stack, 'Vpc', { + restrictDefaultSecurityGroup: false, + natGateways: 0, +}); +new redshift.Cluster(stack, 'Cluster', { + vpc: vpc, + vpcSubnets: { + subnetType: ec2.SubnetType.PUBLIC, + }, + masterUser: { + masterUsername: 'admin', + }, + publiclyAccessible: true, + resourceAction: redshift.ResourceAction.PAUSE_CLUSTER, +}); + +new integ.IntegTest(app, 'ResourceActionInteg', { + testCases: [stack], +}); From 6896b65b31912904779e9ff541abdaebdfc24981 Mon Sep 17 00:00:00 2001 From: Kazuho CryerShinozuka Date: Sun, 3 Nov 2024 08:58:33 +0900 Subject: [PATCH 2/4] add validation --- .../@aws-cdk/aws-redshift-alpha/lib/cluster.ts | 6 +++++- .../aws-redshift-alpha/test/cluster.test.ts | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/packages/@aws-cdk/aws-redshift-alpha/lib/cluster.ts b/packages/@aws-cdk/aws-redshift-alpha/lib/cluster.ts index d5ac5e25ba8ef..1bfbf0cbeb260 100644 --- a/packages/@aws-cdk/aws-redshift-alpha/lib/cluster.ts +++ b/packages/@aws-cdk/aws-redshift-alpha/lib/cluster.ts @@ -81,7 +81,7 @@ export enum ClusterType { } /** - * The Amazon Redshift operation to be performed + * The Amazon Redshift operation */ export enum ResourceAction { /** @@ -613,6 +613,10 @@ export class Cluster extends ClusterBase { } } + if (props.resourceAction === ResourceAction.FAILOVER_PRIMARY_COMPUTE && !props.multiAz) { + throw new Error('ResourceAction.FAILOVER_PRIMARY_COMPUTE can only be used with multi-AZ clusters.'); + } + this.cluster = new CfnCluster(this, 'Resource', { // Basic allowVersionUpgrade: true, diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/cluster.test.ts b/packages/@aws-cdk/aws-redshift-alpha/test/cluster.test.ts index a9720b8d46f21..82c595ecd3b7b 100644 --- a/packages/@aws-cdk/aws-redshift-alpha/test/cluster.test.ts +++ b/packages/@aws-cdk/aws-redshift-alpha/test/cluster.test.ts @@ -491,9 +491,23 @@ test.each([ }, vpc, resourceAction, + multiAz: true, }); }); +test.each([false, undefined])('throw error for failover primary compute action with single AZ cluster', (multiAz) => { + expect(() => { + new Cluster(stack, 'Redshift', { + masterUser: { + masterUsername: 'admin', + }, + vpc, + multiAz, + resourceAction: ResourceAction.FAILOVER_PRIMARY_COMPUTE, + }); + }).toThrow('ResourceAction.FAILOVER_PRIMARY_COMPUTE can only be used with multi-AZ clusters.') +}); + test('throws when trying to add rotation to a cluster without secret', () => { // WHEN const cluster = new Cluster(stack, 'Redshift', { From 7f8fbcb366cc747b982bf7bb722a32b5ffb1656d Mon Sep 17 00:00:00 2001 From: Kazuho CryerShinozuka Date: Sun, 3 Nov 2024 09:23:18 +0900 Subject: [PATCH 3/4] fix format --- packages/@aws-cdk/aws-redshift-alpha/test/cluster.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/cluster.test.ts b/packages/@aws-cdk/aws-redshift-alpha/test/cluster.test.ts index 82c595ecd3b7b..da34324054419 100644 --- a/packages/@aws-cdk/aws-redshift-alpha/test/cluster.test.ts +++ b/packages/@aws-cdk/aws-redshift-alpha/test/cluster.test.ts @@ -505,7 +505,7 @@ test.each([false, undefined])('throw error for failover primary compute action w multiAz, resourceAction: ResourceAction.FAILOVER_PRIMARY_COMPUTE, }); - }).toThrow('ResourceAction.FAILOVER_PRIMARY_COMPUTE can only be used with multi-AZ clusters.') + }).toThrow('ResourceAction.FAILOVER_PRIMARY_COMPUTE can only be used with multi-AZ clusters.'); }); test('throws when trying to add rotation to a cluster without secret', () => { From d2840aa2fe4b58863aece90f0992feccf2a90658 Mon Sep 17 00:00:00 2001 From: Kazuho CryerShinozuka Date: Mon, 4 Nov 2024 21:10:28 +0900 Subject: [PATCH 4/4] fix unit test --- packages/@aws-cdk/aws-redshift-alpha/test/cluster.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/cluster.test.ts b/packages/@aws-cdk/aws-redshift-alpha/test/cluster.test.ts index da34324054419..c48278d4444fe 100644 --- a/packages/@aws-cdk/aws-redshift-alpha/test/cluster.test.ts +++ b/packages/@aws-cdk/aws-redshift-alpha/test/cluster.test.ts @@ -491,6 +491,7 @@ test.each([ }, vpc, resourceAction, + nodeType: NodeType.RA3_XLPLUS, multiAz: true, }); });