Skip to content

Commit 8b5320a

Browse files
authored
feat(aws-neptune): add autoMinorVersionUpgrade to cluster props (#18394)
Fixes #17545
1 parent b6e3e51 commit 8b5320a

File tree

5 files changed

+66
-1
lines changed

5 files changed

+66
-1
lines changed

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

+14
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,17 @@ const replica1 = new neptune.DatabaseInstance(this, 'Instance', {
125125
instanceType: neptune.InstanceType.R5_LARGE
126126
});
127127
```
128+
129+
## Automatic minor version upgrades
130+
131+
By setting `autoMinorVersionUpgrade` to true, Neptune will automatically update
132+
the engine of the entire cluster to the latest minor version after a stabilization
133+
window of 2 to 3 weeks.
134+
135+
```ts
136+
new neptune.DatabaseCluster(stack, 'Cluster', {
137+
vpc,
138+
instanceType: InstanceType.R5_LARGE,
139+
autoMinorVersionUpgrade: true
140+
});
141+
```

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

+9
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,14 @@ export interface DatabaseClusterProps {
226226
* @default - Retain cluster.
227227
*/
228228
readonly removalPolicy?: RemovalPolicy
229+
230+
/**
231+
* If set to true, Neptune will automatically update the engine of the entire
232+
* cluster to the latest minor version after a stabilization window of 2 to 3 weeks.
233+
*
234+
* @default - false
235+
*/
236+
readonly autoMinorVersionUpgrade?: boolean;
229237
}
230238

231239
/**
@@ -513,6 +521,7 @@ export class DatabaseCluster extends DatabaseClusterBase implements IDatabaseClu
513521
// Instance properties
514522
dbInstanceClass: props.instanceType._instanceType,
515523
dbParameterGroupName: props.parameterGroup?.parameterGroupName,
524+
autoMinorVersionUpgrade: props.autoMinorVersionUpgrade === true,
516525
});
517526

518527
// We must have a dependency on the NAT gateway provider here to create

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

+40
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,46 @@ describe('DatabaseCluster', () => {
523523
// THEN
524524
expect(() => { cluster.grantConnect(role); }).toThrow(/Cannot grant connect when IAM authentication is disabled/);
525525
});
526+
527+
test('autoMinorVersionUpgrade is enabled when configured', () => {
528+
529+
// GIVEN
530+
const stack = testStack();
531+
const vpc = new ec2.Vpc(stack, 'VPC');
532+
533+
// WHEN
534+
new DatabaseCluster(stack, 'Cluster', {
535+
vpc,
536+
instanceType: InstanceType.R5_LARGE,
537+
autoMinorVersionUpgrade: true,
538+
});
539+
540+
// THEN
541+
Template.fromStack(stack).hasResourceProperties('AWS::Neptune::DBInstance', {
542+
AutoMinorVersionUpgrade: true,
543+
});
544+
545+
});
546+
547+
test('autoMinorVersionUpgrade is not enabled when not configured', () => {
548+
549+
// GIVEN
550+
const stack = testStack();
551+
const vpc = new ec2.Vpc(stack, 'VPC');
552+
553+
// WHEN
554+
new DatabaseCluster(stack, 'Cluster', {
555+
vpc,
556+
instanceType: InstanceType.R5_LARGE,
557+
});
558+
559+
// THEN
560+
Template.fromStack(stack).hasResourceProperties('AWS::Neptune::DBInstance', {
561+
AutoMinorVersionUpgrade: false,
562+
});
563+
564+
});
565+
526566
});
527567

528568
function testStack() {

packages/@aws-cdk/aws-neptune/test/integ.cluster.expected.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,8 @@
491491
"DBInstanceClass": "db.r5.large",
492492
"DBClusterIdentifier": {
493493
"Ref": "DatabaseB269D8BB"
494-
}
494+
},
495+
"AutoMinorVersionUpgrade": true
495496
},
496497
"DependsOn": [
497498
"VPCPrivateSubnet1DefaultRouteAE1D6490",

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

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class TestStack extends cdk.Stack {
3535
clusterParameterGroup: params,
3636
kmsKey,
3737
removalPolicy: cdk.RemovalPolicy.DESTROY,
38+
autoMinorVersionUpgrade: true,
3839
});
3940

4041
cluster.connections.allowDefaultPortFromAnyIpv4('Open to the world');

0 commit comments

Comments
 (0)