Skip to content

Commit

Permalink
feat(aws-neptune): add autoMinorVersionUpgrade to cluster props (aws#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ericzbeard authored and TikiTDO committed Feb 21, 2022
1 parent d72cc71 commit fe2b4c8
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 1 deletion.
14 changes: 14 additions & 0 deletions packages/@aws-cdk/aws-neptune/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,17 @@ const replica1 = new neptune.DatabaseInstance(this, 'Instance', {
instanceType: neptune.InstanceType.R5_LARGE
});
```

## Automatic minor version upgrades

By setting `autoMinorVersionUpgrade` to true, Neptune will automatically update
the engine of the entire cluster to the latest minor version after a stabilization
window of 2 to 3 weeks.

```ts
new neptune.DatabaseCluster(stack, 'Cluster', {
vpc,
instanceType: InstanceType.R5_LARGE,
autoMinorVersionUpgrade: true
});
```
9 changes: 9 additions & 0 deletions packages/@aws-cdk/aws-neptune/lib/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,14 @@ export interface DatabaseClusterProps {
* @default - Retain cluster.
*/
readonly removalPolicy?: RemovalPolicy

/**
* If set to true, Neptune will automatically update the engine of the entire
* cluster to the latest minor version after a stabilization window of 2 to 3 weeks.
*
* @default - false
*/
readonly autoMinorVersionUpgrade?: boolean;
}

/**
Expand Down Expand Up @@ -513,6 +521,7 @@ export class DatabaseCluster extends DatabaseClusterBase implements IDatabaseClu
// Instance properties
dbInstanceClass: props.instanceType._instanceType,
dbParameterGroupName: props.parameterGroup?.parameterGroupName,
autoMinorVersionUpgrade: props.autoMinorVersionUpgrade === true,
});

// We must have a dependency on the NAT gateway provider here to create
Expand Down
40 changes: 40 additions & 0 deletions packages/@aws-cdk/aws-neptune/test/cluster.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,46 @@ describe('DatabaseCluster', () => {
// THEN
expect(() => { cluster.grantConnect(role); }).toThrow(/Cannot grant connect when IAM authentication is disabled/);
});

test('autoMinorVersionUpgrade is enabled when configured', () => {

// GIVEN
const stack = testStack();
const vpc = new ec2.Vpc(stack, 'VPC');

// WHEN
new DatabaseCluster(stack, 'Cluster', {
vpc,
instanceType: InstanceType.R5_LARGE,
autoMinorVersionUpgrade: true,
});

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::Neptune::DBInstance', {
AutoMinorVersionUpgrade: true,
});

});

test('autoMinorVersionUpgrade is not enabled when not configured', () => {

// GIVEN
const stack = testStack();
const vpc = new ec2.Vpc(stack, 'VPC');

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

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::Neptune::DBInstance', {
AutoMinorVersionUpgrade: false,
});

});

});

function testStack() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,8 @@
"DBInstanceClass": "db.r5.large",
"DBClusterIdentifier": {
"Ref": "DatabaseB269D8BB"
}
},
"AutoMinorVersionUpgrade": true
},
"DependsOn": [
"VPCPrivateSubnet1DefaultRouteAE1D6490",
Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-neptune/test/integ.cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class TestStack extends cdk.Stack {
clusterParameterGroup: params,
kmsKey,
removalPolicy: cdk.RemovalPolicy.DESTROY,
autoMinorVersionUpgrade: true,
});

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

0 comments on commit fe2b4c8

Please sign in to comment.