Skip to content

Commit d95db49

Browse files
feat(neptune): auto minor version upgrade for an instance (#31988)
### Issue # (if applicable) None ### Reason for this change Cloudformation supports for configuring `autoMinorVersionUpgrade` for a database instance but AWS CDK cannot do that. https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-neptune-dbinstance.html#cfn-neptune-dbinstance-autominorversionupgrade ### Description of changes Add `autoMinorVersionUpgrade` to `DatabaseInstanceProps` ### 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 40835a0 commit d95db49

15 files changed

+2363
-1
lines changed

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

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

141+
You can also specify `autoMinorVersionUpgrade` to a database instance.
142+
Even within the same cluster, you can modify the `autoMinorVersionUpgrade` setting on a per-instance basis.
143+
144+
```ts fixture=with-cluster
145+
new neptune.DatabaseInstance(this, 'Instance', {
146+
cluster,
147+
instanceType: neptune.InstanceType.R5_LARGE,
148+
autoMinorVersionUpgrade: true,
149+
});
150+
```
151+
141152
## Port
142153

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

packages/@aws-cdk/aws-neptune-alpha/awslint.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"props-physical-name:@aws-cdk/aws-neptune-alpha.ClusterParameterGroupProps",
44
"props-physical-name:@aws-cdk/aws-neptune-alpha.ParameterGroupProps",
55
"props-physical-name:@aws-cdk/aws-neptune-alpha.SubnetGroupProps",
6-
"docs-public-apis:@aws-cdk/aws-neptune-alpha.ServerlessScalingConfiguration"
6+
"docs-public-apis:@aws-cdk/aws-neptune-alpha.ServerlessScalingConfiguration",
7+
"props-no-undefined-default:@aws-cdk/aws-neptune-alpha.DatabaseInstanceProps.autoMinorVersionUpgrade"
78
]
89
}

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

+8
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,13 @@ export interface DatabaseInstanceProps {
403403
* @default RemovalPolicy.Retain
404404
*/
405405
readonly removalPolicy?: cdk.RemovalPolicy;
406+
407+
/**
408+
* Indicates that minor version patches are applied automatically.
409+
*
410+
* @default undefined
411+
*/
412+
readonly autoMinorVersionUpgrade?: boolean;
406413
}
407414

408415
/**
@@ -494,6 +501,7 @@ export class DatabaseInstance extends DatabaseInstanceBase implements IDatabaseI
494501
super(scope, id);
495502

496503
const instance = new CfnDBInstance(this, 'Resource', {
504+
autoMinorVersionUpgrade: props.autoMinorVersionUpgrade,
497505
dbClusterIdentifier: props.cluster.clusterIdentifier,
498506
dbInstanceClass: props.instanceType._instanceType,
499507
availabilityZone: props.availabilityZone,

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

+17
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,23 @@ describe('DatabaseInstance', () => {
108108
});
109109
});
110110

111+
test.each([true, false])('instance with auto minor version upgrade', (autoMinorVersionUpgrade) => {
112+
// GIVEN
113+
const stack = testStack();
114+
115+
// WHEN
116+
new DatabaseInstance(stack, 'Instance', {
117+
cluster: stack.cluster,
118+
instanceType: InstanceType.R5_LARGE,
119+
autoMinorVersionUpgrade,
120+
});
121+
122+
// THEN
123+
Template.fromStack(stack).hasResourceProperties('AWS::Neptune::DBInstance', {
124+
AutoMinorVersionUpgrade: autoMinorVersionUpgrade,
125+
});
126+
});
127+
111128
test('instance type from CfnParameter', () => {
112129
// GIVEN
113130
const stack = testStack();

packages/@aws-cdk/aws-neptune-alpha/test/integ.instance-auto-minor-version-upgrade.js.snapshot/AutoMinorVersionUpgradeInstanceIntegDefaultTestDeployAssert5F020D27.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.instance-auto-minor-version-upgrade.js.snapshot/AutoMinorVersionUpgradeInstanceIntegDefaultTestDeployAssert5F020D27.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.instance-auto-minor-version-upgrade.js.snapshot/AutoMinorVersionUpgradeInstanceStack.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)