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(rds): database instance - auto scale allocated storage #6788

Merged
merged 32 commits into from
Mar 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
375a157
fix(apigateway): Allows configuring authorization scopes in apigatewa…
pankajy93 Feb 28, 2020
37249b2
Fixes build failure for Case sensitive fields
pankajy93 Feb 28, 2020
bab8d99
Merge branch 'master' into master
nirvana124 Feb 29, 2020
71ab433
Update packages/@aws-cdk/aws-apigateway/lib/method.ts
nirvana124 Mar 5, 2020
26c31ea
Update packages/@aws-cdk/aws-apigateway/lib/method.ts
nirvana124 Mar 5, 2020
14dfbe7
Update packages/@aws-cdk/aws-apigateway/lib/method.ts
nirvana124 Mar 5, 2020
4612c83
Update packages/@aws-cdk/aws-apigateway/test/test.method.ts
nirvana124 Mar 5, 2020
87cbb71
Update packages/@aws-cdk/aws-apigateway/test/test.method.ts
nirvana124 Mar 5, 2020
07a3188
Merge branch 'master' into master
nirvana124 Mar 5, 2020
49d3752
Added test cases to cover auth scopes absent and method options auth …
pankajy93 Mar 5, 2020
3399253
Updating readme for authorizationScopes
pankajy93 Mar 5, 2020
913df38
removing trailing white space to fix @aws-cdk/aws-apigateway: ERROR: …
pankajy93 Mar 5, 2020
3f451f7
Merge branch 'master' into master
nirvana124 Mar 9, 2020
9b558f4
Merge branch 'master' into master
nirvana124 Mar 10, 2020
6b3e232
adds comments under default integration and method section.
pankajy93 Mar 13, 2020
7518e33
Merge branch 'master' into master
nirvana124 Mar 13, 2020
5cea74b
adjust lang in README
Mar 13, 2020
4660a32
Reolved conflicts
pankajy93 Mar 13, 2020
c11dc30
Merge branch 'master' of https://github.com/nirvana124/aws-cdk
pankajy93 Mar 15, 2020
3f75fca
Merge branch 'master' of https://github.com/aws/aws-cdk
pankajy93 Mar 15, 2020
b7b169e
Merge branch 'master' of https://github.com/aws/aws-cdk
pankajy93 Mar 17, 2020
0399ffc
Merge branch 'master' of https://github.com/aws/aws-cdk
pankajy93 Mar 18, 2020
fcc79bf
feat(rds): configure maxAllocatedStorage for rds fixes #6666
pankajy93 Mar 18, 2020
fff58e8
Merge branch 'master' into nirvana124/maxAllocatedStorage
nirvana124 Mar 21, 2020
7b6fb74
spell fix
nirvana124 Mar 23, 2020
84f84b7
spell fix
nirvana124 Mar 23, 2020
7ffd572
Adding docs url
nirvana124 Mar 23, 2020
e1e2c23
Correct url of autoscale document
nirvana124 Mar 23, 2020
c6e6b4d
Adding new line
nirvana124 Mar 23, 2020
8253fc2
Review comment fixes
pankajy93 Mar 24, 2020
aa0c688
Merge branch 'master' into nirvana124/maxAllocatedStorage
nirvana124 Mar 24, 2020
928f4c7
Merge branch 'master' into nirvana124/maxAllocatedStorage
mergify[bot] Mar 24, 2020
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
16 changes: 16 additions & 0 deletions packages/@aws-cdk/aws-rds/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,21 @@ const instance = new DatabaseInstance(stack, 'Instance', {
```
By default, the master password will be generated and stored in AWS Secrets Manager.

To use the storage auto scaling option of RDS you can specify the maximum allocated storage.
This is the upper limit to which RDS can automatically scale the storage. More info can be found
[here](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_PIOPS.StorageTypes.html#USER_PIOPS.Autoscaling)
Example for max storage configuration:

```ts
const instance = new DatabaseInstance(stack, 'Instance', {
engine: rds.DatabaseInstanceEngine.ORACLE_SE1,
instanceClass: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE2, ec2.InstanceSize.SMALL),
masterUsername: 'syscdk',
vpc,
maxAllocatedStorage: 200
});
```

Use `DatabaseInstanceFromSnapshot` and `DatabaseInstanceReadReplica` to create an instance from snapshot or
a source database respectively:

Expand All @@ -76,6 +91,7 @@ new DatabaseInstanceReadReplica(stack, 'ReadReplica', {
vpc
});
```

Creating a "production" Oracle database instance with option and parameter groups:

[example of setting up a production oracle instance](test/integ.instance.lit.ts)
Expand Down
10 changes: 9 additions & 1 deletion packages/@aws-cdk/aws-rds/lib/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,13 @@ export interface DatabaseInstanceNewProps {
* @default RemovalPolicy.Retain
*/
readonly removalPolicy?: RemovalPolicy

/**
* Upper limit to which RDS can scale the storage in GiB(Gibibyte).
* @see https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_PIOPS.StorageTypes.html#USER_PIOPS.Autoscaling
* @default - No autoscaling of RDS instance
*/
readonly maxAllocatedStorage?: number;
}

/**
Expand Down Expand Up @@ -567,7 +574,8 @@ abstract class DatabaseInstanceNew extends DatabaseInstanceBase implements IData
processorFeatures: props.processorFeatures && renderProcessorFeatures(props.processorFeatures),
publiclyAccessible: props.vpcPlacement && props.vpcPlacement.subnetType === ec2.SubnetType.PUBLIC,
storageType,
vpcSecurityGroups: securityGroups.map(s => s.securityGroupId)
vpcSecurityGroups: securityGroups.map(s => s.securityGroupId),
maxAllocatedStorage: props.maxAllocatedStorage
};
}

Expand Down
46 changes: 46 additions & 0 deletions packages/@aws-cdk/aws-rds/test/test.instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,52 @@ export = {
}), /timezone property can be configured only for Microsoft SQL Server/);
});

test.done();
},

'create an instance from snapshot with maximum allocated storage'(test: Test) {
// GIVEN
const stack = new cdk.Stack();
const vpc = new ec2.Vpc(stack, 'VPC');

// WHEN
new rds.DatabaseInstanceFromSnapshot(stack, 'Instance', {
snapshotIdentifier: 'my-snapshot',
engine: rds.DatabaseInstanceEngine.POSTGRES,
instanceClass: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE2, ec2.InstanceSize.LARGE),
vpc,
maxAllocatedStorage: 200
});

expect(stack).to(haveResource('AWS::RDS::DBInstance', {
DBSnapshotIdentifier: 'my-snapshot',
MaxAllocatedStorage: 200
}));

test.done();
},

'create a DB instance with maximum allocated storage'(test: Test) {
// GIVEN
const stack = new cdk.Stack();
const vpc = new ec2.Vpc(stack, 'VPC');

// WHEN
new rds.DatabaseInstance(stack, 'Instance', {
engine: rds.DatabaseInstanceEngine.MYSQL,
instanceClass: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE2, ec2.InstanceSize.SMALL),
masterUsername: 'admin',
vpc,
backupRetention: cdk.Duration.seconds(0),
maxAllocatedStorage: 250
});

// THEN
expect(stack).to(haveResource('AWS::RDS::DBInstance', {
BackupRetentionPeriod: 0,
MaxAllocatedStorage: 250
}));

test.done();
}
};