Skip to content

Commit 130b62b

Browse files
feat(neptune-alpha): specify port for the cluster (#31137)
### 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*
1 parent 7ed221c commit 130b62b

14 files changed

+2345
-0
lines changed

packages/@aws-cdk/aws-neptune-alpha/README.md

+12
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,18 @@ new neptune.DatabaseCluster(this, 'Cluster', {
138138
});
139139
```
140140

141+
## Port
142+
143+
By default, Neptune uses port `8182`. You can override the default port by specifying the `port` property:
144+
145+
```ts
146+
const cluster = new neptune.DatabaseCluster(this, 'Database', {
147+
vpc,
148+
instanceType: neptune.InstanceType.R5_LARGE,
149+
port: 12345,
150+
});
151+
```
152+
141153
## Logging
142154

143155
Neptune supports various methods for monitoring performance and usage. One of those methods is logging

packages/@aws-cdk/aws-neptune-alpha/lib/cluster.ts

+8
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,13 @@ export interface DatabaseClusterProps {
332332
* @default - false
333333
*/
334334
readonly copyTagsToSnapshot?: boolean;
335+
336+
/**
337+
* The port number on which the DB instances in the DB cluster accept connections.
338+
*
339+
* @default 8182
340+
*/
341+
readonly port?: number;
335342
}
336343

337344
/**
@@ -617,6 +624,7 @@ export class DatabaseCluster extends DatabaseClusterBase implements IDatabaseClu
617624
deletionProtection: deletionProtection,
618625
associatedRoles: props.associatedRoles ? props.associatedRoles.map(role => ({ roleArn: role.roleArn })) : undefined,
619626
iamAuthEnabled: Lazy.any({ produce: () => this.enableIamAuthentication }),
627+
dbPort: props.port,
620628
// Backup
621629
backupRetentionPeriod: props.backupRetention?.toDays(),
622630
preferredBackupWindow: props.preferredBackupWindow,

packages/@aws-cdk/aws-neptune-alpha/test/cluster.test.ts

+18
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,24 @@ describe('DatabaseCluster', () => {
221221
});
222222
});
223223

224+
test('cluster with port', () => {
225+
// GIVEN
226+
const stack = testStack();
227+
const vpc = new ec2.Vpc(stack, 'VPC');
228+
229+
// WHEN
230+
new DatabaseCluster(stack, 'Database', {
231+
vpc,
232+
instanceType: InstanceType.R5_LARGE,
233+
port: 1234,
234+
});
235+
236+
// THEN
237+
Template.fromStack(stack).hasResourceProperties('AWS::Neptune::DBCluster', {
238+
DBPort: 1234,
239+
});
240+
});
241+
224242
test('cluster with imported parameter group', () => {
225243
// GIVEN
226244
const stack = testStack();

packages/@aws-cdk/aws-neptune-alpha/test/integ.cluster-port.js.snapshot/NeptuneClusterPortTestDefaultTestDeployAssert7A0847B4.assets.json

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/aws-neptune-alpha/test/integ.cluster-port.js.snapshot/NeptuneClusterPortTestDefaultTestDeployAssert7A0847B4.template.json

+36
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/aws-neptune-alpha/test/integ.cluster-port.js.snapshot/NeptuneClusterPortTestStack.assets.json

+32
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)