Skip to content

Commit

Permalink
feat(neptune): auto minor version upgrade for an instance (#31988)
Browse files Browse the repository at this point in the history
### 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*
  • Loading branch information
badmintoncryer authored Dec 2, 2024
1 parent 40835a0 commit d95db49
Show file tree
Hide file tree
Showing 15 changed files with 2,363 additions and 1 deletion.
11 changes: 11 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,17 @@ new neptune.DatabaseCluster(this, 'Cluster', {
});
```

You can also specify `autoMinorVersionUpgrade` to a database instance.
Even within the same cluster, you can modify the `autoMinorVersionUpgrade` setting on a per-instance basis.

```ts fixture=with-cluster
new neptune.DatabaseInstance(this, 'Instance', {
cluster,
instanceType: neptune.InstanceType.R5_LARGE,
autoMinorVersionUpgrade: true,
});
```

## Port

By default, Neptune uses port `8182`. You can override the default port by specifying the `port` property:
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-neptune-alpha/awslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"props-physical-name:@aws-cdk/aws-neptune-alpha.ClusterParameterGroupProps",
"props-physical-name:@aws-cdk/aws-neptune-alpha.ParameterGroupProps",
"props-physical-name:@aws-cdk/aws-neptune-alpha.SubnetGroupProps",
"docs-public-apis:@aws-cdk/aws-neptune-alpha.ServerlessScalingConfiguration"
"docs-public-apis:@aws-cdk/aws-neptune-alpha.ServerlessScalingConfiguration",
"props-no-undefined-default:@aws-cdk/aws-neptune-alpha.DatabaseInstanceProps.autoMinorVersionUpgrade"
]
}
8 changes: 8 additions & 0 deletions packages/@aws-cdk/aws-neptune-alpha/lib/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,13 @@ export interface DatabaseInstanceProps {
* @default RemovalPolicy.Retain
*/
readonly removalPolicy?: cdk.RemovalPolicy;

/**
* Indicates that minor version patches are applied automatically.
*
* @default undefined
*/
readonly autoMinorVersionUpgrade?: boolean;
}

/**
Expand Down Expand Up @@ -494,6 +501,7 @@ export class DatabaseInstance extends DatabaseInstanceBase implements IDatabaseI
super(scope, id);

const instance = new CfnDBInstance(this, 'Resource', {
autoMinorVersionUpgrade: props.autoMinorVersionUpgrade,
dbClusterIdentifier: props.cluster.clusterIdentifier,
dbInstanceClass: props.instanceType._instanceType,
availabilityZone: props.availabilityZone,
Expand Down
17 changes: 17 additions & 0 deletions packages/@aws-cdk/aws-neptune-alpha/test/instance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,23 @@ describe('DatabaseInstance', () => {
});
});

test.each([true, false])('instance with auto minor version upgrade', (autoMinorVersionUpgrade) => {
// GIVEN
const stack = testStack();

// WHEN
new DatabaseInstance(stack, 'Instance', {
cluster: stack.cluster,
instanceType: InstanceType.R5_LARGE,
autoMinorVersionUpgrade,
});

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

test('instance type from CfnParameter', () => {
// 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 d95db49

Please sign in to comment.