Skip to content

Commit

Permalink
feat(neptune-alpha): specify port for the cluster (#31137)
Browse files Browse the repository at this point in the history
### Issue # (if applicable)

Closes #31074.

### Reason for this change

Cloudformation supports for setting port number for the Neptune cluster but AWS CDK cannot do this.

### Description of changes

Add `port` prop to `DatabaseClusterProps`.

### Description of how you validated changes

Added both unit and integ tests.

### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
badmintoncryer authored Sep 4, 2024
1 parent 7ed221c commit 130b62b
Show file tree
Hide file tree
Showing 14 changed files with 2,345 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/@aws-cdk/aws-neptune-alpha/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,18 @@ new neptune.DatabaseCluster(this, 'Cluster', {
});
```

## Port

By default, Neptune uses port `8182`. You can override the default port by specifying the `port` property:

```ts
const cluster = new neptune.DatabaseCluster(this, 'Database', {
vpc,
instanceType: neptune.InstanceType.R5_LARGE,
port: 12345,
});
```

## Logging

Neptune supports various methods for monitoring performance and usage. One of those methods is logging
Expand Down
8 changes: 8 additions & 0 deletions packages/@aws-cdk/aws-neptune-alpha/lib/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,13 @@ export interface DatabaseClusterProps {
* @default - false
*/
readonly copyTagsToSnapshot?: boolean;

/**
* The port number on which the DB instances in the DB cluster accept connections.
*
* @default 8182
*/
readonly port?: number;
}

/**
Expand Down Expand Up @@ -617,6 +624,7 @@ export class DatabaseCluster extends DatabaseClusterBase implements IDatabaseClu
deletionProtection: deletionProtection,
associatedRoles: props.associatedRoles ? props.associatedRoles.map(role => ({ roleArn: role.roleArn })) : undefined,
iamAuthEnabled: Lazy.any({ produce: () => this.enableIamAuthentication }),
dbPort: props.port,
// Backup
backupRetentionPeriod: props.backupRetention?.toDays(),
preferredBackupWindow: props.preferredBackupWindow,
Expand Down
18 changes: 18 additions & 0 deletions packages/@aws-cdk/aws-neptune-alpha/test/cluster.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,24 @@ describe('DatabaseCluster', () => {
});
});

test('cluster with port', () => {
// GIVEN
const stack = testStack();
const vpc = new ec2.Vpc(stack, 'VPC');

// WHEN
new DatabaseCluster(stack, 'Database', {
vpc,
instanceType: InstanceType.R5_LARGE,
port: 1234,
});

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::Neptune::DBCluster', {
DBPort: 1234,
});
});

test('cluster with imported parameter group', () => {
// GIVEN
const stack = testStack();
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 130b62b

Please # to comment.