Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(aws-redshiftserverless): support Namespace and Workgroup L2 construct #43

Merged
merged 32 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
35629f6
feat: add Redshift Serverless Namespace and Workgroup construct
mazyu36 Sep 11, 2024
ea83a48
add namespace validation
mazyu36 Sep 12, 2024
f220079
fix
mazyu36 Sep 12, 2024
bb9e928
add validation for workgroup
mazyu36 Sep 12, 2024
87c01f9
lint
mazyu36 Sep 12, 2024
58893ad
update
mazyu36 Sep 12, 2024
63aca7a
add README
mazyu36 Sep 12, 2024
3b71877
update baseCapacity
mazyu36 Sep 14, 2024
e843891
Merge branch 'main' into redshift-serverless
hoegertn Sep 15, 2024
6f4ec2e
Merge branch 'main' into redshift-serverless
hoegertn Sep 15, 2024
a5a62c5
update docs
mazyu36 Sep 15, 2024
624447e
Merge branch 'main' into redshift-serverless
hoegertn Sep 25, 2024
9c7680d
incorporate review comments
mazyu36 Sep 27, 2024
472df47
Update src/aws-redshiftserverless/README.md
mazyu36 Sep 28, 2024
77db5f0
Update src/aws-redshiftserverless/README.md
mazyu36 Sep 28, 2024
2fd5907
fix name
mazyu36 Sep 28, 2024
b5b58b0
docs updated
mazyu36 Sep 29, 2024
1f6ddd6
add addIamRole method
mazyu36 Sep 29, 2024
9e2fffa
Update src/aws-redshiftserverless/namespace.ts
mazyu36 Sep 29, 2024
45179ab
Update src/aws-redshiftserverless/namespace.ts
mazyu36 Sep 29, 2024
044283e
Update src/aws-redshiftserverless/namespace.ts
mazyu36 Sep 29, 2024
754f8d8
Update src/aws-redshiftserverless/namespace.ts
mazyu36 Sep 29, 2024
7ad4f6c
Update src/aws-redshiftserverless/workgroup.ts
mazyu36 Sep 29, 2024
fcefdff
Update src/aws-redshiftserverless/workgroup.ts
mazyu36 Sep 29, 2024
3358535
Update src/aws-redshiftserverless/workgroup.ts
mazyu36 Sep 29, 2024
f7dfb94
Update src/aws-redshiftserverless/namespace.ts
mazyu36 Sep 29, 2024
8898327
Update src/aws-redshiftserverless/namespace.ts
mazyu36 Sep 29, 2024
2f3bf5a
incorporate review comments
mazyu36 Sep 29, 2024
878394a
Update test/aws-redshiftserverless/workgroup.test.ts
mazyu36 Oct 1, 2024
899b01e
Update src/aws-redshiftserverless/README.md
mazyu36 Oct 1, 2024
2a628a2
Update test/aws-redshiftserverless/workgroup.test.ts
mazyu36 Oct 1, 2024
31c9ae6
incorporate review comments
mazyu36 Oct 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,559 changes: 1,468 additions & 91 deletions API.md

Large diffs are not rendered by default.

98 changes: 98 additions & 0 deletions src/aws-redshiftserverless/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
Constructs for the Amazon Redshift Serverlss

# Redshift Serverless CDK Construct

## Overview

The `Namespace` construct and the `Workgroup` construct facilitate the creation and management of [Redshift Serverless Workgroups and namespaces](https://docs.aws.amazon.com/redshift/latest/mgmt/serverless-workgroup-namespace.html) within AWS CDK applications.

## Usage

Import the necessary classes from AWS CDK and this construct and create a VPC for the workgroup:

```ts
import { App, Stack } from 'aws-cdk-lib';
import * as ec2 from 'aws-cdk-lib/aws-ec2';
import { Namespace, Workgroup } from '@open-constructs/aws-cdk/aws-redshiftserverless';

const app = new App();
const stack = new Stack(app, 'RedshiftServerlessStack',{
account: '012345678901'
region: 'us-east-1',
});
const vpc = new ec2.Vpc(stack, 'MyVpc');
```

**Note** If you want to use `Vpc` Construct to create a VPC for `Workgroup`, you must specify `account` and `region` in `Stack`.
`Workgroup` needs at least three subnets, and they must span across three Availability Zones.

The environment-agnostic stacks will be created with access to only 2 AZs (Ref: [`maxAzs` property docs](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.Vpc.html#maxazs))

For more infomation about Redshift Serverles's limitations, see [Considerations when using Amazon Redshift Serverless](https://docs.aws.amazon.com/redshift/latest/mgmt/serverless-usage-considerations.html).

### Basic Example

Here's how you can create a namespace and a workgroup:

```ts
import { SecretValue } from 'aws-cdk-lib';
import * as iam from 'aws-cdk-lib/aws-iam';
declare const defaultIamRole: iam.IRole;
declare const anotherIamRole: iam.IRole;

const namespace = new redshiftserverless.Namespace(stack, 'Namespace', {
namespaceName: 'my-namespace',
defaultIamRole: myIamRole, // Specify a default IAM role
iamRoles: [defaultIamRole, anotherIamRole], // Assign IAM roles list which must include default IAM Role
});

const workgroup = new redshiftserverless.Workgroup(stack, 'MyWorkgroup', {
workgroupName: 'my-workgroup',
namespace,
vpc,
});
```

### Advanced Example

Creating a namespace and a workgroup with custom settings:

```ts
declare const workgroupSecurityGroup: ec2.ISecurityGroup;

const namespace = new redshiftserverless.Namespace(stack, 'MyCustomNamespace', {
namespaceName: 'my-custom-namespace',
dbName: 'mydb', // Spacify user-defined database name
adminUsername: 'admin', // Specify user-defined admin username
adminUserpassword: SecretValue.unsafePlainText('My-password-123!'), // Spacify user-defined admin password
mazyu36 marked this conversation as resolved.
Show resolved Hide resolved
logExports: [redshiftserverless.LogExport.USER_LOG], // Log export settings
});

const workgroup = new redshiftserverless.Workgroup(stack, 'MyCustomWorkgroup', {
workgroupName: 'my-custom-workgroup',
namespace,
vpc,
baseCapacity: 32, // Specify Base Capacity uses to serve queries
securityGroups: [workgroupSecurityGroup], // Specify user-defined security groups
});
```

### Import an existing endpoint:
You can import existing namespaces and workgroups:

```ts
declare const securityGroup: ec2.ISecurityGroup;

const importedNamespace = redshiftserverless.Namespace.fromNamespaceAttributes(stack, 'ImportedNamespace', {
namespaceId: 'my-namespace-id',
namespaceName: 'my-namespace-name',
});

const importedWorkgroup = redshiftserverless.Workgroup.fromWorkgroupAttributes(stack, 'ImportedWorkgroup', {
workgroupName: 'my-workgroup',
workgroupId: 'my-workgroup-id',
endpointAddress: 'my-workgroup.endpoint.com',
port: 5439,
securityGroups: [securityGroup],
});
```
2 changes: 2 additions & 0 deletions src/aws-redshiftserverless/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './namespace';
export * from './workgroup';
Loading
Loading