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(docdb): graduate to stable 🚀 #13875

Merged
merged 4 commits into from
Mar 30, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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
24 changes: 6 additions & 18 deletions packages/@aws-cdk/aws-docdb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,7 @@

![cfn-resources: Stable](https://img.shields.io/badge/cfn--resources-stable-success.svg?style=for-the-badge)

> All classes with the `Cfn` prefix in this module ([CFN Resources]) are always stable and safe to use.
>
> [CFN Resources]: https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_lib

![cdk-constructs: Experimental](https://img.shields.io/badge/cdk--constructs-experimental-important.svg?style=for-the-badge)

> The APIs of higher level constructs in this module are experimental and under active development.
> They are subject to non-backward compatible changes or removal in any future version. These are
> not subject to the [Semantic Versioning](https://semver.org/) model and breaking changes will be
> announced in the release notes. This means that while you may use them, you may need to update
> your source code when upgrading to a newer version of this package.
![cdk-constructs: Stable](https://img.shields.io/badge/cdk--constructs-stable-success.svg?style=for-the-badge)

---

Expand All @@ -32,13 +22,11 @@ const cluster = new DatabaseCluster(this, 'Database', {
masterUser: {
username: 'myuser' // NOTE: 'admin' is reserved by DocumentDB
},
instanceProps: {
instanceType: ec2.InstanceType.of(ec2.InstanceClass.R5, ec2.InstanceSize.LARGE),
vpcSubnets: {
subnetType: ec2.SubnetType.PUBLIC,
},
vpc
}
instanceType: ec2.InstanceType.of(ec2.InstanceClass.R5, ec2.InstanceSize.LARGE),
vpcSubnets: {
subnetType: ec2.SubnetType.PUBLIC,
},
vpc
});
```

Expand Down
51 changes: 36 additions & 15 deletions packages/@aws-cdk/aws-docdb/lib/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { DatabaseSecret } from './database-secret';
import { CfnDBCluster, CfnDBInstance, CfnDBSubnetGroup } from './docdb.generated';
import { Endpoint } from './endpoint';
import { IClusterParameterGroup } from './parameter-group';
import { BackupProps, InstanceProps, Login, RotationMultiUserOptions } from './props';
import { BackupProps, Login, RotationMultiUserOptions } from './props';

/**
* Properties for a new database cluster
Expand Down Expand Up @@ -82,9 +82,37 @@ export interface DatabaseClusterProps {
readonly instanceIdentifierBase?: string;

/**
* Settings for the individual instances that are launched
* What type of instance to start for the replicas
*/
readonly instanceProps: InstanceProps;
readonly instanceType: ec2.InstanceType;

/**
* What subnets to run the DocumentDB instances in.
*
* Must be at least 2 subnets in two different AZs.
*/
readonly vpc: ec2.IVpc;

/**
* Where to place the instances within the VPC
*
* @default private subnets
*/
readonly vpcSubnets?: ec2.SubnetSelection;

/**
* Security group.
*
* @default a new security group is created.
*/
readonly securityGroup?: ec2.ISecurityGroup;

/**
* The DB parameter group to associate with the instance.
*
* @default no parameter group
*/
readonly parameterGroup?: IClusterParameterGroup;

/**
* A weekly time range in which maintenance should preferably execute.
Expand All @@ -99,13 +127,6 @@ export interface DatabaseClusterProps {
*/
readonly preferredMaintenanceWindow?: string;

/**
* Additional parameters to pass to the database engine
*
* @default - No parameter group.
*/
readonly parameterGroup?: IClusterParameterGroup;

/**
* The removal policy to apply when the cluster and its instances are removed
* or replaced during a stack update, or when the stack is deleted. This
Expand Down Expand Up @@ -275,8 +296,8 @@ export class DatabaseCluster extends DatabaseClusterBase {
constructor(scope: Construct, id: string, props: DatabaseClusterProps) {
super(scope, id);

this.vpc = props.instanceProps.vpc;
this.vpcSubnets = props.instanceProps.vpcSubnets;
this.vpc = props.vpc;
this.vpcSubnets = props.vpcSubnets;

// Determine the subnet(s) to deploy the DocDB cluster to
const { subnetIds, internetConnectivityEstablished } = this.vpc.selectSubnets(this.vpcSubnets);
Expand All @@ -295,8 +316,8 @@ export class DatabaseCluster extends DatabaseClusterBase {

// Create the security group for the DB cluster
let securityGroup: ec2.ISecurityGroup;
if (props.instanceProps.securityGroup) {
securityGroup = props.instanceProps.securityGroup;
if (props.securityGroup) {
securityGroup = props.securityGroup;
} else {
securityGroup = new ec2.SecurityGroup(this, 'SecurityGroup', {
description: 'DocumentDB security group',
Expand Down Expand Up @@ -381,7 +402,7 @@ export class DatabaseCluster extends DatabaseClusterBase {
dbClusterIdentifier: cluster.ref,
dbInstanceIdentifier: instanceIdentifier,
// Instance properties
dbInstanceClass: databaseInstanceType(props.instanceProps.instanceType),
dbInstanceClass: databaseInstanceType(props.instanceType),
});

instance.applyRemovalPolicy(props.removalPolicy, {
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-docdb/lib/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export interface DatabaseInstanceProps {
/**
* The name of the compute and memory capacity classes.
*/
readonly instanceClass: ec2.InstanceType;
readonly instanceType: ec2.InstanceType;

/**
* The name of the Availability Zone where the DB instance will be located.
Expand Down Expand Up @@ -202,7 +202,7 @@ export class DatabaseInstance extends DatabaseInstanceBase implements IDatabaseI

const instance = new CfnDBInstance(this, 'Resource', {
dbClusterIdentifier: props.cluster.clusterIdentifier,
dbInstanceClass: `db.${props.instanceClass}`,
dbInstanceClass: `db.${props.instanceType}`,
autoMinorVersionUpgrade: props.autoMinorVersionUpgrade ?? true,
availabilityZone: props.availabilityZone,
dbInstanceIdentifier: props.dbInstanceName,
Expand Down
40 changes: 0 additions & 40 deletions packages/@aws-cdk/aws-docdb/lib/props.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import * as ec2 from '@aws-cdk/aws-ec2';
import * as kms from '@aws-cdk/aws-kms';
import * as secretsmanager from '@aws-cdk/aws-secretsmanager';
import { Duration, SecretValue } from '@aws-cdk/core';
import { IClusterParameterGroup } from './parameter-group';

/**
* Backup configuration for DocumentDB databases
Expand Down Expand Up @@ -57,44 +55,6 @@ export interface Login {
readonly kmsKey?: kms.IKey;
}

/**
* Instance properties for database instances
*/
export interface InstanceProps {
/**
* What type of instance to start for the replicas
*/
readonly instanceType: ec2.InstanceType;

/**
* What subnets to run the DocumentDB instances in.
*
* Must be at least 2 subnets in two different AZs.
*/
readonly vpc: ec2.IVpc;

/**
* Where to place the instances within the VPC
*
* @default private subnets
*/
readonly vpcSubnets?: ec2.SubnetSelection;

/**
* Security group.
*
* @default a new security group is created.
*/
readonly securityGroup?: ec2.ISecurityGroup;

/**
* The DB parameter group to associate with the instance.
*
* @default no parameter group
*/
readonly parameterGroup?: IClusterParameterGroup;
}

/**
* Options to add the multi user rotation
*/
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-docdb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@
"attribute-tag:@aws-cdk/aws-docdb.DatabaseSecret.secretName"
]
},
"stability": "experimental",
"maturity": "experimental",
"stability": "stable",
"maturity": "stable",
"awscdkio": {
"announce": false
},
Expand Down
Loading