Skip to content

Commit ba8edb3

Browse files
authored
feat(neptune): add copyTagsToSnapshot property to the DatabaseCluster Construct (#30092)
### Issue # (if applicable) Closes #30087 ### Reason for this change As described in the issue. ### Description of changes Add copyTagsToSnapshot property to the DatabaseCluster Construct. ### Description of how you validated changes Add both unit tests 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 6301a9a commit ba8edb3

12 files changed

+2021
-7
lines changed

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

+17-5
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import * as neptune from '@aws-cdk/aws-neptune-alpha';
2525

2626
## Starting a Neptune Database
2727

28-
To set up a Neptune database, define a `DatabaseCluster`. You must always launch a database in a VPC.
28+
To set up a Neptune database, define a `DatabaseCluster`. You must always launch a database in a VPC.
2929

3030
```ts
3131
const cluster = new neptune.DatabaseCluster(this, 'Database', {
@@ -126,9 +126,9 @@ const replica1 = new neptune.DatabaseInstance(this, 'Instance', {
126126

127127
## Automatic minor version upgrades
128128

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

133133
```ts
134134
new neptune.DatabaseCluster(this, 'Cluster', {
@@ -184,9 +184,21 @@ instance.metric('SparqlRequestsPerSec') // instance-level SparqlErrors metric
184184

185185
For more details on the available metrics, refer to https://docs.aws.amazon.com/neptune/latest/userguide/cw-metrics.html
186186

187+
## Copy tags to snapshot
188+
189+
By setting `copyTagsToSnapshot` to true, all tags of the cluster are copied to the snapshots when they are created.
190+
191+
```ts
192+
const cluster = new neptune.DatabaseCluster(this, 'Database', {
193+
vpc,
194+
instanceType: neptune.InstanceType.R5_LARGE,
195+
copyTagsToSnapshot: true // whether to save the cluster tags when creating the snapshot.
196+
});
197+
```
198+
187199
## Neptune Serverless
188200

189-
You can configure a Neptune Serverless cluster using the dedicated instance type along with the
201+
You can configure a Neptune Serverless cluster using the dedicated instance type along with the
190202
`serverlessScalingConfiguration` property.
191203

192204
> Visit [Using Amazon Neptune Serverless](https://docs.aws.amazon.com/neptune/latest/userguide/neptune-serverless-using.html) for more details.

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

+11-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export class EngineVersion {
8989
* Constructor for specifying a custom engine version
9090
* @param version the engine version of Neptune
9191
*/
92-
public constructor(public readonly version: string) {}
92+
public constructor(public readonly version: string) { }
9393
}
9494

9595
/**
@@ -109,7 +109,7 @@ export class LogType {
109109
* Constructor for specifying a custom log type
110110
* @param value the log type
111111
*/
112-
public constructor(public readonly value: string) {}
112+
public constructor(public readonly value: string) { }
113113
}
114114

115115
export interface ServerlessScalingConfiguration {
@@ -325,6 +325,13 @@ export interface DatabaseClusterProps {
325325
* @default - required if instanceType is db.serverless
326326
*/
327327
readonly serverlessScalingConfiguration?: ServerlessScalingConfiguration;
328+
329+
/**
330+
* Whether to copy tags to the snapshot when a snapshot is created.
331+
*
332+
* @default - false
333+
*/
334+
readonly copyTagsToSnapshot?: boolean;
328335
}
329336

330337
/**
@@ -620,6 +627,8 @@ export class DatabaseCluster extends DatabaseClusterBase implements IDatabaseClu
620627
enableCloudwatchLogsExports: props.cloudwatchLogsExports?.map(logType => logType.value),
621628
storageEncrypted,
622629
serverlessScalingConfiguration: props.serverlessScalingConfiguration,
630+
// Tags
631+
copyTagsToSnapshot: props.copyTagsToSnapshot,
623632
});
624633

625634
cluster.applyRemovalPolicy(props.removalPolicy, {

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

+34
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,40 @@ describe('DatabaseCluster', () => {
879879
RetentionInDays: 30,
880880
});
881881
});
882+
883+
test('copyTagsToSnapshot is not set by default', () => {
884+
// GIVEN
885+
const stack = testStack();
886+
const vpc = new ec2.Vpc(stack, 'VPC');
887+
888+
// WHEN
889+
new DatabaseCluster(stack, 'Database', {
890+
vpc,
891+
instanceType: InstanceType.R5_LARGE,
892+
});
893+
894+
// THEN
895+
Template.fromStack(stack).hasResourceProperties('AWS::Neptune::DBCluster', {
896+
CopyTagsToSnapshot: Match.absent(),
897+
});
898+
});
899+
900+
test.each([false, true])('cluster with copyTagsToSnapshot set', (value) => {
901+
const stack = testStack();
902+
const vpc = new ec2.Vpc(stack, 'VPC');
903+
904+
// WHEN
905+
new DatabaseCluster(stack, 'Database', {
906+
vpc,
907+
instanceType: InstanceType.R5_LARGE,
908+
copyTagsToSnapshot: value,
909+
});
910+
911+
// THEN
912+
Template.fromStack(stack).hasResourceProperties('AWS::Neptune::DBCluster', {
913+
CopyTagsToSnapshot: value,
914+
});
915+
});
882916
});
883917

884918
function testStack() {

packages/@aws-cdk/aws-neptune-alpha/test/integ.cluster-copy-tags-to-snapshot.js.snapshot/ClusterTestDefaultTestDeployAssert6A1BBA9D.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.cluster-copy-tags-to-snapshot.js.snapshot/ClusterTestDefaultTestDeployAssert6A1BBA9D.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.cluster-copy-tags-to-snapshot.js.snapshot/aws-cdk-neptune-integ-copy-tags-to-snapshot.assets.json

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)