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

fix(rds): setting timezone on DatabaseInstance causes internal failure #6534

Merged
merged 2 commits into from
Mar 2, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 6 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,11 @@ abstract class DatabaseInstanceSource extends DatabaseInstanceNew implements IDa
this.singleUserRotationApplication = props.engine.singleUserRotationApplication;
this.multiUserRotationApplication = props.engine.multiUserRotationApplication;

if (props.timezone && props.engine !== DatabaseInstanceEngine.SQL_SERVER_EE && props.engine !== DatabaseInstanceEngine.SQL_SERVER_EX
nija-at marked this conversation as resolved.
Show resolved Hide resolved
&& props.engine !== DatabaseInstanceEngine.SQL_SERVER_SE && props.engine !== DatabaseInstanceEngine.SQL_SERVER_WEB) {
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
48 changes: 48 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,52 @@ export = {

test.done();
},

'throws when timezone is set for non-sqlserver database engine'(test: Test) {
// GIVEN
const stack = new cdk.Stack();
const dbConfig = {
instanceClass: ec2.InstanceType.of(ec2.InstanceClass.C5, ec2.InstanceSize.SMALL),
masterUsername: 'master',
timezone: 'Europe/Zurich',
vpc: new ec2.Vpc(stack, 'myvpc'),
};

// THEN
test.ok(new rds.DatabaseInstance(stack, 'sqlserver-ee-db', {
nija-at marked this conversation as resolved.
Show resolved Hide resolved
engine: rds.DatabaseInstanceEngine.SQL_SERVER_EE,
...dbConfig
}));
test.ok(new rds.DatabaseInstance(stack, 'sqlserver-ex-db', {
engine: rds.DatabaseInstanceEngine.SQL_SERVER_EX,
...dbConfig
}));
test.ok(new rds.DatabaseInstance(stack, 'sqlserver-se-db', {
engine: rds.DatabaseInstanceEngine.SQL_SERVER_SE,
...dbConfig
}));
test.ok(new rds.DatabaseInstance(stack, 'sqlserver-web-db', {
engine: rds.DatabaseInstanceEngine.SQL_SERVER_WEB,
...dbConfig
}));

test.throws(() => new rds.DatabaseInstance(stack, 'mysql-db', {
engine: rds.DatabaseInstanceEngine.MYSQL,
...dbConfig
}), /timezone property can be configured only for Microsoft SQL Server/);
test.throws(() => new rds.DatabaseInstance(stack, 'postgres-db', {
engine: rds.DatabaseInstanceEngine.POSTGRES,
...dbConfig
}), /timezone property can be configured only for Microsoft SQL Server/);
test.throws(() => new rds.DatabaseInstance(stack, 'oracle-ee-db', {
engine: rds.DatabaseInstanceEngine.ORACLE_EE,
...dbConfig
}), /timezone property can be configured only for Microsoft SQL Server/);
test.throws(() => new rds.DatabaseInstance(stack, 'maria-db', {
engine: rds.DatabaseInstanceEngine.MARIADB,
...dbConfig
}), /timezone property can be configured only for Microsoft SQL Server/);

test.done();
}
};