Skip to content

Commit

Permalink
feat(redshift): support enhanced vpc routing when creating redshift c…
Browse files Browse the repository at this point in the history
…luster (#22499)

Allows users to enable enhanced VPC routing when creating a Redshift cluster.

----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [x] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
sean-beath committed Oct 18, 2022
1 parent 6f332ef commit e2b18e7
Show file tree
Hide file tree
Showing 11 changed files with 1,860 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/@aws-cdk/aws-redshift/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -368,3 +368,21 @@ The elastic IP address is an external IP address for accessing the cluster outsi

In some cases, you might want to associate the cluster with an elastic IP address or change an elastic IP address that is associated with the cluster. To attach an elastic IP address after the cluster is created, first update the cluster so that it is not publicly accessible, then make it both publicly accessible and add an Elastic IP address in the same operation.

## Enhanced VPC Routing

When you use Amazon Redshift enhanced VPC routing, Amazon Redshift forces all COPY and UNLOAD traffic between your cluster and your data repositories through your virtual private cloud (VPC) based on the Amazon VPC service. By using enhanced VPC routing, you can use standard VPC features, such as VPC security groups, network access control lists (ACLs), VPC endpoints, VPC endpoint policies, internet gateways, and Domain Name System (DNS) servers, as described in the Amazon VPC User Guide. You use these features to tightly manage the flow of data between your Amazon Redshift cluster and other resources. When you use enhanced VPC routing to route traffic through your VPC, you can also use VPC flow logs to monitor COPY and UNLOAD traffic.

```ts
declare const vpc: ec2.Vpc;

new Cluster(stack, 'Redshift', {
masterUser: {
masterUsername: 'admin',
masterPassword: cdk.SecretValue.unsafePlainText('tooshort'),
},
vpc,
enhancedVpcRouting: true,
})
```

If enhanced VPC routing is not enabled, Amazon Redshift routes traffic through the internet, including traffic to other services within the AWS network.
10 changes: 10 additions & 0 deletions packages/@aws-cdk/aws-redshift/lib/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,15 @@ export interface ClusterProps {
* @default - No Elastic IP
*/
readonly elasticIp?: string

/**
* If this flag is set, Amazon Redshift forces all COPY and UNLOAD traffic between your cluster and your data repositories through your virtual private cloud (VPC).
*
* @see https://docs.aws.amazon.com/redshift/latest/mgmt/enhanced-vpc-routing.html
*
* @default - false
*/
readonly enhancedVpcRouting?: boolean
}

/**
Expand Down Expand Up @@ -547,6 +556,7 @@ export class Cluster extends ClusterBase {
encrypted: props.encrypted ?? true,
classic: props.classicResizing,
elasticIp: props.elasticIp,
enhancedVpcRouting: props.enhancedVpcRouting,
});

this.cluster.applyRemovalPolicy(removalPolicy, {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"version": "21.0.0",
"files": {
"21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": {
"source": {
"path": "EnhancedVpcRoutingDefaultTestDeployAssert10B513A1.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": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"Parameters": {
"BootstrapVersion": {
"Type": "AWS::SSM::Parameter::Value<String>",
"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."
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":"21.0.0"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": "21.0.0",
"testCases": {
"EnhancedVpcRouting/DefaultTest": {
"stacks": [
"redshift-enhancedvpcrouting-integ"
],
"assertionStack": "EnhancedVpcRouting/DefaultTest/DeployAssert",
"assertionStackName": "EnhancedVpcRoutingDefaultTestDeployAssert10B513A1"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,273 @@
{
"version": "21.0.0",
"artifacts": {
"Tree": {
"type": "cdk:tree",
"properties": {
"file": "tree.json"
}
},
"redshift-enhancedvpcrouting-integ.assets": {
"type": "cdk:asset-manifest",
"properties": {
"file": "redshift-enhancedvpcrouting-integ.assets.json",
"requiresBootstrapStackVersion": 6,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
}
},
"redshift-enhancedvpcrouting-integ": {
"type": "aws:cloudformation:stack",
"environment": "aws://unknown-account/unknown-region",
"properties": {
"templateFile": "redshift-enhancedvpcrouting-integ.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}/88e2010a08d484eca3203f7e1bcffce43eaa10faedbd092b56c3d70967765b7a.json",
"requiresBootstrapStackVersion": 6,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
"additionalDependencies": [
"redshift-enhancedvpcrouting-integ.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": [
"redshift-enhancedvpcrouting-integ.assets"
],
"metadata": {
"/redshift-enhancedvpcrouting-integ/VPC/Resource": [
{
"type": "aws:cdk:logicalId",
"data": "VPCB9E5F0B4"
}
],
"/redshift-enhancedvpcrouting-integ/VPC/PublicSubnet1/Subnet": [
{
"type": "aws:cdk:logicalId",
"data": "VPCPublicSubnet1SubnetB4246D30"
}
],
"/redshift-enhancedvpcrouting-integ/VPC/PublicSubnet1/RouteTable": [
{
"type": "aws:cdk:logicalId",
"data": "VPCPublicSubnet1RouteTableFEE4B781"
}
],
"/redshift-enhancedvpcrouting-integ/VPC/PublicSubnet1/RouteTableAssociation": [
{
"type": "aws:cdk:logicalId",
"data": "VPCPublicSubnet1RouteTableAssociation0B0896DC"
}
],
"/redshift-enhancedvpcrouting-integ/VPC/PublicSubnet1/DefaultRoute": [
{
"type": "aws:cdk:logicalId",
"data": "VPCPublicSubnet1DefaultRoute91CEF279"
}
],
"/redshift-enhancedvpcrouting-integ/VPC/PublicSubnet1/EIP": [
{
"type": "aws:cdk:logicalId",
"data": "VPCPublicSubnet1EIP6AD938E8"
}
],
"/redshift-enhancedvpcrouting-integ/VPC/PublicSubnet1/NATGateway": [
{
"type": "aws:cdk:logicalId",
"data": "VPCPublicSubnet1NATGatewayE0556630"
}
],
"/redshift-enhancedvpcrouting-integ/VPC/PublicSubnet2/Subnet": [
{
"type": "aws:cdk:logicalId",
"data": "VPCPublicSubnet2Subnet74179F39"
}
],
"/redshift-enhancedvpcrouting-integ/VPC/PublicSubnet2/RouteTable": [
{
"type": "aws:cdk:logicalId",
"data": "VPCPublicSubnet2RouteTable6F1A15F1"
}
],
"/redshift-enhancedvpcrouting-integ/VPC/PublicSubnet2/RouteTableAssociation": [
{
"type": "aws:cdk:logicalId",
"data": "VPCPublicSubnet2RouteTableAssociation5A808732"
}
],
"/redshift-enhancedvpcrouting-integ/VPC/PublicSubnet2/DefaultRoute": [
{
"type": "aws:cdk:logicalId",
"data": "VPCPublicSubnet2DefaultRouteB7481BBA"
}
],
"/redshift-enhancedvpcrouting-integ/VPC/PublicSubnet2/EIP": [
{
"type": "aws:cdk:logicalId",
"data": "VPCPublicSubnet2EIP4947BC00"
}
],
"/redshift-enhancedvpcrouting-integ/VPC/PublicSubnet2/NATGateway": [
{
"type": "aws:cdk:logicalId",
"data": "VPCPublicSubnet2NATGateway3C070193"
}
],
"/redshift-enhancedvpcrouting-integ/VPC/PrivateSubnet1/Subnet": [
{
"type": "aws:cdk:logicalId",
"data": "VPCPrivateSubnet1Subnet8BCA10E0"
}
],
"/redshift-enhancedvpcrouting-integ/VPC/PrivateSubnet1/RouteTable": [
{
"type": "aws:cdk:logicalId",
"data": "VPCPrivateSubnet1RouteTableBE8A6027"
}
],
"/redshift-enhancedvpcrouting-integ/VPC/PrivateSubnet1/RouteTableAssociation": [
{
"type": "aws:cdk:logicalId",
"data": "VPCPrivateSubnet1RouteTableAssociation347902D1"
}
],
"/redshift-enhancedvpcrouting-integ/VPC/PrivateSubnet1/DefaultRoute": [
{
"type": "aws:cdk:logicalId",
"data": "VPCPrivateSubnet1DefaultRouteAE1D6490"
}
],
"/redshift-enhancedvpcrouting-integ/VPC/PrivateSubnet2/Subnet": [
{
"type": "aws:cdk:logicalId",
"data": "VPCPrivateSubnet2SubnetCFCDAA7A"
}
],
"/redshift-enhancedvpcrouting-integ/VPC/PrivateSubnet2/RouteTable": [
{
"type": "aws:cdk:logicalId",
"data": "VPCPrivateSubnet2RouteTable0A19E10E"
}
],
"/redshift-enhancedvpcrouting-integ/VPC/PrivateSubnet2/RouteTableAssociation": [
{
"type": "aws:cdk:logicalId",
"data": "VPCPrivateSubnet2RouteTableAssociation0C73D413"
}
],
"/redshift-enhancedvpcrouting-integ/VPC/PrivateSubnet2/DefaultRoute": [
{
"type": "aws:cdk:logicalId",
"data": "VPCPrivateSubnet2DefaultRouteF4F5CFD2"
}
],
"/redshift-enhancedvpcrouting-integ/VPC/IGW": [
{
"type": "aws:cdk:logicalId",
"data": "VPCIGWB7E252D3"
}
],
"/redshift-enhancedvpcrouting-integ/VPC/VPCGW": [
{
"type": "aws:cdk:logicalId",
"data": "VPCVPCGW99B986DC"
}
],
"/redshift-enhancedvpcrouting-integ/Cluster/Subnets/Default": [
{
"type": "aws:cdk:logicalId",
"data": "ClusterSubnetsDCFA5CB7"
}
],
"/redshift-enhancedvpcrouting-integ/Cluster/SecurityGroup/Resource": [
{
"type": "aws:cdk:logicalId",
"data": "ClusterSecurityGroup0921994B"
}
],
"/redshift-enhancedvpcrouting-integ/Cluster/Secret/Resource": [
{
"type": "aws:cdk:logicalId",
"data": "ClusterSecret6368BD0F"
}
],
"/redshift-enhancedvpcrouting-integ/Cluster/Secret/Attachment/Resource": [
{
"type": "aws:cdk:logicalId",
"data": "ClusterSecretAttachment769E6258"
}
],
"/redshift-enhancedvpcrouting-integ/Cluster/Resource": [
{
"type": "aws:cdk:logicalId",
"data": "ClusterEB0386A7"
}
],
"/redshift-enhancedvpcrouting-integ/BootstrapVersion": [
{
"type": "aws:cdk:logicalId",
"data": "BootstrapVersion"
}
],
"/redshift-enhancedvpcrouting-integ/CheckBootstrapVersion": [
{
"type": "aws:cdk:logicalId",
"data": "CheckBootstrapVersion"
}
]
},
"displayName": "redshift-enhancedvpcrouting-integ"
},
"EnhancedVpcRoutingDefaultTestDeployAssert10B513A1.assets": {
"type": "cdk:asset-manifest",
"properties": {
"file": "EnhancedVpcRoutingDefaultTestDeployAssert10B513A1.assets.json",
"requiresBootstrapStackVersion": 6,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
}
},
"EnhancedVpcRoutingDefaultTestDeployAssert10B513A1": {
"type": "aws:cloudformation:stack",
"environment": "aws://unknown-account/unknown-region",
"properties": {
"templateFile": "EnhancedVpcRoutingDefaultTestDeployAssert10B513A1.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": [
"EnhancedVpcRoutingDefaultTestDeployAssert10B513A1.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": [
"EnhancedVpcRoutingDefaultTestDeployAssert10B513A1.assets"
],
"metadata": {
"/EnhancedVpcRouting/DefaultTest/DeployAssert/BootstrapVersion": [
{
"type": "aws:cdk:logicalId",
"data": "BootstrapVersion"
}
],
"/EnhancedVpcRouting/DefaultTest/DeployAssert/CheckBootstrapVersion": [
{
"type": "aws:cdk:logicalId",
"data": "CheckBootstrapVersion"
}
]
},
"displayName": "EnhancedVpcRouting/DefaultTest/DeployAssert"
}
}
}
Loading

0 comments on commit e2b18e7

Please sign in to comment.