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(redshift): tableNameSuffix evaluation #17213

Merged
merged 17 commits into from
Nov 11, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ClusterProps, executeStatement } from './util';

export async function handler(props: TableHandlerProps & ClusterProps, event: AWSLambda.CloudFormationCustomResourceEvent) {
const tableNamePrefix = props.tableName.prefix;
const tableNameSuffix = props.tableName.generateSuffix ? `${event.RequestId.substring(0, 8)}` : '';
const tableNameSuffix = props.tableName.generateSuffix === 'true' ? `${event.RequestId.substring(0, 8)}` : '';
const tableColumns = props.tableColumns;
const clusterProps = props;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface UserHandlerProps {
export interface TableHandlerProps {
readonly tableName: {
readonly prefix: string;
readonly generateSuffix: boolean;
readonly generateSuffix: string;
};
readonly tableColumns: Column[];
}
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-redshift/lib/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export class Table extends TableBase {
properties: {
tableName: {
prefix: props.tableName ?? cdk.Names.uniqueId(this),
generateSuffix: !props.tableName,
generateSuffix: !props.tableName ? 'true' : 'false',
},
tableColumns: this.tableColumns,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const physicalResourceId = 'PhysicalResourceId';
const resourceProperties = {
tableName: {
prefix: tableNamePrefix,
generateSuffix: true,
generateSuffix: 'true',
},
tableColumns,
clusterName,
Expand Down Expand Up @@ -64,7 +64,7 @@ describe('create', () => {
...resourceProperties,
tableName: {
...resourceProperties.tableName,
generateSuffix: false,
generateSuffix: 'false',
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1369,7 +1369,7 @@
"databaseName": "my_db",
"tableName": {
"prefix": "awscdkredshiftclusterdatabaseTable24923533",
"generateSuffix": true
"generateSuffix": "true"
},
"tableColumns": [
{
Expand Down Expand Up @@ -1412,4 +1412,4 @@
"Description": "Artifact hash for asset \"daeb79e3cee39c9b902dc0d5c780223e227ed573ea60976252947adab5fb2be1\""
}
}
}
}
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-redshift/test/table.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('cluster table', () => {
Template.fromStack(stack).hasResourceProperties('Custom::RedshiftDatabaseQuery', {
tableName: {
prefix: 'Table',
generateSuffix: true,
generateSuffix: 'true',
},
tableColumns,
});
Expand All @@ -67,7 +67,7 @@ describe('cluster table', () => {
Template.fromStack(stack).hasResourceProperties('Custom::RedshiftDatabaseQuery', {
tableName: {
prefix: tableName,
generateSuffix: false,
generateSuffix: 'false',
},
});
});
Expand Down