Skip to content

Commit

Permalink
feat(redshift): add publiclyAccessible prop (#11162)
Browse files Browse the repository at this point in the history
fixes #11161


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
alex9311 authored Oct 29, 2020
1 parent d85e3ed commit 9f8a6de
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/@aws-cdk/aws-redshift/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ By default, the master password will be generated and stored in AWS Secrets Mana

A default database named `default_db` will be created in the cluster. To change the name of this database set the `defaultDatabaseName` attribute in the constructor properties.

By default, the cluster will not be publicly accessible.
Depending on your use case, you can make the cluster publicly accessible with the `publiclyAccessible` property.

### Connecting

To control who can access the cluster, use the `.connections` attribute. Redshift Clusters have
Expand Down
9 changes: 8 additions & 1 deletion packages/@aws-cdk/aws-redshift/lib/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,13 @@ export interface ClusterProps {
* @default RemovalPolicy.RETAIN
*/
readonly removalPolicy?: RemovalPolicy

/**
* Whether to make cluster publicly accessible.
*
* @default false
*/
readonly publiclyAccessible?: boolean
}

/**
Expand Down Expand Up @@ -469,7 +476,7 @@ export class Cluster extends ClusterBase {
loggingProperties,
iamRoles: props.roles ? props.roles.map(role => role.roleArn) : undefined,
dbName: props.defaultDatabaseName || 'default_db',
publiclyAccessible: false,
publiclyAccessible: props.publiclyAccessible || false,
// Encryption
kmsKeyId: props.encryptionKey && props.encryptionKey.keyArn,
encrypted: props.encrypted !== undefined ? props.encrypted : true,
Expand Down
16 changes: 16 additions & 0 deletions packages/@aws-cdk/aws-redshift/test/cluster.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,22 @@ test('cluster with parameter group', () => {

});

test('publicly accessible cluster', () => {
// WHEN
new Cluster(stack, 'Redshift', {
masterUser: {
masterUsername: 'admin',
},
vpc,
publiclyAccessible: true,
});

// THEN
cdkExpect(stack).to(haveResource('AWS::Redshift::Cluster', {
PubliclyAccessible: true,
}));
});

test('imported cluster with imported security group honors allowAllOutbound', () => {
// GIVEN
const cluster = Cluster.fromClusterAttributes(stack, 'Database', {
Expand Down

0 comments on commit 9f8a6de

Please sign in to comment.