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 all commits
Commits
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
22 changes: 17 additions & 5 deletions packages/@aws-cdk/aws-neptune-alpha/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import * as neptune from '@aws-cdk/aws-neptune-alpha';

## Starting a Neptune Database

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

```ts
const cluster = new neptune.DatabaseCluster(this, 'Database', {
Expand Down Expand Up @@ -126,9 +126,9 @@ const replica1 = new neptune.DatabaseInstance(this, 'Instance', {

## Automatic minor version upgrades

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

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

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

## Copy tags to snapshot

By setting `copyTagsToSnapshot` to true, all tags of the cluster are copied to the snapshots when they are created.

```ts
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.
});
```

## Neptune Serverless

You can configure a Neptune Serverless cluster using the dedicated instance type along with the
You can configure a Neptune Serverless cluster using the dedicated instance type along with the
`serverlessScalingConfiguration` property.

> Visit [Using Amazon Neptune Serverless](https://docs.aws.amazon.com/neptune/latest/userguide/neptune-serverless-using.html) for more details.
Expand Down
13 changes: 11 additions & 2 deletions packages/@aws-cdk/aws-neptune-alpha/lib/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,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 @@ -109,7 +109,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 @@ -325,6 +325,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 @@ -620,6 +627,8 @@ export class DatabaseCluster extends DatabaseClusterBase implements IDatabaseClu
enableCloudwatchLogsExports: props.cloudwatchLogsExports?.map(logType => logType.value),
storageEncrypted,
serverlessScalingConfiguration: props.serverlessScalingConfiguration,
// Tags
copyTagsToSnapshot: props.copyTagsToSnapshot,
});

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('copyTagsToSnapshot is not set by default', () => {
// 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.

Loading