Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(neptune): auto minor version upgrade for an instance #31988

Merged
merged 19 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created an integration test with a mixed autoMinorVersionUpgrade setting for verification, and it is deploying successfully.


```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
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 - same as the cluster's autoMinorVersionUpgrade setting
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the default in CDK is undefined. Do not refer to the default value in the service.

Copy link
Contributor Author

@badmintoncryer badmintoncryer Nov 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, does this mean that it is preferable to specify @default undefined here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Copy link
Contributor Author

@badmintoncryer badmintoncryer Nov 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DESIGN_GUIDELINES says that it is better to avoid @default undefined.

don't write @default undefined, describe the behavior that happens if the property is not supplied.

https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md#defaults

Therefore, I think it would be better to describe how the current behavior works. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but IMO, we should not mention the CFN default behaviour, since we will not update this value if CFN decided to change that default value.

Copy link
Contributor Author

@badmintoncryer badmintoncryer Nov 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated my description to @default undefined and suppressed linter.

awslint.json

{
  "exclude": [
    "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",
    "props-no-undefined-default:@aws-cdk/aws-neptune-alpha.DatabaseInstanceProps.autoMinorVersionUpgrade" // added
  ]
}

*/
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