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): add copyTagsToSnapshot property to the DatabaseCluster Construct #30092

Merged
merged 7 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-neptune-alpha/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ To set up a Neptune database, define a `DatabaseCluster`. You must always launch
const cluster = new neptune.DatabaseCluster(this, 'Database', {
vpc,
instanceType: neptune.InstanceType.R5_LARGE,
copyTagsToSnapshot: true // whether to save the cluster tags when creating the snapshot.
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems unnatural to have this property here, which is the most basic chapter. How about creating a new chapter like the Automatic minor version upgrades?

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 added a new chapter about copyTagsSnapshot.

});
```

Expand Down
14 changes: 12 additions & 2 deletions packages/@aws-cdk/aws-neptune-alpha/lib/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export class EngineVersion {
* Constructor for specifying a custom engine version
* @param version the engine version of Neptune
*/
public constructor(public readonly version: string) {}
public constructor(public readonly version: string) { }
}

/**
Expand All @@ -105,7 +105,7 @@ export class LogType {
* Constructor for specifying a custom log type
* @param value the log type
*/
public constructor(public readonly value: string) {}
public constructor(public readonly value: string) { }
}

export interface ServerlessScalingConfiguration {
Expand Down Expand Up @@ -321,6 +321,13 @@ export interface DatabaseClusterProps {
* @default - required if instanceType is db.serverless
*/
readonly serverlessScalingConfiguration?: ServerlessScalingConfiguration;

/**
* Whether to copy tags to the snapshot when a snapshot is created.
*
* @default - false
*/
readonly copyTagsToSnapshot?: boolean;
}

/**
Expand Down Expand Up @@ -616,6 +623,9 @@ export class DatabaseCluster extends DatabaseClusterBase implements IDatabaseClu
enableCloudwatchLogsExports: props.cloudwatchLogsExports?.map(logType => logType.value),
storageEncrypted,
serverlessScalingConfiguration: props.serverlessScalingConfiguration,
// Tags
copyTagsToSnapshot: props.copyTagsToSnapshot,

mazyu36 marked this conversation as resolved.
Show resolved Hide resolved
});

cluster.applyRemovalPolicy(props.removalPolicy, {
Expand Down
34 changes: 34 additions & 0 deletions packages/@aws-cdk/aws-neptune-alpha/test/cluster.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,40 @@ describe('DatabaseCluster', () => {
RetentionInDays: 30,
});
});

test('cluster with copyTagsToSnapshot default', () => {
mazyu36 marked this conversation as resolved.
Show resolved Hide resolved
// GIVEN
const stack = testStack();
const vpc = new ec2.Vpc(stack, 'VPC');

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

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::Neptune::DBCluster', {
CopyTagsToSnapshot: Match.absent(),
});
});

test.each([false, true])('cluster with copyTagsToSnapshot set', (value) => {
const stack = testStack();
const vpc = new ec2.Vpc(stack, 'VPC');

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

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::Neptune::DBCluster', {
CopyTagsToSnapshot: value,
});
});
});

function 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.