Skip to content

Commit

Permalink
Merge branch 'master' into optional-disabled-parameter-for-lambda-eve…
Browse files Browse the repository at this point in the history
…nt-sources
  • Loading branch information
Zeynep Su Kurultay authored Mar 2, 2020
2 parents 557536f + 9e2ac91 commit 67e362e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/@aws-cdk/aws-rds/lib/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ export interface DatabaseInstanceSourceProps extends DatabaseInstanceNewProps {
readonly allowMajorVersionUpgrade?: boolean;

/**
* The time zone of the instance.
* The time zone of the instance. This is currently supported only by Microsoft Sql Server.
*
* @default - RDS default timezone
*/
Expand Down Expand Up @@ -678,6 +678,12 @@ abstract class DatabaseInstanceSource extends DatabaseInstanceNew implements IDa
this.singleUserRotationApplication = props.engine.singleUserRotationApplication;
this.multiUserRotationApplication = props.engine.multiUserRotationApplication;

const timezoneSupport = [ DatabaseInstanceEngine.SQL_SERVER_EE, DatabaseInstanceEngine.SQL_SERVER_EX,
DatabaseInstanceEngine.SQL_SERVER_SE, DatabaseInstanceEngine.SQL_SERVER_WEB ];
if (props.timezone && !timezoneSupport.includes(props.engine)) {
throw new Error(`timezone property can be configured only for Microsoft SQL Server, not ${props.engine.name}`);
}

this.sourceCfnProps = {
...this.newCfnProps,
allocatedStorage: props.allocatedStorage ? props.allocatedStorage.toString() : '100',
Expand Down
33 changes: 33 additions & 0 deletions packages/@aws-cdk/aws-rds/test/test.instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -685,4 +685,37 @@ export = {

test.done();
},

'throws when timezone is set for non-sqlserver database engine'(test: Test) {
// GIVEN
const stack = new cdk.Stack();
const vpc = new ec2.Vpc(stack, 'vpc');
const tzSupportedEngines = [ rds.DatabaseInstanceEngine.SQL_SERVER_EE, rds.DatabaseInstanceEngine.SQL_SERVER_EX,
rds.DatabaseInstanceEngine.SQL_SERVER_SE, rds.DatabaseInstanceEngine.SQL_SERVER_WEB ];
const tzUnsupportedEngines = [ rds.DatabaseInstanceEngine.MYSQL, rds.DatabaseInstanceEngine.POSTGRES,
rds.DatabaseInstanceEngine.ORACLE_EE, rds.DatabaseInstanceEngine.MARIADB ];

// THEN
tzSupportedEngines.forEach((engine) => {
test.ok(new rds.DatabaseInstance(stack, `${engine.name}-db`, {
engine,
instanceClass: ec2.InstanceType.of(ec2.InstanceClass.C5, ec2.InstanceSize.SMALL),
masterUsername: 'master',
timezone: 'Europe/Zurich',
vpc,
}));
});

tzUnsupportedEngines.forEach((engine) => {
test.throws(() => new rds.DatabaseInstance(stack, `${engine.name}-db`, {
engine,
instanceClass: ec2.InstanceType.of(ec2.InstanceClass.C5, ec2.InstanceSize.SMALL),
masterUsername: 'master',
timezone: 'Europe/Zurich',
vpc,
}), /timezone property can be configured only for Microsoft SQL Server/);
});

test.done();
}
};

0 comments on commit 67e362e

Please sign in to comment.