From 3546c5da8c502bac635a2d066386433f755c5c22 Mon Sep 17 00:00:00 2001 From: Rizbir Khan Date: Thu, 30 Mar 2023 14:48:57 +0000 Subject: [PATCH 01/21] refactor to use table id over table name --- .../database-query-provider/privileges.ts | 26 +- .../aws-redshift/lib/private/handler-props.ts | 1 + .../aws-redshift/lib/private/privileges.ts | 25 +- packages/@aws-cdk/aws-redshift/lib/table.ts | 9 + .../privileges.test.ts | 69 +- .../handler-name.js | 10 - .../index.js | 21 - .../privileges.js | 58 - .../redshift-data.js | 37 - .../table.js | 148 -- .../types.js | 24 - .../user.js | 70 - .../util.js | 34 - .../handler-name.js | 10 - .../index.js | 23 - .../privileges.js | 58 - .../redshift-data.js | 37 - .../table.js | 148 -- .../types.js | 120 - .../user.js | 70 - .../util.js | 34 - ...-cdk-redshift-cluster-database.assets.json | 14 +- ...dk-redshift-cluster-database.template.json | 2367 +++++++++-------- .../test/integ.database.js.snapshot/cdk.out | 2 +- .../integ.database.js.snapshot/integ.json | 8 +- .../integ.database.js.snapshot/manifest.json | 14 +- ...efaultTestDeployAssert4339FB48.assets.json | 4 +- .../test/integ.database.js.snapshot/tree.json | 16 +- 28 files changed, 1344 insertions(+), 2113 deletions(-) delete mode 100644 packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.169a8c0beb97c903ee155ea9653e39b0884c9e3b860ac72ffbe906b3c1f4e338/handler-name.js delete mode 100644 packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.169a8c0beb97c903ee155ea9653e39b0884c9e3b860ac72ffbe906b3c1f4e338/index.js delete mode 100644 packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.169a8c0beb97c903ee155ea9653e39b0884c9e3b860ac72ffbe906b3c1f4e338/privileges.js delete mode 100644 packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.169a8c0beb97c903ee155ea9653e39b0884c9e3b860ac72ffbe906b3c1f4e338/redshift-data.js delete mode 100644 packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.169a8c0beb97c903ee155ea9653e39b0884c9e3b860ac72ffbe906b3c1f4e338/table.js delete mode 100644 packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.169a8c0beb97c903ee155ea9653e39b0884c9e3b860ac72ffbe906b3c1f4e338/types.js delete mode 100644 packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.169a8c0beb97c903ee155ea9653e39b0884c9e3b860ac72ffbe906b3c1f4e338/user.js delete mode 100644 packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.169a8c0beb97c903ee155ea9653e39b0884c9e3b860ac72ffbe906b3c1f4e338/util.js delete mode 100644 packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.847e15feeb180b356ab9a8094d8b9459ea8ec26fc27957794d583ed9eb3a79d8/handler-name.js delete mode 100644 packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.847e15feeb180b356ab9a8094d8b9459ea8ec26fc27957794d583ed9eb3a79d8/index.js delete mode 100644 packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.847e15feeb180b356ab9a8094d8b9459ea8ec26fc27957794d583ed9eb3a79d8/privileges.js delete mode 100644 packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.847e15feeb180b356ab9a8094d8b9459ea8ec26fc27957794d583ed9eb3a79d8/redshift-data.js delete mode 100644 packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.847e15feeb180b356ab9a8094d8b9459ea8ec26fc27957794d583ed9eb3a79d8/table.js delete mode 100644 packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.847e15feeb180b356ab9a8094d8b9459ea8ec26fc27957794d583ed9eb3a79d8/types.js delete mode 100644 packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.847e15feeb180b356ab9a8094d8b9459ea8ec26fc27957794d583ed9eb3a79d8/user.js delete mode 100644 packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.847e15feeb180b356ab9a8094d8b9459ea8ec26fc27957794d583ed9eb3a79d8/util.js diff --git a/packages/@aws-cdk/aws-redshift/lib/private/database-query-provider/privileges.ts b/packages/@aws-cdk/aws-redshift/lib/private/database-query-provider/privileges.ts index f1533bb9cb326..dfe3b8f283de6 100644 --- a/packages/@aws-cdk/aws-redshift/lib/private/database-query-provider/privileges.ts +++ b/packages/@aws-cdk/aws-redshift/lib/private/database-query-provider/privileges.ts @@ -62,10 +62,28 @@ async function updatePrivileges( } const oldTablePrivileges = oldResourceProperties.tablePrivileges; - if (oldTablePrivileges !== tablePrivileges) { - await revokePrivileges(username, oldTablePrivileges, clusterProps); - await grantPrivileges(username, tablePrivileges, clusterProps); - return { replace: false }; + const tablesToRevoke = oldTablePrivileges.filter(({ tableId, actions }) => { + const tableRemoved = !tablePrivileges.find(({ tableId: otherTableId }) => tableId === otherTableId); + const actionsRemoved = tablePrivileges.find(({ tableId: otherTableId, actions: otherActions }) => ( + tableId === otherTableId && actions.some(action => !otherActions.includes(action)) + )); + return tableRemoved || actionsRemoved; + }); + if (tablesToRevoke.length > 0) { + await revokePrivileges(username, tablesToRevoke, clusterProps); + } + + const tablesToGrant = tablePrivileges.filter(({ tableId, tableName, actions }) => { + const tableAdded = !oldTablePrivileges.find(({ tableId: otherTableId, tableName: otherTableName }) => ( + tableId === otherTableId && tableName === otherTableName + )); + const actionsAdded = oldTablePrivileges.find(({ tableId: otherTableId, actions: otherActions }) => ( + tableId === otherTableId && otherActions.some(action => !actions.includes(action)) + )); + return tableAdded || actionsAdded; + }); + if (tablesToGrant.length > 0) { + await grantPrivileges(username, tablesToGrant, clusterProps); } return { replace: false }; diff --git a/packages/@aws-cdk/aws-redshift/lib/private/handler-props.ts b/packages/@aws-cdk/aws-redshift/lib/private/handler-props.ts index b26fe2a5a7237..b0ac515d7e36a 100644 --- a/packages/@aws-cdk/aws-redshift/lib/private/handler-props.ts +++ b/packages/@aws-cdk/aws-redshift/lib/private/handler-props.ts @@ -25,6 +25,7 @@ export interface TableHandlerProps { } export interface TablePrivilege { + readonly tableId: string; readonly tableName: string; readonly actions: string[]; } diff --git a/packages/@aws-cdk/aws-redshift/lib/private/privileges.ts b/packages/@aws-cdk/aws-redshift/lib/private/privileges.ts index b9975d7fdec7c..a96f272995719 100644 --- a/packages/@aws-cdk/aws-redshift/lib/private/privileges.ts +++ b/packages/@aws-cdk/aws-redshift/lib/private/privileges.ts @@ -63,23 +63,30 @@ export class UserTablePrivileges extends Construct { tablePrivileges: cdk.Lazy.any({ produce: () => { const reducedPrivileges = this.privileges.reduce((privileges, { table, actions }) => { - const tableName = table.tableName; - if (!(tableName in privileges)) { - privileges[tableName] = []; + const tableId = table.id; + if (!(tableId in privileges)) { + privileges[tableId] = { + tableName: table.tableName, + actions: [], + }; } - actions = actions.concat(privileges[tableName]); + actions = actions.concat(privileges[tableId].actions); if (actions.includes(TableAction.ALL)) { actions = [TableAction.ALL]; } if (actions.includes(TableAction.UPDATE) || actions.includes(TableAction.DELETE)) { actions.push(TableAction.SELECT); } - privileges[tableName] = Array.from(new Set(actions)); + privileges[tableId] = { + tableName: table.tableName, + actions: Array.from(new Set(actions)), + }; return privileges; - }, {} as { [key: string]: TableAction[] }); - const serializedPrivileges: SerializedTablePrivilege[] = Object.entries(reducedPrivileges).map(([tableName, actions]) => ({ - tableName: tableName, - actions: actions.map(action => TableAction[action]), + }, {} as { [key: string]: { tableName: string, actions: TableAction[] } }); + const serializedPrivileges: SerializedTablePrivilege[] = Object.entries(reducedPrivileges).map(([tableId, config]) => ({ + tableId, + tableName: config.tableName, + actions: config.actions.map(action => TableAction[action]), })); return serializedPrivileges; }, diff --git a/packages/@aws-cdk/aws-redshift/lib/table.ts b/packages/@aws-cdk/aws-redshift/lib/table.ts index 92587ca745efa..12947230c9960 100644 --- a/packages/@aws-cdk/aws-redshift/lib/table.ts +++ b/packages/@aws-cdk/aws-redshift/lib/table.ts @@ -155,6 +155,11 @@ export interface TableProps extends DatabaseOptions { * Represents a table in a Redshift database. */ export interface ITable extends IConstruct { + /** + * Idenfifier of the table construct. + */ + readonly id: string; + /** * Name of the table. */ @@ -211,6 +216,7 @@ abstract class TableBase extends Construct implements ITable { abstract readonly tableColumns: Column[]; abstract readonly cluster: ICluster; abstract readonly databaseName: string; + abstract readonly id: string; grant(user: IUser, ...actions: TableAction[]) { user.addTablePrivileges(this, ...actions); } @@ -229,6 +235,7 @@ export class Table extends TableBase { readonly tableColumns = attrs.tableColumns; readonly cluster = attrs.cluster; readonly databaseName = attrs.databaseName; + readonly id = id; }(scope, id); } @@ -236,6 +243,7 @@ export class Table extends TableBase { readonly tableColumns: Column[]; readonly cluster: ICluster; readonly databaseName: string; + readonly id: string; private resource: DatabaseQuery; @@ -254,6 +262,7 @@ export class Table extends TableBase { this.tableColumns = props.tableColumns; this.cluster = props.cluster; this.databaseName = props.databaseName; + this.id = id; const useColumnIds = !!cdk.FeatureFlags.of(this).isEnabled(REDSHIFT_COLUMN_ID); diff --git a/packages/@aws-cdk/aws-redshift/test/database-query-provider/privileges.test.ts b/packages/@aws-cdk/aws-redshift/test/database-query-provider/privileges.test.ts index daa3835b89f24..0b4a8456e0c3a 100644 --- a/packages/@aws-cdk/aws-redshift/test/database-query-provider/privileges.test.ts +++ b/packages/@aws-cdk/aws-redshift/test/database-query-provider/privileges.test.ts @@ -3,7 +3,9 @@ import type * as AWSLambda from 'aws-lambda'; const username = 'username'; const tableName = 'tableName'; -const tablePrivileges = [{ tableName, actions: ['INSERT', 'SELECT'] }]; +const tableId = 'tableId'; +const actions = ['INSERT', 'SELECT']; +const tablePrivileges = [{ tableId, tableName, actions }]; const clusterName = 'clusterName'; const adminUserArn = 'adminUserArn'; const databaseName = 'databaseName'; @@ -142,9 +144,27 @@ describe('update', () => { })); }); - test('does not replace when privileges change', async () => { + test('does not replace when table name is changed', async () => { const newTableName = 'newTableName'; - const newTablePrivileges = [{ tableName: newTableName, actions: ['DROP'] }]; + const newTablePrivileges = [{ tableId, tableName: newTableName, actions }]; + const newResourceProperties = { + ...resourceProperties, + tablePrivileges: newTablePrivileges, + }; + + await expect(managePrivileges(newResourceProperties, event)).resolves.toMatchObject({ + PhysicalResourceId: physicalResourceId, + }); + expect(mockExecuteStatement).not.toHaveBeenCalledWith(expect.objectContaining({ + Sql: `REVOKE INSERT, SELECT ON ${newTableName} FROM ${username}`, + })); + expect(mockExecuteStatement).not.toHaveBeenCalledWith(expect.objectContaining({ + Sql: expect.stringMatching(new RegExp(`.+ ON ${tableName} TO ${username}`)), + })); + }); + + test('does not replace when table actions are changed', async () => { + const newTablePrivileges = [{ tableId, tableName, actions: ['DROP'] }]; const newResourceProperties = { ...resourceProperties, tablePrivileges: newTablePrivileges, @@ -157,7 +177,46 @@ describe('update', () => { Sql: `REVOKE INSERT, SELECT ON ${tableName} FROM ${username}`, })); expect(mockExecuteStatement).toHaveBeenCalledWith(expect.objectContaining({ - Sql: `GRANT DROP ON ${newTableName} TO ${username}`, + Sql: `GRANT DROP ON ${tableName} TO ${username}`, })); }); -}); + + test('does not replace when table id is changed', async () => { + const newTableId = 'newTableId'; + const newTablePrivileges = [{ tableId: newTableId, tableName, actions }]; + const newResourceProperties = { + ...resourceProperties, + tablePrivileges: newTablePrivileges, + }; + + await expect(managePrivileges(newResourceProperties, event)).resolves.toMatchObject({ + PhysicalResourceId: physicalResourceId, + }); + expect(mockExecuteStatement).not.toHaveBeenCalledWith(expect.objectContaining({ + Sql: `.+ ON ${tableName} FROM ${username}`, + })); + }); + + test('does not replace when table id is appended', async () => { + const newTablePrivileges = [{ tableId: 'newTableId', tableName, actions }]; + const newResourceProperties = { + ...resourceProperties, + tablePrivileges: newTablePrivileges, + }; + + const newEvent = { + ...event, + OldResourceProperties: { + ...event.OldResourceProperties, + tablePrivileges: [{ tableName, actions }], + }, + }; + + await expect(managePrivileges(newResourceProperties, newEvent)).resolves.toMatchObject({ + PhysicalResourceId: physicalResourceId, + }); + expect(mockExecuteStatement).not.toHaveBeenCalledWith(expect.objectContaining({ + Sql: `.+ ON ${tableName} FROM ${username}`, + })); + }); +}); \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.169a8c0beb97c903ee155ea9653e39b0884c9e3b860ac72ffbe906b3c1f4e338/handler-name.js b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.169a8c0beb97c903ee155ea9653e39b0884c9e3b860ac72ffbe906b3c1f4e338/handler-name.js deleted file mode 100644 index 4983115a93834..0000000000000 --- a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.169a8c0beb97c903ee155ea9653e39b0884c9e3b860ac72ffbe906b3c1f4e338/handler-name.js +++ /dev/null @@ -1,10 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.HandlerName = void 0; -var HandlerName; -(function (HandlerName) { - HandlerName["User"] = "user"; - HandlerName["Table"] = "table"; - HandlerName["UserTablePrivileges"] = "user-table-privileges"; -})(HandlerName = exports.HandlerName || (exports.HandlerName = {})); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGFuZGxlci1uYW1lLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiaGFuZGxlci1uYW1lLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLElBQVksV0FJWDtBQUpELFdBQVksV0FBVztJQUNyQiw0QkFBYSxDQUFBO0lBQ2IsOEJBQWUsQ0FBQTtJQUNmLDREQUE2QyxDQUFBO0FBQy9DLENBQUMsRUFKVyxXQUFXLEdBQVgsbUJBQVcsS0FBWCxtQkFBVyxRQUl0QiIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBlbnVtIEhhbmRsZXJOYW1lIHtcbiAgVXNlciA9ICd1c2VyJyxcbiAgVGFibGUgPSAndGFibGUnLFxuICBVc2VyVGFibGVQcml2aWxlZ2VzID0gJ3VzZXItdGFibGUtcHJpdmlsZWdlcycsXG59XG4iXX0= \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.169a8c0beb97c903ee155ea9653e39b0884c9e3b860ac72ffbe906b3c1f4e338/index.js b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.169a8c0beb97c903ee155ea9653e39b0884c9e3b860ac72ffbe906b3c1f4e338/index.js deleted file mode 100644 index d7a8b52f2944c..0000000000000 --- a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.169a8c0beb97c903ee155ea9653e39b0884c9e3b860ac72ffbe906b3c1f4e338/index.js +++ /dev/null @@ -1,21 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.handler = void 0; -const handler_name_1 = require("./handler-name"); -const privileges_1 = require("./privileges"); -const table_1 = require("./table"); -const user_1 = require("./user"); -const HANDLERS = { - [handler_name_1.HandlerName.Table]: table_1.handler, - [handler_name_1.HandlerName.User]: user_1.handler, - [handler_name_1.HandlerName.UserTablePrivileges]: privileges_1.handler, -}; -async function handler(event) { - const subHandler = HANDLERS[event.ResourceProperties.handler]; - if (!subHandler) { - throw new Error(`Requested handler ${event.ResourceProperties.handler} is not in supported set: ${JSON.stringify(Object.keys(HANDLERS))}`); - } - return subHandler(event.ResourceProperties, event); -} -exports.handler = handler; -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJpbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFFQSxpREFBNkM7QUFDN0MsNkNBQTJEO0FBQzNELG1DQUFpRDtBQUNqRCxpQ0FBK0M7QUFFL0MsTUFBTSxRQUFRLEdBQWlIO0lBQzdILENBQUMsMEJBQVcsQ0FBQyxLQUFLLENBQUMsRUFBRSxlQUFXO0lBQ2hDLENBQUMsMEJBQVcsQ0FBQyxJQUFJLENBQUMsRUFBRSxjQUFVO0lBQzlCLENBQUMsMEJBQVcsQ0F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tYXRpb25DdXN0b21SZXNvdXJjZUV2ZW50KSA9PiBQcm9taXNlPGFueT4pIH0gPSB7XG4gIFtIYW5kbGVyTmFtZS5UYWJsZV06IG1hbmFnZVRhYmxlLFxuICBbSGFuZGxlck5hbWUuVXNlcl06IG1hbmFnZVVzZXIsXG4gIFtIYW5kbGVyTmFtZS5Vc2VyVGFibGVQcml2aWxlZ2VzXTogbWFuYWdlUHJpdmlsZWdlcyxcbn07XG5cbmV4cG9ydCBhc3luYyBmdW5jdGlvbiBoYW5kbGVyKGV2ZW50OiBBV1NMYW1iZGEuQ2xvdWRGb3JtYXRpb25DdXN0b21SZXNvdXJjZUV2ZW50KSB7XG4gIGNvbnN0IHN1YkhhbmRsZXIgPSBIQU5ETEVSU1tldmVudC5SZXNvdXJjZVByb3BlcnRpZXMuaGFuZGxlciBhcyBIYW5kbGVyTmFtZV07XG4gIGlmICghc3ViSGFuZGxlcikge1xuICAgIHRocm93IG5ldyBFcnJvcihgUmVxdWVzdGVkIGhhbmRsZXIgJHtldmVudC5SZXNvdXJjZVByb3BlcnRpZXMuaGFuZGxlcn0gaXMgbm90IGluIHN1cHBvcnRlZCBzZXQ6ICR7SlNPTi5zdHJpbmdpZnkoT2JqZWN0LmtleXMoSEFORExFUlMpKX1gKTtcbiAgfVxuICByZXR1cm4gc3ViSGFuZGxlcihldmVudC5SZXNvdXJjZVByb3BlcnRpZXMsIGV2ZW50KTtcbn1cbiJdfQ== \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.169a8c0beb97c903ee155ea9653e39b0884c9e3b860ac72ffbe906b3c1f4e338/privileges.js b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.169a8c0beb97c903ee155ea9653e39b0884c9e3b860ac72ffbe906b3c1f4e338/privileges.js deleted file mode 100644 index 8770142deb498..0000000000000 --- a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.169a8c0beb97c903ee155ea9653e39b0884c9e3b860ac72ffbe906b3c1f4e338/privileges.js +++ /dev/null @@ -1,58 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.handler = void 0; -const redshift_data_1 = require("./redshift-data"); -const util_1 = require("./util"); -async function handler(props, event) { - const username = props.username; - const tablePrivileges = props.tablePrivileges; - const clusterProps = props; - if (event.RequestType === 'Create') { - await grantPrivileges(username, tablePrivileges, clusterProps); - return { PhysicalResourceId: util_1.makePhysicalId(username, clusterProps, event.RequestId) }; - } - else if (event.RequestType === 'Delete') { - await revokePrivileges(username, tablePrivileges, clusterProps); - return; - } - else if (event.RequestType === 'Update') { - const { replace } = await updatePrivileges(username, tablePrivileges, clusterProps, event.OldResourceProperties); - const physicalId = replace ? util_1.makePhysicalId(username, clusterProps, event.RequestId) : event.PhysicalResourceId; - return { PhysicalResourceId: physicalId }; - } - else { - /* eslint-disable-next-line dot-notation */ - throw new Error(`Unrecognized event type: ${event['RequestType']}`); - } -} -exports.handler = handler; -async function revokePrivileges(username, tablePrivileges, clusterProps) { - await Promise.all(tablePrivileges.map(({ tableName, actions }) => { - return redshift_data_1.executeStatement(`REVOKE ${actions.join(', ')} ON ${tableName} FROM ${username}`, clusterProps); - })); -} -async function grantPrivileges(username, tablePrivileges, clusterProps) { - await Promise.all(tablePrivileges.map(({ tableName, actions }) => { - return redshift_data_1.executeStatement(`GRANT ${actions.join(', ')} ON ${tableName} TO ${username}`, clusterProps); - })); -} -async function updatePrivileges(username, tablePrivileges, clusterProps, oldResourceProperties) { - const oldClusterProps = oldResourceProperties; - if (clusterProps.clusterName !== oldClusterProps.clusterName || clusterProps.databaseName !== oldClusterProps.databaseName) { - await grantPrivileges(username, tablePrivileges, clusterProps); - return { replace: true }; - } - const oldUsername = oldResourceProperties.username; - if (oldUsername !== username) { - await grantPrivileges(username, tablePrivileges, clusterProps); - return { replace: true }; - } - const oldTablePrivileges = oldResourceProperties.tablePrivileges; - if (oldTablePrivileges !== tablePrivileges) { - await revokePrivileges(username, oldTablePrivileges, clusterProps); - await grantPrivileges(username, tablePrivileges, clusterProps); - return { replace: false }; - } - return { replace: false }; -} -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJpdmlsZWdlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInByaXZpbGVnZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBRUEsbURBQW1EO0FBRW5ELGlDQUF3QztBQUdqQyxLQUFLLFVBQVUsT0FBTyxDQUFDLEtBQXFELEVBQUUsS0FBa0Q7SUFDckksTUFBTSxRQUFRLEdBQUcsS0FBSyxDQUFDLFFBQVEsQ0FBQztJQUNoQyxNQUFNLGVBQWUsR0FBRyxLQUFLLENBQUMsZUFBZSxDQUFDO0lBQzlDLE1BQU0sWUFBWSxHQUFHLEtBQUssQ0FBQztJQUUzQixJQUFJLEtBQUssQ0FBQyxXQUFXLEtBQUssUUFBUSxFQUFFO1FBQ2xDLE1BQU0sZUFBZSxDQUFDLFFBQVEsRUFBRSxlQUFlLEVBQUUsWUFBWSxDQUFDLENBQUM7UUFDL0QsT0FBTyxFQUFFLGtCQUFrQixFQUFFLHFCQUFjLENBQUMsUUFBUSxFQUFFLFlBQVksRUFBRSxLQUFLLENBQUMsU0FBUyxDQUFDLEVBQUUsQ0FBQztLQUN4RjtTQUFNLElBQUksS0FBSyxDQUFDLFdBQVcsS0FBSyxRQUFRLEVBQUU7UUFDekMsTUFBTSxnQkFBZ0IsQ0FBQyxRQUFRLEVBQUUsZUFBZSxFQUFFLFlBQVksQ0FBQyxDQUFDO1FBQ2hFLE9BQU87S0FDUjtTQUFNLElBQUksS0FBSyxDQUFDLFdBQVcsS0FBSyxRQUFRLEVBQUU7UUFDekMsTUFBTSxFQUFFLE9BQU8sRUFBRSxHQUFHLE1BQU0sZ0JBQWdCLENBQ3hDLFFBQVEsRUFDUixlQUFlLEVBQ2YsWUFBWSxFQUNaLEtBQUssQ0FBQyxx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B7IHJlcGxhY2U6IGZhbHNlIH07XG59XG4iXX0= \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.169a8c0beb97c903ee155ea9653e39b0884c9e3b860ac72ffbe906b3c1f4e338/redshift-data.js b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.169a8c0beb97c903ee155ea9653e39b0884c9e3b860ac72ffbe906b3c1f4e338/redshift-data.js deleted file mode 100644 index e65374f4ab7e0..0000000000000 --- a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.169a8c0beb97c903ee155ea9653e39b0884c9e3b860ac72ffbe906b3c1f4e338/redshift-data.js +++ /dev/null @@ -1,37 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.executeStatement = void 0; -/* eslint-disable-next-line import/no-extraneous-dependencies */ -const RedshiftData = require("aws-sdk/clients/redshiftdata"); -const redshiftData = new RedshiftData(); -async function executeStatement(statement, clusterProps) { - const executeStatementProps = { - ClusterIdentifier: clusterProps.clusterName, - Database: clusterProps.databaseName, - SecretArn: clusterProps.adminUserArn, - Sql: statement, - }; - const executedStatement = await redshiftData.executeStatement(executeStatementProps).promise(); - if (!executedStatement.Id) { - throw new Error('Service error: Statement execution did not return a statement ID'); - } - await waitForStatementComplete(executedStatement.Id); -} -exports.executeStatement = executeStatement; -const waitTimeout = 100; -async function waitForStatementComplete(statementId) { - await new Promise((resolve) => { - setTimeout(() => resolve(), waitTimeout); - }); - const statement = await redshiftData.describeStatement({ Id: statementId }).promise(); - if (statement.Status !== 'FINISHED' && statement.Status !== 'FAILED' && statement.Status !== 'ABORTED') { - return waitForStatementComplete(statementId); - } - else if (statement.Status === 'FINISHED') { - return; - } - else { - throw new Error(`Statement status was ${statement.Status}: ${statement.Error}`); - } -} -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVkc2hpZnQtZGF0YS5qcyIsInNvdXJjZVJvb3QiOiIiL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yAhPT0gJ0FCT1JURUQnKSB7XG4gICAgcmV0dXJuIHdhaXRGb3JTdGF0ZW1lbnRDb21wbGV0ZShzdGF0ZW1lbnRJZCk7XG4gIH0gZWxzZSBpZiAoc3RhdGVtZW50LlN0YXR1cyA9PT0gJ0ZJTklTSEVEJykge1xuICAgIHJldHVybjtcbiAgfSBlbHNlIHtcbiAgICB0aHJvdyBuZXcgRXJyb3IoYFN0YXRlbWVudCBzdGF0dXMgd2FzICR7c3RhdGVtZW50LlN0YXR1c306ICR7c3RhdGVtZW50LkVycm9yfWApO1xuICB9XG59XG4iXX0= \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.169a8c0beb97c903ee155ea9653e39b0884c9e3b860ac72ffbe906b3c1f4e338/table.js b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.169a8c0beb97c903ee155ea9653e39b0884c9e3b860ac72ffbe906b3c1f4e338/table.js deleted file mode 100644 index e31afe4b9ef0b..0000000000000 --- a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.169a8c0beb97c903ee155ea9653e39b0884c9e3b860ac72ffbe906b3c1f4e338/table.js +++ /dev/null @@ -1,148 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.handler = void 0; -const redshift_data_1 = require("./redshift-data"); -const types_1 = require("./types"); -const util_1 = require("./util"); -async function handler(props, event) { - const tableNamePrefix = props.tableName.prefix; - const tableNameSuffix = props.tableName.generateSuffix === 'true' ? `${event.RequestId.substring(0, 8)}` : ''; - const tableColumns = props.tableColumns; - const tableAndClusterProps = props; - const useColumnIds = props.useColumnIds; - if (event.RequestType === 'Create') { - const tableName = await createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps); - return { PhysicalResourceId: tableName }; - } - else if (event.RequestType === 'Delete') { - await dropTable(event.PhysicalResourceId, tableAndClusterProps); - return; - } - else if (event.RequestType === 'Update') { - const tableName = await updateTable(event.PhysicalResourceId, tableNamePrefix, tableNameSuffix, tableColumns, useColumnIds, tableAndClusterProps, event.OldResourceProperties); - return { PhysicalResourceId: tableName }; - } - else { - /* eslint-disable-next-line dot-notation */ - throw new Error(`Unrecognized event type: ${event['RequestType']}`); - } -} -exports.handler = handler; -async function createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps) { - const tableName = tableNamePrefix + tableNameSuffix; - const tableColumnsString = tableColumns.map(column => `${column.name} ${column.dataType}`).join(); - let statement = `CREATE TABLE ${tableName} (${tableColumnsString})`; - if (tableAndClusterProps.distStyle) { - statement += ` DISTSTYLE ${tableAndClusterProps.distStyle}`; - } - const distKeyColumn = util_1.getDistKeyColumn(tableColumns); - if (distKeyColumn) { - statement += ` DISTKEY(${distKeyColumn.name})`; - } - const sortKeyColumns = util_1.getSortKeyColumns(tableColumns); - if (sortKeyColumns.length > 0) { - const sortKeyColumnsString = getSortKeyColumnsString(sortKeyColumns); - statement += ` ${tableAndClusterProps.sortStyle} SORTKEY(${sortKeyColumnsString})`; - } - await redshift_data_1.executeStatement(statement, tableAndClusterProps); - if (tableAndClusterProps.tableComment) { - await redshift_data_1.executeStatement(`COMMENT ON TABLE ${tableName} IS '${tableAndClusterProps.tableComment}'`, tableAndClusterProps); - } - return tableName; -} -async function dropTable(tableName, clusterProps) { - await redshift_data_1.executeStatement(`DROP TABLE ${tableName}`, clusterProps); -} -async function updateTable(tableName, tableNamePrefix, tableNameSuffix, tableColumns, useColumnIds, tableAndClusterProps, oldResourceProperties) { - const alterationStatements = []; - const oldClusterProps = oldResourceProperties; - if (tableAndClusterProps.clusterName !== oldClusterProps.clusterName || tableAndClusterProps.databaseName !== oldClusterProps.databaseName) { - return createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps); - } - const oldTableNamePrefix = oldResourceProperties.tableName.prefix; - if (tableNamePrefix !== oldTableNamePrefix) { - return createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps); - } - const oldTableColumns = oldResourceProperties.tableColumns; - const columnDeletions = oldTableColumns.filter(oldColumn => (tableColumns.every(column => { - if (useColumnIds) { - return oldColumn.id ? oldColumn.id !== column.id : oldColumn.name !== column.name; - } - return oldColumn.name !== column.name; - }))); - if (columnDeletions.length > 0) { - alterationStatements.push(...columnDeletions.map(column => `ALTER TABLE ${tableName} DROP COLUMN ${column.name}`)); - } - const columnAdditions = tableColumns.filter(column => { - return !oldTableColumns.some(oldColumn => { - if (useColumnIds) { - return oldColumn.id ? oldColumn.id === column.id : oldColumn.name === column.name; - } - return oldColumn.name === column.name; - }); - }).map(column => `ADD ${column.name} ${column.dataType}`); - if (columnAdditions.length > 0) { - alterationStatements.push(...columnAdditions.map(addition => `ALTER TABLE ${tableName} ${addition}`)); - } - if (useColumnIds) { - const columnNameUpdates = tableColumns.reduce((updates, column) => { - const oldColumn = oldTableColumns.find(oldCol => oldCol.id && oldCol.id === column.id); - if (oldColumn && oldColumn.name !== column.name) { - updates[oldColumn.name] = column.name; - } - return updates; - }, {}); - if (Object.keys(columnNameUpdates).length > 0) { - alterationStatements.push(...Object.entries(columnNameUpdates).map(([oldName, newName]) => (`ALTER TABLE ${tableName} RENAME COLUMN ${oldName} TO ${newName}`))); - } - } - const oldDistStyle = oldResourceProperties.distStyle; - if ((!oldDistStyle && tableAndClusterProps.distStyle) || - (oldDistStyle && !tableAndClusterProps.distStyle)) { - return createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps); - } - else if (oldDistStyle !== tableAndClusterProps.distStyle) { - alterationStatements.push(`ALTER TABLE ${tableName} ALTER DISTSTYLE ${tableAndClusterProps.distStyle}`); - } - const oldDistKey = util_1.getDistKeyColumn(oldTableColumns)?.name; - const newDistKey = util_1.getDistKeyColumn(tableColumns)?.name; - if ((!oldDistKey && newDistKey) || (oldDistKey && !newDistKey)) { - return createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps); - } - else if (oldDistKey !== newDistKey) { - alterationStatements.push(`ALTER TABLE ${tableName} ALTER DISTKEY ${newDistKey}`); - } - const oldSortKeyColumns = util_1.getSortKeyColumns(oldTableColumns); - const newSortKeyColumns = util_1.getSortKeyColumns(tableColumns); - const oldSortStyle = oldResourceProperties.sortStyle; - const newSortStyle = tableAndClusterProps.sortStyle; - if ((oldSortStyle === newSortStyle && !util_1.areColumnsEqual(oldSortKeyColumns, newSortKeyColumns)) - || (oldSortStyle !== newSortStyle)) { - switch (newSortStyle) { - case types_1.TableSortStyle.INTERLEAVED: - // INTERLEAVED sort key addition requires replacement. - // https://docs.aws.amazon.com/redshift/latest/dg/r_ALTER_TABLE.html - return createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps); - case types_1.TableSortStyle.COMPOUND: { - const sortKeyColumnsString = getSortKeyColumnsString(newSortKeyColumns); - alterationStatements.push(`ALTER TABLE ${tableName} ALTER ${newSortStyle} SORTKEY(${sortKeyColumnsString})`); - break; - } - case types_1.TableSortStyle.AUTO: { - alterationStatements.push(`ALTER TABLE ${tableName} ALTER SORTKEY ${newSortStyle}`); - break; - } - } - } - const oldComment = oldResourceProperties.tableComment; - const newComment = tableAndClusterProps.tableComment; - if (oldComment !== newComment) { - alterationStatements.push(`COMMENT ON TABLE ${tableName} IS ${newComment ? `'${newComment}'` : 'NULL'}`); - } - await Promise.all(alterationStatements.map(statement => redshift_data_1.executeStatement(statement, tableAndClusterProps))); - return tableName; -} -function getSortKeyColumnsString(sortKeyColumns) { - return sortKeyColumns.map(column => column.name).join(); -} -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFibGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJ0YWJsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFFQSxtREFBbUQ7QUFDbkQsbUNBQTZFO0FBQzdFLGlDQUE4RTtBQUd2RSxLQUFLLFVBQVUsT0FBTyxDQUFDLEtBQTJCLEVBQUUsS0FBa0Q7SUFDM0csTU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5Q29sdW1uc1N0cmluZ30pYCk7XG4gICAgICAgIGJyZWFrO1xuICAgICAgfVxuXG4gICAgICBjYXNlIFRhYmxlU29ydFN0eWxlLkFVVE86IHtcbiAgICAgICAgYWx0ZXJhdGlvblN0YXRlbWVudHMucHVzaChgQUxURVIgVEFCTEUgJHt0YWJsZU5hbWV9IEFMVEVSIFNPUlRLRVkgJHtuZXdTb3J0U3R5bGV9YCk7XG4gICAgICAgIGJyZWFrO1xuICAgICAgfVxuICAgIH1cbiAgfVxuXG4gIGNvbnN0IG9sZENvbW1lbnQgPSBvbGRSZXNvdXJjZVByb3BlcnRpZXMudGFibGVDb21tZW50O1xuICBjb25zdCBuZXdDb21tZW50ID0gdGFibGVBbmRDbHVzdGVyUHJvcHMudGFibGVDb21tZW50O1xuICBpZiAob2xkQ29tbWVudCAhPT0gbmV3Q29tbWVudCkge1xuICAgIGFsdGVyYXRpb25TdGF0ZW1lbnRzLnB1c2goYENPTU1FTlQgT04gVEFCTEUgJHt0YWJsZU5hbWV9IElTICR7bmV3Q29tbWVudCA/IGAnJHtuZXdDb21tZW50fSdgIDogJ05VTEwnfWApO1xuICB9XG5cbiAgYXdhaXQgUHJvbWlzZS5hbGwoYWx0ZXJhdGlvblN0YXRlbWVudHMubWFwKHN0YXRlbWVudCA9PiBleGVjdXRlU3RhdGVtZW50KHN0YXRlbWVudCwgdGFibGVBbmRDbHVzdGVyUHJvcHMpKSk7XG5cbiAgcmV0dXJuIHRhYmxlTmFtZTtcbn1cblxuZnVuY3Rpb24gZ2V0U29ydEtleUNvbHVtbnNTdHJpbmcoc29ydEtleUNvbHVtbnM6IENvbHVtbltdKSB7XG4gIHJldHVybiBzb3J0S2V5Q29sdW1ucy5tYXAoY29sdW1uID0+IGNvbHVtbi5uYW1lKS5qb2luKCk7XG59XG4iXX0= \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.169a8c0beb97c903ee155ea9653e39b0884c9e3b860ac72ffbe906b3c1f4e338/types.js b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.169a8c0beb97c903ee155ea9653e39b0884c9e3b860ac72ffbe906b3c1f4e338/types.js deleted file mode 100644 index 070bb11c1600e..0000000000000 --- a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.169a8c0beb97c903ee155ea9653e39b0884c9e3b860ac72ffbe906b3c1f4e338/types.js +++ /dev/null @@ -1,24 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.TableSortStyle = void 0; -/** - * The sort style of a table. - * This has been duplicated here to exporting private types. - */ -var TableSortStyle; -(function (TableSortStyle) { - /** - * Amazon Redshift assigns an optimal sort key based on the table data. - */ - TableSortStyle["AUTO"] = "AUTO"; - /** - * Specifies that the data is sorted using a compound key made up of all of the listed columns, - * in the order they are listed. - */ - TableSortStyle["COMPOUND"] = "COMPOUND"; - /** - * Specifies that the data is sorted using an interleaved sort key. - */ - TableSortStyle["INTERLEAVED"] = "INTERLEAVED"; -})(TableSortStyle = exports.TableSortStyle || (exports.TableSortStyle = {})); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJ0eXBlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFLQTs7O0dBR0c7QUFDSCxJQUFZLGNBZ0JYO0FBaEJELFdBQVksY0FBYztJQUN4Qjs7T0FFRztJQUNILCtCQUFhLENBQUE7SUFFYjs7O09BR0c7SUFDSCx1Q0FBcUIsQ0FBQTtJQUVyQjs7T0FFRztJQUNILDZDQUEyQixDQUFBO0FBQzdCLENBQUMsRUFoQlcsY0FBYyxHQUFkLHNCQUFjLEtBQWQsc0JBQWMsUUFnQnpCIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgRGF0YWJhc2VRdWVyeUhhbmRsZXJQcm9wcywgVGFibGVIYW5kbGVyUHJvcHMgfSBmcm9tICcuLi9oYW5kbGVyLXByb3BzJztcblxuZXhwb3J0IHR5cGUgQ2x1c3RlclByb3BzID0gT21pdDxEYXRhYmFzZVF1ZXJ5SGFuZGxlclByb3BzLCAnaGFuZGxlcic+O1xuZXhwb3J0IHR5cGUgVGFibGVBbmRDbHVzdGVyUHJvcHMgPSBUYWJsZUhhbmRsZXJQcm9wcyAmIENsdXN0ZXJQcm9wcztcblxuLyoqXG4gKiBUaGUgc29ydCBzdHlsZSBvZiBhIHRhYmxlLlxuICogVGhpcyBoYXMgYmVlbiBkdXBsaWNhdGVkIGhlcmUgdG8gZXhwb3J0aW5nIHByaXZhdGUgdHlwZXMuXG4gKi9cbmV4cG9ydCBlbnVtIFRhYmxlU29ydFN0eWxlIHtcbiAgLyoqXG4gICAqIEFtYXpvbiBSZWRzaGlmdCBhc3NpZ25zIGFuIG9wdGltYWwgc29ydCBrZXkgYmFzZWQgb24gdGhlIHRhYmxlIGRhdGEuXG4gICAqL1xuICBBVVRPID0gJ0FVVE8nLFxuXG4gIC8qKlxuICAgKiBTcGVjaWZpZXMgdGhhdCB0aGUgZGF0YSBpcyBzb3J0ZWQgdXNpbmcgYSBjb21wb3VuZCBrZXkgbWFkZSB1cCBvZiBhbGwgb2YgdGhlIGxpc3RlZCBjb2x1bW5zLFxuICAgKiBpbiB0aGUgb3JkZXIgdGhleSBhcmUgbGlzdGVkLlxuICAgKi9cbiAgQ09NUE9VTkQgPSAnQ09NUE9VTkQnLFxuXG4gIC8qKlxuICAgKiBTcGVjaWZpZXMgdGhhdCB0aGUgZGF0YSBpcyBzb3J0ZWQgdXNpbmcgYW4gaW50ZXJsZWF2ZWQgc29ydCBrZXkuXG4gICAqL1xuICBJTlRFUkxFQVZFRCA9ICdJTlRFUkxFQVZFRCcsXG59XG4iXX0= \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.169a8c0beb97c903ee155ea9653e39b0884c9e3b860ac72ffbe906b3c1f4e338/user.js b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.169a8c0beb97c903ee155ea9653e39b0884c9e3b860ac72ffbe906b3c1f4e338/user.js deleted file mode 100644 index f097ae1836462..0000000000000 --- a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.169a8c0beb97c903ee155ea9653e39b0884c9e3b860ac72ffbe906b3c1f4e338/user.js +++ /dev/null @@ -1,70 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.handler = void 0; -/* eslint-disable-next-line import/no-extraneous-dependencies */ -const SecretsManager = require("aws-sdk/clients/secretsmanager"); -const redshift_data_1 = require("./redshift-data"); -const util_1 = require("./util"); -const secretsManager = new SecretsManager(); -async function handler(props, event) { - const username = props.username; - const passwordSecretArn = props.passwordSecretArn; - const clusterProps = props; - if (event.RequestType === 'Create') { - await createUser(username, passwordSecretArn, clusterProps); - return { PhysicalResourceId: util_1.makePhysicalId(username, clusterProps, event.RequestId), Data: { username: username } }; - } - else if (event.RequestType === 'Delete') { - await dropUser(username, clusterProps); - return; - } - else if (event.RequestType === 'Update') { - const { replace } = await updateUser(username, passwordSecretArn, clusterProps, event.OldResourceProperties); - const physicalId = replace ? util_1.makePhysicalId(username, clusterProps, event.RequestId) : event.PhysicalResourceId; - return { PhysicalResourceId: physicalId, Data: { username: username } }; - } - else { - /* eslint-disable-next-line dot-notation */ - throw new Error(`Unrecognized event type: ${event['RequestType']}`); - } -} -exports.handler = handler; -async function dropUser(username, clusterProps) { - await redshift_data_1.executeStatement(`DROP USER ${username}`, clusterProps); -} -async function createUser(username, passwordSecretArn, clusterProps) { - const password = await getPasswordFromSecret(passwordSecretArn); - await redshift_data_1.executeStatement(`CREATE USER ${username} PASSWORD '${password}'`, clusterProps); -} -async function updateUser(username, passwordSecretArn, clusterProps, oldResourceProperties) { - const oldClusterProps = oldResourceProperties; - if (clusterProps.clusterName !== oldClusterProps.clusterName || clusterProps.databaseName !== oldClusterProps.databaseName) { - await createUser(username, passwordSecretArn, clusterProps); - return { replace: true }; - } - const oldUsername = oldResourceProperties.username; - const oldPasswordSecretArn = oldResourceProperties.passwordSecretArn; - const oldPassword = await getPasswordFromSecret(oldPasswordSecretArn); - const password = await getPasswordFromSecret(passwordSecretArn); - if (username !== oldUsername) { - await createUser(username, passwordSecretArn, clusterProps); - return { replace: true }; - } - if (password !== oldPassword) { - await redshift_data_1.executeStatement(`ALTER USER ${username} PASSWORD '${password}'`, clusterProps); - return { replace: false }; - } - return { replace: false }; -} -async function getPasswordFromSecret(passwordSecretArn) { - const secretValue = await secretsManager.getSecretValue({ - SecretId: passwordSecretArn, - }).promise(); - const secretString = secretValue.SecretString; - if (!secretString) { - throw new Error(`Secret string for ${passwordSecretArn} was empty`); - } - const { password } = JSON.parse(secretString); - return password; -} -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXNlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInVzZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBRUEsZ0VBQWdFO0FBQ2hFLGlFQUFpRTtBQUNqRSxtREFBbUQ7QUFFbkQsaUNBQXdDO0FBR3hDLE1BQU0sY0FBYyxHQUFHLElBQUksY0FBYyxFQUFFLENBQUM7QUFFckMsS0FBSyxVQUFVLE9BQU8sQ0FBQyxLQUFzQyxFQUFFLEtBQWtEO0lBQ3RILE1BQU0sUUFBUSxHQUFHLEtBQUssQ0FBQyxRQUFRLENBQUM7SUFDaEMsTUFBTSxpQkFBaUIsR0FBRyxLQUFLLENBQUMsaUJBQWlCLENBQUM7SUFDbEQsTUFBTSxZQUFZLEdBQUcsS0FBSyxDQUFDO0lBRTNCLElBQUksS0FBSyxDQUFDLFdBQVcsS0FBSyxRQUFRLEVBQUU7UUFDbEMsTUFBTSxVQUFVLENBQUMsUUFBUSxFQUFFLGlCQUFpQixFQUFFLFlBQVksQ0FBQyxDQUFDO1FBQzVELE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FN0cmluZykge1xuICAgIHRocm93IG5ldyBFcnJvcihgU2VjcmV0IHN0cmluZyBmb3IgJHtwYXNzd29yZFNlY3JldEFybn0gd2FzIGVtcHR5YCk7XG4gIH1cbiAgY29uc3QgeyBwYXNzd29yZCB9ID0gSlNPTi5wYXJzZShzZWNyZXRTdHJpbmcpO1xuXG4gIHJldHVybiBwYXNzd29yZDtcbn1cbiJdfQ== \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.169a8c0beb97c903ee155ea9653e39b0884c9e3b860ac72ffbe906b3c1f4e338/util.js b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.169a8c0beb97c903ee155ea9653e39b0884c9e3b860ac72ffbe906b3c1f4e338/util.js deleted file mode 100644 index d8dc8cad799c9..0000000000000 --- a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.169a8c0beb97c903ee155ea9653e39b0884c9e3b860ac72ffbe906b3c1f4e338/util.js +++ /dev/null @@ -1,34 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.areColumnsEqual = exports.getSortKeyColumns = exports.getDistKeyColumn = exports.makePhysicalId = void 0; -function makePhysicalId(resourceName, clusterProps, requestId) { - return `${clusterProps.clusterName}:${clusterProps.databaseName}:${resourceName}:${requestId}`; -} -exports.makePhysicalId = makePhysicalId; -function getDistKeyColumn(columns) { - // string comparison is required for custom resource since everything is passed as string - const distKeyColumns = columns.filter(column => column.distKey === true || column.distKey === 'true'); - if (distKeyColumns.length === 0) { - return undefined; - } - else if (distKeyColumns.length > 1) { - throw new Error('Multiple dist key columns found'); - } - return distKeyColumns[0]; -} -exports.getDistKeyColumn = getDistKeyColumn; -function getSortKeyColumns(columns) { - // string comparison is required for custom resource since everything is passed as string - return columns.filter(column => column.sortKey === true || column.sortKey === 'true'); -} -exports.getSortKeyColumns = getSortKeyColumns; -function areColumnsEqual(columnsA, columnsB) { - if (columnsA.length !== columnsB.length) { - return false; - } - return columnsA.every(columnA => { - return columnsB.find(column => column.name === columnA.name && column.dataType === columnA.dataType); - }); -} -exports.areColumnsEqual = areColumnsEqual; -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInV0aWwudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBR0EsU0FBZ0IsY0FBYyxDQUFDLFlBQW9CLEVBQUUsWUFBMEIsRUFBRSxTQUFpQjtJQUNoRyxPQUFPLEdBQUcsWUFBWSxDQUFDLFdBQVcsSUFBSSxZQUFZLENBQUMsWUFBWSxJQUFJLFlBQVksSUFBSSxTQUFTLEVBQUUsQ0FBQztBQUNqRyxDQUFDO0FBRkQsd0NBRUM7QUFFRCxTQUFnQixnQkFBZ0IsQ0FBQyxPQUFpQjtJQUNoRCx5RkFBeUY7SUFDekYsTUFBTSxjQUFjLEdBQUcsT0FBTyxDQUFDLE1BQU0sQ0FBQyxNQUFNLENBQUMsRUFBRSxDQUFDLE1BQU0sQ0FBQyxPQUFPLEtBQUssSUFBSSxJQUFLLE1BQU0sQ0FBQyxPQUE2QixLQUFLLE1BQU0sQ0FBQyxDQUFDO0lBRTdILElBQUksY0FBYyxDQUFDLE1BQU0sS0FBSyxDQUFDLEVBQUU7UUFDL0IsT0FBTyxTQUFTLENBQUM7S0FDbEI7U0FBTSxJQUFJLGNBQWMsQ0FBQyxNQUFNLEdBQUcsQ0FBQyxFQUFFO1FBQ3BDLE1BQU0sSUFBSSxLQUFLLENBQUMsaUNBQWlDLENBQUMsQ0FBQztLQUNwRDtJQUVELE9BQU8sY0FBYyxDQUFDLENBQUMsQ0FBQyxDQUFDO0FBQzNCLENBQUM7QUFYRCw0Q0FXQztBQUVELFNBQWdCLGlCQUFpQixDQUFDLE9BQWlCO0lBQ2pELHlGQUF5RjtJQUN6RixPQUFPLE9BQU8sQ0FBQyxNQUFNLENBQUMs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Y29sdW1uc0I6IENvbHVtbltdKTogYm9vbGVhbiB7XG4gIGlmIChjb2x1bW5zQS5sZW5ndGggIT09IGNvbHVtbnNCLmxlbmd0aCkge1xuICAgIHJldHVybiBmYWxzZTtcbiAgfVxuICByZXR1cm4gY29sdW1uc0EuZXZlcnkoY29sdW1uQSA9PiB7XG4gICAgcmV0dXJuIGNvbHVtbnNCLmZpbmQoY29sdW1uID0+IGNvbHVtbi5uYW1lID09PSBjb2x1bW5BLm5hbWUgJiYgY29sdW1uLmRhdGFUeXBlID09PSBjb2x1bW5BLmRhdGFUeXBlKTtcbiAgfSk7XG59XG4iXX0= \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.847e15feeb180b356ab9a8094d8b9459ea8ec26fc27957794d583ed9eb3a79d8/handler-name.js b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.847e15feeb180b356ab9a8094d8b9459ea8ec26fc27957794d583ed9eb3a79d8/handler-name.js deleted file mode 100644 index 4983115a93834..0000000000000 --- a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.847e15feeb180b356ab9a8094d8b9459ea8ec26fc27957794d583ed9eb3a79d8/handler-name.js +++ /dev/null @@ -1,10 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.HandlerName = void 0; -var HandlerName; -(function (HandlerName) { - HandlerName["User"] = "user"; - HandlerName["Table"] = "table"; - HandlerName["UserTablePrivileges"] = "user-table-privileges"; -})(HandlerName = exports.HandlerName || (exports.HandlerName = {})); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGFuZGxlci1uYW1lLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiaGFuZGxlci1uYW1lLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLElBQVksV0FJWDtBQUpELFdBQVksV0FBVztJQUNyQiw0QkFBYSxDQUFBO0lBQ2IsOEJBQWUsQ0FBQTtJQUNmLDREQUE2QyxDQUFBO0FBQy9DLENBQUMsRUFKVyxXQUFXLEdBQVgsbUJBQVcsS0FBWCxtQkFBVyxRQUl0QiIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBlbnVtIEhhbmRsZXJOYW1lIHtcbiAgVXNlciA9ICd1c2VyJyxcbiAgVGFibGUgPSAndGFibGUnLFxuICBVc2VyVGFibGVQcml2aWxlZ2VzID0gJ3VzZXItdGFibGUtcHJpdmlsZWdlcycsXG59XG4iXX0= \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.847e15feeb180b356ab9a8094d8b9459ea8ec26fc27957794d583ed9eb3a79d8/index.js b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.847e15feeb180b356ab9a8094d8b9459ea8ec26fc27957794d583ed9eb3a79d8/index.js deleted file mode 100644 index d91935764b9bf..0000000000000 --- a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.847e15feeb180b356ab9a8094d8b9459ea8ec26fc27957794d583ed9eb3a79d8/index.js +++ /dev/null @@ -1,23 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.handler = void 0; -const handler_name_1 = require("./handler-name"); -const privileges_1 = require("./privileges"); -const table_1 = require("./table"); -const user_1 = require("./user"); -const HANDLERS = { - [handler_name_1.HandlerName.Table]: table_1.handler, - [handler_name_1.HandlerName.User]: user_1.handler, - [handler_name_1.HandlerName.UserTablePrivileges]: privileges_1.handler, -}; -async function handler(event) { - const subHandler = HANDLERS[event.ResourceProperties.handler]; - if (!subHandler) { - throw new Error(`Requested handler ${event.ResourceProperties.handler} is not in supported set: ${JSON.stringify(Object.keys(HANDLERS))}`); - } - return subHandler(event.ResourceProperties, event); -} -exports.handler = handler; -var types_1 = require("./types"); -Object.defineProperty(exports, "ColumnEncoding", { enumerable: true, get: function () { return types_1.ColumnEncoding; } }); -//# sourceMappingURL=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E9iamVjdC5rZXlzKEhBTkRMRVJTKSl9YCk7XG4gIH1cbiAgcmV0dXJuIHN1YkhhbmRsZXIoZXZlbnQuUmVzb3VyY2VQcm9wZXJ0aWVzLCBldmVudCk7XG59XG5cbmV4cG9ydCB7IENvbHVtbkVuY29kaW5nIH0gZnJvbSAnLi90eXBlcyc7XG4iXX0= \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.847e15feeb180b356ab9a8094d8b9459ea8ec26fc27957794d583ed9eb3a79d8/privileges.js b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.847e15feeb180b356ab9a8094d8b9459ea8ec26fc27957794d583ed9eb3a79d8/privileges.js deleted file mode 100644 index 8770142deb498..0000000000000 --- a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.847e15feeb180b356ab9a8094d8b9459ea8ec26fc27957794d583ed9eb3a79d8/privileges.js +++ /dev/null @@ -1,58 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.handler = void 0; -const redshift_data_1 = require("./redshift-data"); -const util_1 = require("./util"); -async function handler(props, event) { - const username = props.username; - const tablePrivileges = props.tablePrivileges; - const clusterProps = props; - if (event.RequestType === 'Create') { - await grantPrivileges(username, tablePrivileges, clusterProps); - return { PhysicalResourceId: util_1.makePhysicalId(username, clusterProps, event.RequestId) }; - } - else if (event.RequestType === 'Delete') { - await revokePrivileges(username, tablePrivileges, clusterProps); - return; - } - else if (event.RequestType === 'Update') { - const { replace } = await updatePrivileges(username, tablePrivileges, clusterProps, event.OldResourceProperties); - const physicalId = replace ? util_1.makePhysicalId(username, clusterProps, event.RequestId) : event.PhysicalResourceId; - return { PhysicalResourceId: physicalId }; - } - else { - /* eslint-disable-next-line dot-notation */ - throw new Error(`Unrecognized event type: ${event['RequestType']}`); - } -} -exports.handler = handler; -async function revokePrivileges(username, tablePrivileges, clusterProps) { - await Promise.all(tablePrivileges.map(({ tableName, actions }) => { - return redshift_data_1.executeStatement(`REVOKE ${actions.join(', ')} ON ${tableName} FROM ${username}`, clusterProps); - })); -} -async function grantPrivileges(username, tablePrivileges, clusterProps) { - await Promise.all(tablePrivileges.map(({ tableName, actions }) => { - return redshift_data_1.executeStatement(`GRANT ${actions.join(', ')} ON ${tableName} TO ${username}`, clusterProps); - })); -} -async function updatePrivileges(username, tablePrivileges, clusterProps, oldResourceProperties) { - const oldClusterProps = oldResourceProperties; - if (clusterProps.clusterName !== oldClusterProps.clusterName || clusterProps.databaseName !== oldClusterProps.databaseName) { - await grantPrivileges(username, tablePrivileges, clusterProps); - return { replace: true }; - } - const oldUsername = oldResourceProperties.username; - if (oldUsername !== username) { - await grantPrivileges(username, tablePrivileges, clusterProps); - return { replace: true }; - } - const oldTablePrivileges = oldResourceProperties.tablePrivileges; - if (oldTablePrivileges !== tablePrivileges) { - await revokePrivileges(username, oldTablePrivileges, clusterProps); - await grantPrivileges(username, tablePrivileges, clusterProps); - return { replace: false }; - } - return { replace: false }; -} -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJpdmlsZWdlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInByaXZpbGVnZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBRUEsbURBQW1EO0FBRW5ELGlDQUF3QztBQUdqQyxLQUFLLFVBQVUsT0FBTyxDQUFDLEtBQXFELEVBQUUsS0FBa0Q7SUFDckksTUFBTSxRQUFRLEdBQUcsS0FBSyxDQUFDLFFBQVEsQ0FBQztJQUNoQyxNQUFNLGVBQWUsR0FBRyxLQUFLLENBQUMsZUFBZSxDQUFDO0lBQzlDLE1BQU0sWUFBWSxHQUFHLEtBQUssQ0FBQztJQUUzQixJQUFJLEtBQUssQ0FBQyxXQUFXLEtBQUssUUFBUSxFQUFFO1FBQ2xDLE1BQU0sZUFBZSxDQUFDLFFBQVEsRUFBRSxlQUFlLEVBQUUsWUFBW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cywgY2x1c3RlclByb3BzKTtcbiAgICByZXR1cm4geyByZXBsYWNlOiB0cnVlIH07XG4gIH1cblxuICBjb25zdCBvbGRUYWJsZVByaXZpbGVnZXMgPSBvbGRSZXNvdXJjZVByb3BlcnRpZXMudGFibGVQcml2aWxlZ2VzO1xuICBpZiAob2xkVGFibGVQcml2aWxlZ2VzICE9PSB0YWJsZVByaXZpbGVnZXMpIHtcbiAgICBhd2FpdCByZXZva2VQcml2aWxlZ2VzKHVzZXJuYW1lLCBvbGRUYWJsZVByaXZpbGVnZXMsIGNsdXN0ZXJQcm9wcyk7XG4gICAgYXdhaXQgZ3JhbnRQcml2aWxlZ2VzKHVzZXJuYW1lLCB0YWJsZVByaXZpbGVnZXMsIGNsdXN0ZXJQcm9wcyk7XG4gICAgcmV0dXJuIHsgcmVwbGFjZTogZmFsc2UgfTtcbiAgfVxuXG4gIHJldHVybiB7IHJlcGxhY2U6IGZhbHNlIH07XG59XG4iXX0= \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.847e15feeb180b356ab9a8094d8b9459ea8ec26fc27957794d583ed9eb3a79d8/redshift-data.js b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.847e15feeb180b356ab9a8094d8b9459ea8ec26fc27957794d583ed9eb3a79d8/redshift-data.js deleted file mode 100644 index e65374f4ab7e0..0000000000000 --- a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.847e15feeb180b356ab9a8094d8b9459ea8ec26fc27957794d583ed9eb3a79d8/redshift-data.js +++ /dev/null @@ -1,37 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.executeStatement = void 0; -/* eslint-disable-next-line import/no-extraneous-dependencies */ -const RedshiftData = require("aws-sdk/clients/redshiftdata"); -const redshiftData = new RedshiftData(); -async function executeStatement(statement, clusterProps) { - const executeStatementProps = { - ClusterIdentifier: clusterProps.clusterName, - Database: clusterProps.databaseName, - SecretArn: clusterProps.adminUserArn, - Sql: statement, - }; - const executedStatement = await redshiftData.executeStatement(executeStatementProps).promise(); - if (!executedStatement.Id) { - throw new Error('Service error: Statement execution did not return a statement ID'); - } - await waitForStatementComplete(executedStatement.Id); -} -exports.executeStatement = executeStatement; -const waitTimeout = 100; -async function waitForStatementComplete(statementId) { - await new Promise((resolve) => { - setTimeout(() => resolve(), waitTimeout); - }); - const statement = await redshiftData.describeStatement({ Id: statementId }).promise(); - if (statement.Status !== 'FINISHED' && statement.Status !== 'FAILED' && statement.Status !== 'ABORTED') { - return waitForStatementComplete(statementId); - } - else if (statement.Status === 'FINISHED') { - return; - } - else { - throw new Error(`Statement status was ${statement.Status}: ${statement.Error}`); - } -} -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVkc2hpZnQtZGF0YS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInJlZHNoaWZ0LWRhdGEudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsZ0VBQWdFO0FBQ2hFLDZEQUE2RDtBQUc3RCxNQUFNLFlBQVksR0FBRyxJQUFJLFlBQVksRUFBRSxDQUFDO0FBRWpDLEtBQUssVUFBVSxnQkFBZ0IsQ0FBQyxTQUFpQixFQUFFLFlBQTBCO0lBQ2xGLE1BQU0scUJBQXFCLEdBQUc7UUFDNUIsaUJBQWlCLEVBQUUsWUFBWSxDQUFDLFdBQVc7UUFDM0MsUUFBUSxFQUFFLFlBQVksQ0FBQyxZQUFZO1FBQ25DLFNBQVMsRUFBRSxZQUFZLENBQUMsWUFBWTtRQUNwQyxHQUFHLEVBQUUsU0FBUztLQUNmLENBQUM7SUFDRixNQUFNLGlCQUFpQixHQUFHLE1BQU0sWUFBWSxDQUFDLGdCQUFnQixDQUFDLHFCQUFxQixDQUFDLENBQUMsT0FBTyxFQUFFLENBQUM7SUFDL0YsSUFBSSxDQUFDLGlCQUFpQixDQUFDLEVBQUUsRUFBR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haXRGb3JTdGF0ZW1lbnRDb21wbGV0ZShzdGF0ZW1lbnRJZDogc3RyaW5nKTogUHJvbWlzZTx2b2lkPiB7XG4gIGF3YWl0IG5ldyBQcm9taXNlKChyZXNvbHZlOiAodmFsdWU6IHZvaWQpID0+IHZvaWQpID0+IHtcbiAgICBzZXRUaW1lb3V0KCgpID0+IHJlc29sdmUoKSwgd2FpdFRpbWVvdXQpO1xuICB9KTtcbiAgY29uc3Qgc3RhdGVtZW50ID0gYXdhaXQgcmVkc2hpZnREYXRhLmRlc2NyaWJlU3RhdGVtZW50KHsgSWQ6IHN0YXRlbWVudElkIH0pLnByb21pc2UoKTtcbiAgaWYgKHN0YXRlbWVudC5TdGF0dXMgIT09ICdGSU5JU0hFRCcgJiYgc3RhdGVtZW50LlN0YXR1cyAhPT0gJ0ZBSUxFRCcgJiYgc3RhdGVtZW50LlN0YXR1cyAhPT0gJ0FCT1JURUQnKSB7XG4gICAgcmV0dXJuIHdhaXRGb3JTdGF0ZW1lbnRDb21wbGV0ZShzdGF0ZW1lbnRJZCk7XG4gIH0gZWxzZSBpZiAoc3RhdGVtZW50LlN0YXR1cyA9PT0gJ0ZJTklTSEVEJykge1xuICAgIHJldHVybjtcbiAgfSBlbHNlIHtcbiAgICB0aHJvdyBuZXcgRXJyb3IoYFN0YXRlbWVudCBzdGF0dXMgd2FzICR7c3RhdGVtZW50LlN0YXR1c306ICR7c3RhdGVtZW50LkVycm9yfWApO1xuICB9XG59XG4iXX0= \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.847e15feeb180b356ab9a8094d8b9459ea8ec26fc27957794d583ed9eb3a79d8/table.js b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.847e15feeb180b356ab9a8094d8b9459ea8ec26fc27957794d583ed9eb3a79d8/table.js deleted file mode 100644 index 1294ed3cd80c4..0000000000000 --- a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.847e15feeb180b356ab9a8094d8b9459ea8ec26fc27957794d583ed9eb3a79d8/table.js +++ /dev/null @@ -1,148 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.handler = void 0; -const redshift_data_1 = require("./redshift-data"); -const types_1 = require("./types"); -const util_1 = require("./util"); -async function handler(props, event) { - const tableNamePrefix = props.tableName.prefix; - const tableNameSuffix = props.tableName.generateSuffix === 'true' ? `${event.RequestId.substring(0, 8)}` : ''; - const tableColumns = props.tableColumns; - const tableAndClusterProps = props; - if (event.RequestType === 'Create') { - const tableName = await createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps); - return { PhysicalResourceId: tableName }; - } - else if (event.RequestType === 'Delete') { - await dropTable(event.PhysicalResourceId, tableAndClusterProps); - return; - } - else if (event.RequestType === 'Update') { - const tableName = await updateTable(event.PhysicalResourceId, tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps, event.OldResourceProperties); - return { PhysicalResourceId: tableName }; - } - else { - /* eslint-disable-next-line dot-notation */ - throw new Error(`Unrecognized event type: ${event['RequestType']}`); - } -} -exports.handler = handler; -async function createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps) { - const tableName = tableNamePrefix + tableNameSuffix; - const tableColumnsString = tableColumns.map(column => `${column.name} ${column.dataType}${getEncodingColumnString(column)}`).join(); - let statement = `CREATE TABLE ${tableName} (${tableColumnsString})`; - if (tableAndClusterProps.distStyle) { - statement += ` DISTSTYLE ${tableAndClusterProps.distStyle}`; - } - const distKeyColumn = util_1.getDistKeyColumn(tableColumns); - if (distKeyColumn) { - statement += ` DISTKEY(${distKeyColumn.name})`; - } - const sortKeyColumns = util_1.getSortKeyColumns(tableColumns); - if (sortKeyColumns.length > 0) { - const sortKeyColumnsString = getSortKeyColumnsString(sortKeyColumns); - statement += ` ${tableAndClusterProps.sortStyle} SORTKEY(${sortKeyColumnsString})`; - } - await redshift_data_1.executeStatement(statement, tableAndClusterProps); - for (const column of tableColumns) { - if (column.comment) { - await redshift_data_1.executeStatement(`COMMENT ON COLUMN ${tableName}.${column.name} IS '${column.comment}'`, tableAndClusterProps); - } - } - if (tableAndClusterProps.tableComment) { - await redshift_data_1.executeStatement(`COMMENT ON TABLE ${tableName} IS '${tableAndClusterProps.tableComment}'`, tableAndClusterProps); - } - return tableName; -} -async function dropTable(tableName, clusterProps) { - await redshift_data_1.executeStatement(`DROP TABLE ${tableName}`, clusterProps); -} -async function updateTable(tableName, tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps, oldResourceProperties) { - const alterationStatements = []; - const oldClusterProps = oldResourceProperties; - if (tableAndClusterProps.clusterName !== oldClusterProps.clusterName || tableAndClusterProps.databaseName !== oldClusterProps.databaseName) { - return createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps); - } - const oldTableNamePrefix = oldResourceProperties.tableName.prefix; - if (tableNamePrefix !== oldTableNamePrefix) { - return createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps); - } - const oldTableColumns = oldResourceProperties.tableColumns; - const columnDeletions = oldTableColumns.filter(oldColumn => (tableColumns.every(column => oldColumn.name !== column.name))); - if (columnDeletions.length > 0) { - alterationStatements.push(...columnDeletions.map(column => `ALTER TABLE ${tableName} DROP COLUMN ${column.name}`)); - } - const columnAdditions = tableColumns.filter(column => { - return !oldTableColumns.some(oldColumn => column.name === oldColumn.name && column.dataType === oldColumn.dataType); - }).map(column => `ADD ${column.name} ${column.dataType}`); - if (columnAdditions.length > 0) { - alterationStatements.push(...columnAdditions.map(addition => `ALTER TABLE ${tableName} ${addition}`)); - } - const columnEncoding = tableColumns.filter(column => { - return oldTableColumns.some(oldColumn => column.name === oldColumn.name && column.encoding !== oldColumn.encoding); - }).map(column => `ALTER COLUMN ${column.name} ENCODE ${column.encoding || types_1.ColumnEncoding.AUTO}`); - if (columnEncoding.length > 0) { - alterationStatements.push(`ALTER TABLE ${tableName} ${columnEncoding.join(', ')}`); - } - const columnComments = tableColumns.filter(column => { - return oldTableColumns.some(oldColumn => column.name === oldColumn.name && column.comment !== oldColumn.comment); - }).map(column => `COMMENT ON COLUMN ${tableName}.${column.name} IS ${column.comment ? `'${column.comment}'` : 'NULL'}`); - if (columnComments.length > 0) { - alterationStatements.push(...columnComments); - } - const oldDistStyle = oldResourceProperties.distStyle; - if ((!oldDistStyle && tableAndClusterProps.distStyle) || - (oldDistStyle && !tableAndClusterProps.distStyle)) { - return createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps); - } - else if (oldDistStyle !== tableAndClusterProps.distStyle) { - alterationStatements.push(`ALTER TABLE ${tableName} ALTER DISTSTYLE ${tableAndClusterProps.distStyle}`); - } - const oldDistKey = util_1.getDistKeyColumn(oldTableColumns)?.name; - const newDistKey = util_1.getDistKeyColumn(tableColumns)?.name; - if ((!oldDistKey && newDistKey) || (oldDistKey && !newDistKey)) { - return createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps); - } - else if (oldDistKey !== newDistKey) { - alterationStatements.push(`ALTER TABLE ${tableName} ALTER DISTKEY ${newDistKey}`); - } - const oldSortKeyColumns = util_1.getSortKeyColumns(oldTableColumns); - const newSortKeyColumns = util_1.getSortKeyColumns(tableColumns); - const oldSortStyle = oldResourceProperties.sortStyle; - const newSortStyle = tableAndClusterProps.sortStyle; - if ((oldSortStyle === newSortStyle && !util_1.areColumnsEqual(oldSortKeyColumns, newSortKeyColumns)) - || (oldSortStyle !== newSortStyle)) { - switch (newSortStyle) { - case types_1.TableSortStyle.INTERLEAVED: - // INTERLEAVED sort key addition requires replacement. - // https://docs.aws.amazon.com/redshift/latest/dg/r_ALTER_TABLE.html - return createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps); - case types_1.TableSortStyle.COMPOUND: { - const sortKeyColumnsString = getSortKeyColumnsString(newSortKeyColumns); - alterationStatements.push(`ALTER TABLE ${tableName} ALTER ${newSortStyle} SORTKEY(${sortKeyColumnsString})`); - break; - } - case types_1.TableSortStyle.AUTO: { - alterationStatements.push(`ALTER TABLE ${tableName} ALTER SORTKEY ${newSortStyle}`); - break; - } - } - } - const oldComment = oldResourceProperties.tableComment; - const newComment = tableAndClusterProps.tableComment; - if (oldComment !== newComment) { - alterationStatements.push(`COMMENT ON TABLE ${tableName} IS ${newComment ? `'${newComment}'` : 'NULL'}`); - } - await Promise.all(alterationStatements.map(statement => redshift_data_1.executeStatement(statement, tableAndClusterProps))); - return tableName; -} -function getSortKeyColumnsString(sortKeyColumns) { - return sortKeyColumns.map(column => column.name).join(); -} -function getEncodingColumnString(column) { - if (column.encoding) { - return ` ENCODE ${column.encoding}`; - } - return ''; -} -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFibGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJ0YWJsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFFQSxtREFBbUQ7QUFDbkQsbUNBQTZGO0FBQzdGLGlDQUE4RTtBQUd2RSxLQUFLLFVBQVUsT0FBTyxDQUFDLEtBQTJCLEVBQUUsS0FBa0Q7SUFDM0csTUFBTSxlQUFlLEdBQUcsS0FBSyxDQUFDLFNBQVMsQ0FBQyxNQUFNLENBQUM7SUFDL0MsTUFBTSxlQUFlLEdBQUcsS0FBSyxDQUFDLFNBQVMsQ0FBQyxjQUFjLEtBQUssTUFBTSxDQUFDLENBQUMsQ0FBQyxHQUFHLEtBQUssQ0FBQyxTQUFTLENBQUMsU0FBUyxDQUFDLENBQUMsRUFBRSxDQUFDLENBQUMsRUFBRSxDQUFDLENBQUMsQ0FBQyxFQUFFLENBQUM7SUFDOUcsTUFBTSxZQUFZLEdBQUcsS0FBSyxDQUFDLFlBQVksQ0FBQztJQUN4QyxNQUFNLG9CQUFvQixHQUFHLEtBQUssQ0FBQztJQUVuQyxJQUFJLEtBQUssQ0FBQyxXQUFXLEtBQUssUUFBUSxFQUFFO1FBQ2xDLE1BQU0sU0FBUyxHQUFH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HVtbi5lbmNvZGluZ31gO1xuICB9XG4gIHJldHVybiAnJztcbn1cbiJdfQ== \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.847e15feeb180b356ab9a8094d8b9459ea8ec26fc27957794d583ed9eb3a79d8/types.js b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.847e15feeb180b356ab9a8094d8b9459ea8ec26fc27957794d583ed9eb3a79d8/types.js deleted file mode 100644 index c19cbf576b891..0000000000000 --- a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.847e15feeb180b356ab9a8094d8b9459ea8ec26fc27957794d583ed9eb3a79d8/types.js +++ /dev/null @@ -1,120 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.ColumnEncoding = exports.TableSortStyle = void 0; -/** - * The sort style of a table. - * This has been duplicated here to exporting private types. - */ -var TableSortStyle; -(function (TableSortStyle) { - /** - * Amazon Redshift assigns an optimal sort key based on the table data. - */ - TableSortStyle["AUTO"] = "AUTO"; - /** - * Specifies that the data is sorted using a compound key made up of all of the listed columns, - * in the order they are listed. - */ - TableSortStyle["COMPOUND"] = "COMPOUND"; - /** - * Specifies that the data is sorted using an interleaved sort key. - */ - TableSortStyle["INTERLEAVED"] = "INTERLEAVED"; -})(TableSortStyle = exports.TableSortStyle || (exports.TableSortStyle = {})); -/** - * The compression encoding of a column. - * - * @see https://docs.aws.amazon.com/redshift/latest/dg/c_Compression_encodings.html - */ -var ColumnEncoding; -(function (ColumnEncoding) { - /** - * Amazon Redshift assigns an optimal encoding based on the column data. - * This is the default. - */ - ColumnEncoding["AUTO"] = "AUTO"; - /** - * The column is not compressed. - * - * @see https://docs.aws.amazon.com/redshift/latest/dg/c_Raw_encoding.html - */ - ColumnEncoding["RAW"] = "RAW"; - /** - * The column is compressed using the AZ64 algorithm. - * - * @see https://docs.aws.amazon.com/redshift/latest/dg/az64-encoding.html - */ - ColumnEncoding["AZ64"] = "AZ64"; - /** - * The column is compressed using a separate dictionary for each block column value on disk. - * - * @see https://docs.aws.amazon.com/redshift/latest/dg/c_Byte_dictionary_encoding.html - */ - ColumnEncoding["BYTEDICT"] = "BYTEDICT"; - /** - * The column is compressed based on the difference between values in the column. - * This records differences as 1-byte values. - * - * @see https://docs.aws.amazon.com/redshift/latest/dg/c_Delta_encoding.html - */ - ColumnEncoding["DELTA"] = "DELTA"; - /** - * The column is compressed based on the difference between values in the column. - * This records differences as 2-byte values. - * - * @see https://docs.aws.amazon.com/redshift/latest/dg/c_Delta_encoding.html - */ - ColumnEncoding["DELTA32K"] = "DELTA32K"; - /** - * The column is compressed using the LZO algorithm. - * - * @see https://docs.aws.amazon.com/redshift/latest/dg/lzo-encoding.html - */ - ColumnEncoding["LZO"] = "LZO"; - /** - * The column is compressed to a smaller storage size than the original data type. - * The compressed storage size is 1 byte. - * - * @see https://docs.aws.amazon.com/redshift/latest/dg/c_MostlyN_encoding.html - */ - ColumnEncoding["MOSTLY8"] = "MOSTLY8"; - /** - * The column is compressed to a smaller storage size than the original data type. - * The compressed storage size is 2 bytes. - * - * @see https://docs.aws.amazon.com/redshift/latest/dg/c_MostlyN_encoding.html - */ - ColumnEncoding["MOSTLY16"] = "MOSTLY16"; - /** - * The column is compressed to a smaller storage size than the original data type. - * The compressed storage size is 4 bytes. - * - * @see https://docs.aws.amazon.com/redshift/latest/dg/c_MostlyN_encoding.html - */ - ColumnEncoding["MOSTLY32"] = "MOSTLY32"; - /** - * The column is compressed by recording the number of occurrences of each value in the column. - * - * @see https://docs.aws.amazon.com/redshift/latest/dg/c_Runlength_encoding.html - */ - ColumnEncoding["RUNLENGTH"] = "RUNLENGTH"; - /** - * The column is compressed by recording the first 245 unique words and then using a 1-byte index to represent each word. - * - * @see https://docs.aws.amazon.com/redshift/latest/dg/c_Text255_encoding.html - */ - ColumnEncoding["TEXT255"] = "TEXT255"; - /** - * The column is compressed by recording the first 32K unique words and then using a 2-byte index to represent each word. - * - * @see https://docs.aws.amazon.com/redshift/latest/dg/c_Text255_encoding.html - */ - ColumnEncoding["TEXT32K"] = "TEXT32K"; - /** - * The column is compressed using the ZSTD algorithm. - * - * @see https://docs.aws.amazon.com/redshift/latest/dg/zstd-encoding.html - */ - ColumnEncoding["ZSTD"] = "ZSTD"; -})(ColumnEncoding = exports.ColumnEncoding || (exports.ColumnEncoding = {})); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJ0eXBlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFLQTs7O0dBR0c7QUFDSCxJQUFZLGNBZ0JYO0FBaEJELFdBQVksY0FBYztJQUN4Qjs7T0FFRztJQUNILCtCQUFhLENBQUE7SUFFYjs7O09BR0c7SUFDSCx1Q0FBcUIsQ0FBQTtJQUVyQjs7T0FFRztJQUNILDZDQUEyQixDQUFBO0FBQzdCLENBQUMsRUFoQlcsY0FBYyxHQUFkLHNCQUFjLEtBQWQsc0JBQWMsUUFnQnpCO0FBRUQ7Ozs7R0FJRztBQUNILElBQVksY0FzR1g7QUF0R0QsV0FBWSxjQUFjO0lBQ3hCOzs7T0FHRztJQUNILCtCQUFhLENBQUE7SUFFYjs7OztPQUlHO0lBQ0gsNkJBQVcsQ0FBQTtJQUVYOzs7O09BSUc7SUFDSCwrQkFBYSxDQUFBO0lBRWI7Ozs7T0FJRztJQUNILHVDQUFxQixDQUFBO0lBRXJCOzs7OztPQUtHO0lBQ0gsaUNBQWUsQ0FBQTtJQUVmOzs7OztPQUtHO0lBQ0gsdUNBQXFCLENBQUE7SUFFckI7Ozs7T0FJRztJQUNILDZCQUFXLENBQUE7SUFFWDs7Ozs7T0FLRztJQUNILHFDQUFtQixDQUFBO0lBRW5COzs7OztPQUtHO0lBQ0gsdUNBQXFCLENBQUE7SUFFckI7Ozs7O09BS0c7SUFDSCx1Q0FBcUIsQ0FBQTtJQUVyQ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ICovXG4gIFRFWFQzMksgPSAnVEVYVDMySycsXG5cbiAgLyoqXG4gICAqIFRoZSBjb2x1bW4gaXMgY29tcHJlc3NlZCB1c2luZyB0aGUgWlNURCBhbGdvcml0aG0uXG4gICAqXG4gICAqIEBzZWUgaHR0cHM6Ly9kb2NzLmF3cy5hbWF6b24uY29tL3JlZHNoaWZ0L2xhdGVzdC9kZy96c3RkLWVuY29kaW5nLmh0bWxcbiAgICovXG4gIFpTVEQgPSAnWlNURCcsXG59XG4iXX0= \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.847e15feeb180b356ab9a8094d8b9459ea8ec26fc27957794d583ed9eb3a79d8/user.js b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.847e15feeb180b356ab9a8094d8b9459ea8ec26fc27957794d583ed9eb3a79d8/user.js deleted file mode 100644 index f097ae1836462..0000000000000 --- a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.847e15feeb180b356ab9a8094d8b9459ea8ec26fc27957794d583ed9eb3a79d8/user.js +++ /dev/null @@ -1,70 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.handler = void 0; -/* eslint-disable-next-line import/no-extraneous-dependencies */ -const SecretsManager = require("aws-sdk/clients/secretsmanager"); -const redshift_data_1 = require("./redshift-data"); -const util_1 = require("./util"); -const secretsManager = new SecretsManager(); -async function handler(props, event) { - const username = props.username; - const passwordSecretArn = props.passwordSecretArn; - const clusterProps = props; - if (event.RequestType === 'Create') { - await createUser(username, passwordSecretArn, clusterProps); - return { PhysicalResourceId: util_1.makePhysicalId(username, clusterProps, event.RequestId), Data: { username: username } }; - } - else if (event.RequestType === 'Delete') { - await dropUser(username, clusterProps); - return; - } - else if (event.RequestType === 'Update') { - const { replace } = await updateUser(username, passwordSecretArn, clusterProps, event.OldResourceProperties); - const physicalId = replace ? util_1.makePhysicalId(username, clusterProps, event.RequestId) : event.PhysicalResourceId; - return { PhysicalResourceId: physicalId, Data: { username: username } }; - } - else { - /* eslint-disable-next-line dot-notation */ - throw new Error(`Unrecognized event type: ${event['RequestType']}`); - } -} -exports.handler = handler; -async function dropUser(username, clusterProps) { - await redshift_data_1.executeStatement(`DROP USER ${username}`, clusterProps); -} -async function createUser(username, passwordSecretArn, clusterProps) { - const password = await getPasswordFromSecret(passwordSecretArn); - await redshift_data_1.executeStatement(`CREATE USER ${username} PASSWORD '${password}'`, clusterProps); -} -async function updateUser(username, passwordSecretArn, clusterProps, oldResourceProperties) { - const oldClusterProps = oldResourceProperties; - if (clusterProps.clusterName !== oldClusterProps.clusterName || clusterProps.databaseName !== oldClusterProps.databaseName) { - await createUser(username, passwordSecretArn, clusterProps); - return { replace: true }; - } - const oldUsername = oldResourceProperties.username; - const oldPasswordSecretArn = oldResourceProperties.passwordSecretArn; - const oldPassword = await getPasswordFromSecret(oldPasswordSecretArn); - const password = await getPasswordFromSecret(passwordSecretArn); - if (username !== oldUsername) { - await createUser(username, passwordSecretArn, clusterProps); - return { replace: true }; - } - if (password !== oldPassword) { - await redshift_data_1.executeStatement(`ALTER USER ${username} PASSWORD '${password}'`, clusterProps); - return { replace: false }; - } - return { replace: false }; -} -async function getPasswordFromSecret(passwordSecretArn) { - const secretValue = await secretsManager.getSecretValue({ - SecretId: passwordSecretArn, - }).promise(); - const secretString = secretValue.SecretString; - if (!secretString) { - throw new Error(`Secret string for ${passwordSecretArn} was empty`); - } - const { password } = JSON.parse(secretString); - return password; -} -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXNlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInVzZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBRUEsZ0VBQWdFO0FBQ2hFLGlFQUFpRTtBQUNqRSxtREFBbUQ7QUFFbkQsaUNBQXdDO0FBR3hDLE1BQU0sY0FBYyxHQUFHLElBQUksY0FBYyxFQUFFLEN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Fsc2UgfTtcbn1cblxuYXN5bmMgZnVuY3Rpb24gZ2V0UGFzc3dvcmRGcm9tU2VjcmV0KHBhc3N3b3JkU2VjcmV0QXJuOiBzdHJpbmcpOiBQcm9taXNlPHN0cmluZz4ge1xuICBjb25zdCBzZWNyZXRWYWx1ZSA9IGF3YWl0IHNlY3JldHNNYW5hZ2VyLmdldFNlY3JldFZhbHVlKHtcbiAgICBTZWNyZXRJZDogcGFzc3dvcmRTZWNyZXRBcm4sXG4gIH0pLnByb21pc2UoKTtcbiAgY29uc3Qgc2VjcmV0U3RyaW5nID0gc2VjcmV0VmFsdWUuU2VjcmV0U3RyaW5nO1xuICBpZiAoIXNlY3JldFN0cmluZykge1xuICAgIHRocm93IG5ldyBFcnJvcihgU2VjcmV0IHN0cmluZyBmb3IgJHtwYXNzd29yZFNlY3JldEFybn0gd2FzIGVtcHR5YCk7XG4gIH1cbiAgY29uc3QgeyBwYXNzd29yZCB9ID0gSlNPTi5wYXJzZShzZWNyZXRTdHJpbmcpO1xuXG4gIHJldHVybiBwYXNzd29yZDtcbn1cbiJdfQ== \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.847e15feeb180b356ab9a8094d8b9459ea8ec26fc27957794d583ed9eb3a79d8/util.js b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.847e15feeb180b356ab9a8094d8b9459ea8ec26fc27957794d583ed9eb3a79d8/util.js deleted file mode 100644 index d8dc8cad799c9..0000000000000 --- a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.847e15feeb180b356ab9a8094d8b9459ea8ec26fc27957794d583ed9eb3a79d8/util.js +++ /dev/null @@ -1,34 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.areColumnsEqual = exports.getSortKeyColumns = exports.getDistKeyColumn = exports.makePhysicalId = void 0; -function makePhysicalId(resourceName, clusterProps, requestId) { - return `${clusterProps.clusterName}:${clusterProps.databaseName}:${resourceName}:${requestId}`; -} -exports.makePhysicalId = makePhysicalId; -function getDistKeyColumn(columns) { - // string comparison is required for custom resource since everything is passed as string - const distKeyColumns = columns.filter(column => column.distKey === true || column.distKey === 'true'); - if (distKeyColumns.length === 0) { - return undefined; - } - else if (distKeyColumns.length > 1) { - throw new Error('Multiple dist key columns found'); - } - return distKeyColumns[0]; -} -exports.getDistKeyColumn = getDistKeyColumn; -function getSortKeyColumns(columns) { - // string comparison is required for custom resource since everything is passed as string - return columns.filter(column => column.sortKey === true || column.sortKey === 'true'); -} -exports.getSortKeyColumns = getSortKeyColumns; -function areColumnsEqual(columnsA, columnsB) { - if (columnsA.length !== columnsB.length) { - return false; - } - return columnsA.every(columnA => { - return columnsB.find(column => column.name === columnA.name && column.dataType === columnA.dataType); - }); -} -exports.areColumnsEqual = areColumnsEqual; -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInV0aWwudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBR0EsU0FBZ0IsY0FBYyxDQUFDLFlBQW9CLEVBQUUsWUFBMEIsRUFBRSxTQUFpQjtJQUNoRyxPQUFPLEdBQUcsWUFBWSxDQUFDLFdBQVcsSUFBSSxZQUFZLENBQUMsWUFBWSxJQUFJLFlBQVksSUFBSSxTQUFTLEVBQUUsQ0FBQztBQUNqRyxDQUFDO0FBRkQsd0NBRUM7QUFFRCxTQUFnQixnQkFBZ0IsQ0FBQyxPQUFpQjtJQUNoRCx5RkFBeUY7SUFDekYsTUFBTSxjQUFjLEdBQUcsT0FBTyxDQUFDLE1BQU0sQ0FBQyxNQUFNLENBQUMsRUFBRSxDQUFDLE1BQU0sQ0FBQyxPQUFPLEtBQUssSUFBSSxJQUFLLE1BQU0sQ0FBQyxPQUE2QixLQUFLLE1BQU0sQ0FBQyxDQUFDO0lBRTdILElBQUksY0FBYyxDQUFDLE1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ltdIHtcbiAgLy8gc3RyaW5nIGNvbXBhcmlzb24gaXMgcmVxdWlyZWQgZm9yIGN1c3RvbSByZXNvdXJjZSBzaW5jZSBldmVyeXRoaW5nIGlzIHBhc3NlZCBhcyBzdHJpbmdcbiAgcmV0dXJuIGNvbHVtbnMuZmlsdGVyKGNvbHVtbiA9PiBjb2x1bW4uc29ydEtleSA9PT0gdHJ1ZSB8fCAoY29sdW1uLnNvcnRLZXkgYXMgdW5rbm93biBhcyBzdHJpbmcpID09PSAndHJ1ZScpO1xufVxuXG5leHBvcnQgZnVuY3Rpb24gYXJlQ29sdW1uc0VxdWFsKGNvbHVtbnNBOiBDb2x1bW5bXSwgY29sdW1uc0I6IENvbHVtbltdKTogYm9vbGVhbiB7XG4gIGlmIChjb2x1bW5zQS5sZW5ndGggIT09IGNvbHVtbnNCLmxlbmd0aCkge1xuICAgIHJldHVybiBmYWxzZTtcbiAgfVxuICByZXR1cm4gY29sdW1uc0EuZXZlcnkoY29sdW1uQSA9PiB7XG4gICAgcmV0dXJuIGNvbHVtbnNCLmZpbmQoY29sdW1uID0+IGNvbHVtbi5uYW1lID09PSBjb2x1bW5BLm5hbWUgJiYgY29sdW1uLmRhdGFUeXBlID09PSBjb2x1bW5BLmRhdGFUeXBlKTtcbiAgfSk7XG59XG4iXX0= \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/aws-cdk-redshift-cluster-database.assets.json b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/aws-cdk-redshift-cluster-database.assets.json index ae34a00d79aa9..6355d00ee6905 100644 --- a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/aws-cdk-redshift-cluster-database.assets.json +++ b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/aws-cdk-redshift-cluster-database.assets.json @@ -1,15 +1,15 @@ { - "version": "30.1.0", + "version": "31.0.0", "files": { - "169a8c0beb97c903ee155ea9653e39b0884c9e3b860ac72ffbe906b3c1f4e338": { + "df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a": { "source": { - "path": "asset.169a8c0beb97c903ee155ea9653e39b0884c9e3b860ac72ffbe906b3c1f4e338", + "path": "asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a", "packaging": "zip" }, "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "169a8c0beb97c903ee155ea9653e39b0884c9e3b860ac72ffbe906b3c1f4e338.zip", + "objectKey": "df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a.zip", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } @@ -27,7 +27,7 @@ } } }, - "297bfa1758edc6b71a084153702165132d111eb7914b4bf8ed951da4b98faede": { + "f2cf2a437f9007286a4d7bc2cb4d6008231236f7c800e4503142a26d808b75d7": { "source": { "path": "aws-cdk-redshift-cluster-database.template.json", "packaging": "file" @@ -35,11 +35,11 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "297bfa1758edc6b71a084153702165132d111eb7914b4bf8ed951da4b98faede.json", + "objectKey": "f2cf2a437f9007286a4d7bc2cb4d6008231236f7c800e4503142a26d808b75d7.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } } }, "dockerImages": {} -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/aws-cdk-redshift-cluster-database.template.json b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/aws-cdk-redshift-cluster-database.template.json index 4e234633a945a..6cd10131ee57a 100644 --- a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/aws-cdk-redshift-cluster-database.template.json +++ b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/aws-cdk-redshift-cluster-database.template.json @@ -1,1193 +1,1226 @@ { - "Resources": { - "customkmskey377C6F9A": { - "Type": "AWS::KMS::Key", - "Properties": { - "KeyPolicy": { - "Statement": [ - { - "Action": "kms:*", - "Effect": "Allow", - "Principal": { - "AWS": { - "Fn::Join": [ - "", - [ - "arn:", - { - "Ref": "AWS::Partition" - }, - ":iam::", - { - "Ref": "AWS::AccountId" - }, - ":root" - ] - ] - } - }, - "Resource": "*" - } - ], - "Version": "2012-10-17" - } - }, - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "Vpc8378EB38": { - "Type": "AWS::EC2::VPC", - "Properties": { - "CidrBlock": "10.0.0.0/16", - "EnableDnsHostnames": true, - "EnableDnsSupport": true, - "InstanceTenancy": "default", - "Tags": [ - { - "Key": "Name", - "Value": "aws-cdk-redshift-cluster-database/Vpc" - } - ] - }, - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "VpcPublicSubnet1Subnet5C2D37C4": { - "Type": "AWS::EC2::Subnet", - "Properties": { - "VpcId": { - "Ref": "Vpc8378EB38" - }, - "AvailabilityZone": { - "Fn::Select": [ - 0, - { - "Fn::GetAZs": "" - } - ] - }, - "CidrBlock": "10.0.0.0/18", - "MapPublicIpOnLaunch": true, - "Tags": [ - { - "Key": "aws-cdk:subnet-name", - "Value": "Public" - }, - { - "Key": "aws-cdk:subnet-type", - "Value": "Public" - }, - { - "Key": "Name", - "Value": "aws-cdk-redshift-cluster-database/Vpc/PublicSubnet1" - } - ] - }, - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "VpcPublicSubnet1RouteTable6C95E38E": { - "Type": "AWS::EC2::RouteTable", - "Properties": { - "VpcId": { - "Ref": "Vpc8378EB38" - }, - "Tags": [ - { - "Key": "Name", - "Value": "aws-cdk-redshift-cluster-database/Vpc/PublicSubnet1" - } - ] - }, - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "VpcPublicSubnet1RouteTableAssociation97140677": { - "Type": "AWS::EC2::SubnetRouteTableAssociation", - "Properties": { - "RouteTableId": { - "Ref": "VpcPublicSubnet1RouteTable6C95E38E" - }, - "SubnetId": { - "Ref": "VpcPublicSubnet1Subnet5C2D37C4" - } - }, - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "VpcPublicSubnet1DefaultRoute3DA9E72A": { - "Type": "AWS::EC2::Route", - "Properties": { - "RouteTableId": { - "Ref": "VpcPublicSubnet1RouteTable6C95E38E" - }, - "DestinationCidrBlock": "0.0.0.0/0", - "GatewayId": { - "Ref": "VpcIGWD7BA715C" - } - }, - "DependsOn": ["VpcVPCGWBF912B6E"], - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "VpcPublicSubnet1EIPD7E02669": { - "Type": "AWS::EC2::EIP", - "Properties": { - "Domain": "vpc", - "Tags": [ - { - "Key": "Name", - "Value": "aws-cdk-redshift-cluster-database/Vpc/PublicSubnet1" - } - ] - }, - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "VpcPublicSubnet1NATGateway4D7517AA": { - "Type": "AWS::EC2::NatGateway", - "Properties": { - "SubnetId": { - "Ref": "VpcPublicSubnet1Subnet5C2D37C4" - }, - "AllocationId": { - "Fn::GetAtt": ["VpcPublicSubnet1EIPD7E02669", "AllocationId"] - }, - "Tags": [ - { - "Key": "Name", - "Value": "aws-cdk-redshift-cluster-database/Vpc/PublicSubnet1" - } - ] - }, - "DependsOn": [ - "VpcPublicSubnet1DefaultRoute3DA9E72A", - "VpcPublicSubnet1RouteTableAssociation97140677" - ], - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "VpcPublicSubnet2Subnet691E08A3": { - "Type": "AWS::EC2::Subnet", - "Properties": { - "VpcId": { - "Ref": "Vpc8378EB38" - }, - "AvailabilityZone": { - "Fn::Select": [ - 1, - { - "Fn::GetAZs": "" - } + "Resources": { + "customkmskey377C6F9A": { + "Type": "AWS::KMS::Key", + "Properties": { + "KeyPolicy": { + "Statement": [ + { + "Action": "kms:*", + "Effect": "Allow", + "Principal": { + "AWS": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::", + { + "Ref": "AWS::AccountId" + }, + ":root" ] - }, - "CidrBlock": "10.0.64.0/18", - "MapPublicIpOnLaunch": true, - "Tags": [ - { - "Key": "aws-cdk:subnet-name", - "Value": "Public" - }, - { - "Key": "aws-cdk:subnet-type", - "Value": "Public" - }, - { - "Key": "Name", - "Value": "aws-cdk-redshift-cluster-database/Vpc/PublicSubnet2" - } - ] - }, - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "VpcPublicSubnet2RouteTable94F7E489": { - "Type": "AWS::EC2::RouteTable", - "Properties": { - "VpcId": { - "Ref": "Vpc8378EB38" - }, - "Tags": [ - { - "Key": "Name", - "Value": "aws-cdk-redshift-cluster-database/Vpc/PublicSubnet2" - } - ] - }, - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "VpcPublicSubnet2RouteTableAssociationDD5762D8": { - "Type": "AWS::EC2::SubnetRouteTableAssociation", - "Properties": { - "RouteTableId": { - "Ref": "VpcPublicSubnet2RouteTable94F7E489" - }, - "SubnetId": { - "Ref": "VpcPublicSubnet2Subnet691E08A3" - } - }, - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "VpcPublicSubnet2DefaultRoute97F91067": { - "Type": "AWS::EC2::Route", - "Properties": { - "RouteTableId": { - "Ref": "VpcPublicSubnet2RouteTable94F7E489" - }, - "DestinationCidrBlock": "0.0.0.0/0", - "GatewayId": { - "Ref": "VpcIGWD7BA715C" - } - }, - "DependsOn": ["VpcVPCGWBF912B6E"], - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "VpcPublicSubnet2EIP3C605A87": { - "Type": "AWS::EC2::EIP", - "Properties": { - "Domain": "vpc", - "Tags": [ - { - "Key": "Name", - "Value": "aws-cdk-redshift-cluster-database/Vpc/PublicSubnet2" - } - ] - }, - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "VpcPublicSubnet2NATGateway9182C01D": { - "Type": "AWS::EC2::NatGateway", - "Properties": { - "SubnetId": { - "Ref": "VpcPublicSubnet2Subnet691E08A3" - }, - "AllocationId": { - "Fn::GetAtt": ["VpcPublicSubnet2EIP3C605A87", "AllocationId"] - }, - "Tags": [ - { - "Key": "Name", - "Value": "aws-cdk-redshift-cluster-database/Vpc/PublicSubnet2" - } - ] - }, - "DependsOn": [ - "VpcPublicSubnet2DefaultRoute97F91067", - "VpcPublicSubnet2RouteTableAssociationDD5762D8" - ], - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "VpcPrivateSubnet1Subnet536B997A": { - "Type": "AWS::EC2::Subnet", - "Properties": { - "VpcId": { - "Ref": "Vpc8378EB38" - }, - "AvailabilityZone": { - "Fn::Select": [ - 0, - { - "Fn::GetAZs": "" - } - ] - }, - "CidrBlock": "10.0.128.0/18", - "MapPublicIpOnLaunch": false, - "Tags": [ - { - "Key": "aws-cdk:subnet-name", - "Value": "Private" - }, - { - "Key": "aws-cdk:subnet-type", - "Value": "Private" - }, - { - "Key": "Name", - "Value": "aws-cdk-redshift-cluster-database/Vpc/PrivateSubnet1" - } - ] - }, - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "VpcPrivateSubnet1RouteTableB2C5B500": { - "Type": "AWS::EC2::RouteTable", - "Properties": { - "VpcId": { - "Ref": "Vpc8378EB38" - }, - "Tags": [ - { - "Key": "Name", - "Value": "aws-cdk-redshift-cluster-database/Vpc/PrivateSubnet1" - } - ] - }, - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "VpcPrivateSubnet1RouteTableAssociation70C59FA6": { - "Type": "AWS::EC2::SubnetRouteTableAssociation", - "Properties": { - "RouteTableId": { - "Ref": "VpcPrivateSubnet1RouteTableB2C5B500" - }, - "SubnetId": { - "Ref": "VpcPrivateSubnet1Subnet536B997A" - } - }, - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "VpcPrivateSubnet1DefaultRouteBE02A9ED": { - "Type": "AWS::EC2::Route", - "Properties": { - "RouteTableId": { - "Ref": "VpcPrivateSubnet1RouteTableB2C5B500" - }, - "DestinationCidrBlock": "0.0.0.0/0", - "NatGatewayId": { - "Ref": "VpcPublicSubnet1NATGateway4D7517AA" - } - }, - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "VpcPrivateSubnet2Subnet3788AAA1": { - "Type": "AWS::EC2::Subnet", - "Properties": { - "VpcId": { - "Ref": "Vpc8378EB38" - }, - "AvailabilityZone": { - "Fn::Select": [ - 1, - { - "Fn::GetAZs": "" - } - ] - }, - "CidrBlock": "10.0.192.0/18", - "MapPublicIpOnLaunch": false, - "Tags": [ - { - "Key": "aws-cdk:subnet-name", - "Value": "Private" - }, - { - "Key": "aws-cdk:subnet-type", - "Value": "Private" - }, - { - "Key": "Name", - "Value": "aws-cdk-redshift-cluster-database/Vpc/PrivateSubnet2" - } - ] - }, - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "VpcPrivateSubnet2RouteTableA678073B": { - "Type": "AWS::EC2::RouteTable", - "Properties": { - "VpcId": { - "Ref": "Vpc8378EB38" - }, - "Tags": [ - { - "Key": "Name", - "Value": "aws-cdk-redshift-cluster-database/Vpc/PrivateSubnet2" - } - ] - }, - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "VpcPrivateSubnet2RouteTableAssociationA89CAD56": { - "Type": "AWS::EC2::SubnetRouteTableAssociation", - "Properties": { - "RouteTableId": { - "Ref": "VpcPrivateSubnet2RouteTableA678073B" - }, - "SubnetId": { - "Ref": "VpcPrivateSubnet2Subnet3788AAA1" - } - }, - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "VpcPrivateSubnet2DefaultRoute060D2087": { - "Type": "AWS::EC2::Route", - "Properties": { - "RouteTableId": { - "Ref": "VpcPrivateSubnet2RouteTableA678073B" - }, - "DestinationCidrBlock": "0.0.0.0/0", - "NatGatewayId": { - "Ref": "VpcPublicSubnet2NATGateway9182C01D" - } - }, - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "VpcIGWD7BA715C": { - "Type": "AWS::EC2::InternetGateway", - "Properties": { - "Tags": [ - { - "Key": "Name", - "Value": "aws-cdk-redshift-cluster-database/Vpc" - } - ] - }, - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "VpcVPCGWBF912B6E": { - "Type": "AWS::EC2::VPCGatewayAttachment", - "Properties": { - "VpcId": { - "Ref": "Vpc8378EB38" - }, - "InternetGatewayId": { - "Ref": "VpcIGWD7BA715C" - } - }, - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "ClusterSubnetsDCFA5CB7": { - "Type": "AWS::Redshift::ClusterSubnetGroup", - "Properties": { - "Description": "Subnets for Cluster Redshift cluster", - "SubnetIds": [ - { - "Ref": "VpcPublicSubnet1Subnet5C2D37C4" - }, - { - "Ref": "VpcPublicSubnet2Subnet691E08A3" - } - ] - }, - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "ClusterSecurityGroup0921994B": { - "Type": "AWS::EC2::SecurityGroup", - "Properties": { - "GroupDescription": "Redshift security group", - "SecurityGroupEgress": [ - { - "CidrIp": "0.0.0.0/0", - "Description": "Allow all outbound traffic by default", - "IpProtocol": "-1" - } - ], - "VpcId": { - "Ref": "Vpc8378EB38" - } - }, - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "ClusterSecret6368BD0F": { - "Type": "AWS::SecretsManager::Secret", - "Properties": { - "GenerateSecretString": { - "ExcludeCharacters": "\"@/\\ '", - "GenerateStringKey": "password", - "PasswordLength": 30, - "SecretStringTemplate": "{\"username\":\"admin\"}" + ] } - }, - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "ClusterSecretAttachment769E6258": { - "Type": "AWS::SecretsManager::SecretTargetAttachment", - "Properties": { - "SecretId": { - "Ref": "ClusterSecret6368BD0F" - }, - "TargetId": { - "Ref": "ClusterEB0386A7" + }, + "Resource": "*" + } + ], + "Version": "2012-10-17" + } + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "Vpc8378EB38": { + "Type": "AWS::EC2::VPC", + "Properties": { + "CidrBlock": "10.0.0.0/16", + "EnableDnsHostnames": true, + "EnableDnsSupport": true, + "InstanceTenancy": "default", + "Tags": [ + { + "Key": "Name", + "Value": "aws-cdk-redshift-cluster-database/Vpc" + } + ] + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "VpcPublicSubnet1Subnet5C2D37C4": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "AvailabilityZone": { + "Fn::Select": [ + 0, + { + "Fn::GetAZs": "" + } + ] + }, + "CidrBlock": "10.0.0.0/18", + "MapPublicIpOnLaunch": true, + "Tags": [ + { + "Key": "aws-cdk:subnet-name", + "Value": "Public" + }, + { + "Key": "aws-cdk:subnet-type", + "Value": "Public" + }, + { + "Key": "Name", + "Value": "aws-cdk-redshift-cluster-database/Vpc/PublicSubnet1" + } + ] + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "VpcPublicSubnet1RouteTable6C95E38E": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "Tags": [ + { + "Key": "Name", + "Value": "aws-cdk-redshift-cluster-database/Vpc/PublicSubnet1" + } + ] + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "VpcPublicSubnet1RouteTableAssociation97140677": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VpcPublicSubnet1RouteTable6C95E38E" + }, + "SubnetId": { + "Ref": "VpcPublicSubnet1Subnet5C2D37C4" + } + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "VpcPublicSubnet1DefaultRoute3DA9E72A": { + "Type": "AWS::EC2::Route", + "Properties": { + "RouteTableId": { + "Ref": "VpcPublicSubnet1RouteTable6C95E38E" + }, + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": { + "Ref": "VpcIGWD7BA715C" + } + }, + "DependsOn": [ + "VpcVPCGWBF912B6E" + ], + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "VpcPublicSubnet1EIPD7E02669": { + "Type": "AWS::EC2::EIP", + "Properties": { + "Domain": "vpc", + "Tags": [ + { + "Key": "Name", + "Value": "aws-cdk-redshift-cluster-database/Vpc/PublicSubnet1" + } + ] + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "VpcPublicSubnet1NATGateway4D7517AA": { + "Type": "AWS::EC2::NatGateway", + "Properties": { + "SubnetId": { + "Ref": "VpcPublicSubnet1Subnet5C2D37C4" + }, + "AllocationId": { + "Fn::GetAtt": [ + "VpcPublicSubnet1EIPD7E02669", + "AllocationId" + ] + }, + "Tags": [ + { + "Key": "Name", + "Value": "aws-cdk-redshift-cluster-database/Vpc/PublicSubnet1" + } + ] + }, + "DependsOn": [ + "VpcPublicSubnet1DefaultRoute3DA9E72A", + "VpcPublicSubnet1RouteTableAssociation97140677" + ], + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "VpcPublicSubnet2Subnet691E08A3": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "AvailabilityZone": { + "Fn::Select": [ + 1, + { + "Fn::GetAZs": "" + } + ] + }, + "CidrBlock": "10.0.64.0/18", + "MapPublicIpOnLaunch": true, + "Tags": [ + { + "Key": "aws-cdk:subnet-name", + "Value": "Public" + }, + { + "Key": "aws-cdk:subnet-type", + "Value": "Public" + }, + { + "Key": "Name", + "Value": "aws-cdk-redshift-cluster-database/Vpc/PublicSubnet2" + } + ] + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "VpcPublicSubnet2RouteTable94F7E489": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "Tags": [ + { + "Key": "Name", + "Value": "aws-cdk-redshift-cluster-database/Vpc/PublicSubnet2" + } + ] + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "VpcPublicSubnet2RouteTableAssociationDD5762D8": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VpcPublicSubnet2RouteTable94F7E489" + }, + "SubnetId": { + "Ref": "VpcPublicSubnet2Subnet691E08A3" + } + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "VpcPublicSubnet2DefaultRoute97F91067": { + "Type": "AWS::EC2::Route", + "Properties": { + "RouteTableId": { + "Ref": "VpcPublicSubnet2RouteTable94F7E489" + }, + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": { + "Ref": "VpcIGWD7BA715C" + } + }, + "DependsOn": [ + "VpcVPCGWBF912B6E" + ], + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "VpcPublicSubnet2EIP3C605A87": { + "Type": "AWS::EC2::EIP", + "Properties": { + "Domain": "vpc", + "Tags": [ + { + "Key": "Name", + "Value": "aws-cdk-redshift-cluster-database/Vpc/PublicSubnet2" + } + ] + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "VpcPublicSubnet2NATGateway9182C01D": { + "Type": "AWS::EC2::NatGateway", + "Properties": { + "SubnetId": { + "Ref": "VpcPublicSubnet2Subnet691E08A3" + }, + "AllocationId": { + "Fn::GetAtt": [ + "VpcPublicSubnet2EIP3C605A87", + "AllocationId" + ] + }, + "Tags": [ + { + "Key": "Name", + "Value": "aws-cdk-redshift-cluster-database/Vpc/PublicSubnet2" + } + ] + }, + "DependsOn": [ + "VpcPublicSubnet2DefaultRoute97F91067", + "VpcPublicSubnet2RouteTableAssociationDD5762D8" + ], + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "VpcPrivateSubnet1Subnet536B997A": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "AvailabilityZone": { + "Fn::Select": [ + 0, + { + "Fn::GetAZs": "" + } + ] + }, + "CidrBlock": "10.0.128.0/18", + "MapPublicIpOnLaunch": false, + "Tags": [ + { + "Key": "aws-cdk:subnet-name", + "Value": "Private" + }, + { + "Key": "aws-cdk:subnet-type", + "Value": "Private" + }, + { + "Key": "Name", + "Value": "aws-cdk-redshift-cluster-database/Vpc/PrivateSubnet1" + } + ] + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "VpcPrivateSubnet1RouteTableB2C5B500": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "Tags": [ + { + "Key": "Name", + "Value": "aws-cdk-redshift-cluster-database/Vpc/PrivateSubnet1" + } + ] + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "VpcPrivateSubnet1RouteTableAssociation70C59FA6": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VpcPrivateSubnet1RouteTableB2C5B500" + }, + "SubnetId": { + "Ref": "VpcPrivateSubnet1Subnet536B997A" + } + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "VpcPrivateSubnet1DefaultRouteBE02A9ED": { + "Type": "AWS::EC2::Route", + "Properties": { + "RouteTableId": { + "Ref": "VpcPrivateSubnet1RouteTableB2C5B500" + }, + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": { + "Ref": "VpcPublicSubnet1NATGateway4D7517AA" + } + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "VpcPrivateSubnet2Subnet3788AAA1": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "AvailabilityZone": { + "Fn::Select": [ + 1, + { + "Fn::GetAZs": "" + } + ] + }, + "CidrBlock": "10.0.192.0/18", + "MapPublicIpOnLaunch": false, + "Tags": [ + { + "Key": "aws-cdk:subnet-name", + "Value": "Private" + }, + { + "Key": "aws-cdk:subnet-type", + "Value": "Private" + }, + { + "Key": "Name", + "Value": "aws-cdk-redshift-cluster-database/Vpc/PrivateSubnet2" + } + ] + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "VpcPrivateSubnet2RouteTableA678073B": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "Tags": [ + { + "Key": "Name", + "Value": "aws-cdk-redshift-cluster-database/Vpc/PrivateSubnet2" + } + ] + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "VpcPrivateSubnet2RouteTableAssociationA89CAD56": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VpcPrivateSubnet2RouteTableA678073B" + }, + "SubnetId": { + "Ref": "VpcPrivateSubnet2Subnet3788AAA1" + } + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "VpcPrivateSubnet2DefaultRoute060D2087": { + "Type": "AWS::EC2::Route", + "Properties": { + "RouteTableId": { + "Ref": "VpcPrivateSubnet2RouteTableA678073B" + }, + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": { + "Ref": "VpcPublicSubnet2NATGateway9182C01D" + } + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "VpcIGWD7BA715C": { + "Type": "AWS::EC2::InternetGateway", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": "aws-cdk-redshift-cluster-database/Vpc" + } + ] + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "VpcVPCGWBF912B6E": { + "Type": "AWS::EC2::VPCGatewayAttachment", + "Properties": { + "VpcId": { + "Ref": "Vpc8378EB38" + }, + "InternetGatewayId": { + "Ref": "VpcIGWD7BA715C" + } + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "ClusterSubnetsDCFA5CB7": { + "Type": "AWS::Redshift::ClusterSubnetGroup", + "Properties": { + "Description": "Subnets for Cluster Redshift cluster", + "SubnetIds": [ + { + "Ref": "VpcPublicSubnet1Subnet5C2D37C4" + }, + { + "Ref": "VpcPublicSubnet2Subnet691E08A3" + } + ] + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "ClusterSecurityGroup0921994B": { + "Type": "AWS::EC2::SecurityGroup", + "Properties": { + "GroupDescription": "Redshift security group", + "SecurityGroupEgress": [ + { + "CidrIp": "0.0.0.0/0", + "Description": "Allow all outbound traffic by default", + "IpProtocol": "-1" + } + ], + "VpcId": { + "Ref": "Vpc8378EB38" + } + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "ClusterSecret6368BD0F": { + "Type": "AWS::SecretsManager::Secret", + "Properties": { + "GenerateSecretString": { + "ExcludeCharacters": "\"@/\\ '", + "GenerateStringKey": "password", + "PasswordLength": 30, + "SecretStringTemplate": "{\"username\":\"admin\"}" + } + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "ClusterSecretAttachment769E6258": { + "Type": "AWS::SecretsManager::SecretTargetAttachment", + "Properties": { + "SecretId": { + "Ref": "ClusterSecret6368BD0F" + }, + "TargetId": { + "Ref": "ClusterEB0386A7" + }, + "TargetType": "AWS::Redshift::Cluster" + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "ClusterEB0386A7": { + "Type": "AWS::Redshift::Cluster", + "Properties": { + "ClusterType": "multi-node", + "DBName": "my_db", + "MasterUsername": { + "Fn::Join": [ + "", + [ + "{{resolve:secretsmanager:", + { + "Ref": "ClusterSecret6368BD0F" + }, + ":SecretString:username::}}" + ] + ] + }, + "MasterUserPassword": { + "Fn::Join": [ + "", + [ + "{{resolve:secretsmanager:", + { + "Ref": "ClusterSecret6368BD0F" + }, + ":SecretString:password::}}" + ] + ] + }, + "NodeType": "dc2.large", + "AllowVersionUpgrade": true, + "AutomatedSnapshotRetentionPeriod": 1, + "ClusterParameterGroupName": { + "Ref": "ClusterParameterGroup879806FD" + }, + "ClusterSubnetGroupName": { + "Ref": "ClusterSubnetsDCFA5CB7" + }, + "Encrypted": true, + "KmsKeyId": { + "Ref": "customkmskey377C6F9A" + }, + "NumberOfNodes": 2, + "PubliclyAccessible": true, + "VpcSecurityGroupIds": [ + { + "Fn::GetAtt": [ + "ClusterSecurityGroup0921994B", + "GroupId" + ] + } + ] + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "ClusterParameterGroup879806FD": { + "Type": "AWS::Redshift::ClusterParameterGroup", + "Properties": { + "Description": "Cluster parameter group for family redshift-1.0", + "ParameterGroupFamily": "redshift-1.0", + "Parameters": [ + { + "ParameterName": "enable_user_activity_logging", + "ParameterValue": "true" + } + ] + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "UserSecretE2C04A69": { + "Type": "AWS::SecretsManager::Secret", + "Properties": { + "GenerateSecretString": { + "ExcludeCharacters": "\"@/\\ '", + "GenerateStringKey": "password", + "PasswordLength": 30, + "SecretStringTemplate": "{\"username\":\"awscdkredshiftclusterdatabaseuserc17d5ebd\"}" + } + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "UserSecretAttachment02022609": { + "Type": "AWS::SecretsManager::SecretTargetAttachment", + "Properties": { + "SecretId": { + "Ref": "UserSecretE2C04A69" + }, + "TargetId": { + "Ref": "ClusterEB0386A7" + }, + "TargetType": "AWS::Redshift::Cluster" + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "UserProviderframeworkonEventServiceRole8FBA2FBD": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "ManagedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" }, - "TargetType": "AWS::Redshift::Cluster" - }, - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "ClusterEB0386A7": { - "Type": "AWS::Redshift::Cluster", - "Properties": { - "ClusterType": "multi-node", - "DBName": "my_db", - "MasterUsername": { - "Fn::Join": [ - "", - [ - "{{resolve:secretsmanager:", - { - "Ref": "ClusterSecret6368BD0F" - }, - ":SecretString:username::}}" - ] - ] + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ] + ] + } + ] + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "UserProviderframeworkonEventServiceRoleDefaultPolicy9A9E044F": { + "Type": "AWS::IAM::Policy", + "Properties": { + "PolicyDocument": { + "Statement": [ + { + "Action": "lambda:InvokeFunction", + "Effect": "Allow", + "Resource": [ + { + "Fn::GetAtt": [ + "QueryRedshiftDatabase3de5bea727da479686625efb56431b5f3DF81997", + "Arn" + ] }, - "MasterUserPassword": { - "Fn::Join": [ - "", - [ - "{{resolve:secretsmanager:", - { - "Ref": "ClusterSecret6368BD0F" - }, - ":SecretString:password::}}" + { + "Fn::Join": [ + "", + [ + { + "Fn::GetAtt": [ + "QueryRedshiftDatabase3de5bea727da479686625efb56431b5f3DF81997", + "Arn" ] + }, + ":*" ] - }, - "NodeType": "dc2.large", - "AllowVersionUpgrade": true, - "AutomatedSnapshotRetentionPeriod": 1, - "ClusterParameterGroupName": { - "Ref": "ClusterParameterGroup879806FD" - }, - "ClusterSubnetGroupName": { - "Ref": "ClusterSubnetsDCFA5CB7" - }, - "Encrypted": true, - "KmsKeyId": { - "Ref": "customkmskey377C6F9A" - }, - "NumberOfNodes": 2, - "PubliclyAccessible": true, - "VpcSecurityGroupIds": [ - { - "Fn::GetAtt": ["ClusterSecurityGroup0921994B", "GroupId"] - } - ] - }, - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "ClusterParameterGroup879806FD": { - "Type": "AWS::Redshift::ClusterParameterGroup", - "Properties": { - "Description": "Cluster parameter group for family redshift-1.0", - "ParameterGroupFamily": "redshift-1.0", - "Parameters": [ - { - "ParameterName": "enable_user_activity_logging", - "ParameterValue": "true" - } - ] - }, - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "UserSecretE2C04A69": { - "Type": "AWS::SecretsManager::Secret", - "Properties": { - "GenerateSecretString": { - "ExcludeCharacters": "\"@/\\ '", - "GenerateStringKey": "password", - "PasswordLength": 30, - "SecretStringTemplate": "{\"username\":\"awscdkredshiftclusterdatabaseuserc17d5ebd\"}" + ] } - }, - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "UserSecretAttachment02022609": { - "Type": "AWS::SecretsManager::SecretTargetAttachment", - "Properties": { - "SecretId": { - "Ref": "UserSecretE2C04A69" - }, - "TargetId": { - "Ref": "ClusterEB0386A7" + ] + } + ], + "Version": "2012-10-17" + }, + "PolicyName": "UserProviderframeworkonEventServiceRoleDefaultPolicy9A9E044F", + "Roles": [ + { + "Ref": "UserProviderframeworkonEventServiceRole8FBA2FBD" + } + ] + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "UserProviderframeworkonEvent4EC32885": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": { + "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" + }, + "S3Key": "a8a62b989c7866e3ad5b24f3eb6228f8ca91ebff5f5c76f1da466f6c805c0585.zip" + }, + "Role": { + "Fn::GetAtt": [ + "UserProviderframeworkonEventServiceRole8FBA2FBD", + "Arn" + ] + }, + "Description": "AWS CDK resource provider framework - onEvent (aws-cdk-redshift-cluster-database/User/Resource/Provider)", + "Environment": { + "Variables": { + "USER_ON_EVENT_FUNCTION_ARN": { + "Fn::GetAtt": [ + "QueryRedshiftDatabase3de5bea727da479686625efb56431b5f3DF81997", + "Arn" + ] + } + } + }, + "Handler": "framework.onEvent", + "Runtime": "nodejs14.x", + "Timeout": 900 + }, + "DependsOn": [ + "UserProviderframeworkonEventServiceRoleDefaultPolicy9A9E044F", + "UserProviderframeworkonEventServiceRole8FBA2FBD" + ], + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "UserFDDCDD17": { + "Type": "Custom::RedshiftDatabaseQuery", + "Properties": { + "ServiceToken": { + "Fn::GetAtt": [ + "UserProviderframeworkonEvent4EC32885", + "Arn" + ] + }, + "handler": "user", + "clusterName": { + "Ref": "ClusterEB0386A7" + }, + "adminUserArn": { + "Ref": "ClusterSecretAttachment769E6258" + }, + "databaseName": "my_db", + "username": "awscdkredshiftclusterdatabaseuserc17d5ebd", + "passwordSecretArn": { + "Ref": "UserSecretAttachment02022609" + } + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "UserTablePrivilegesProviderframeworkonEventServiceRole56BAEC9A": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "ManagedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" }, - "TargetType": "AWS::Redshift::Cluster" - }, - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "UserProviderframeworkonEventServiceRole8FBA2FBD": { - "Type": "AWS::IAM::Role", - "Properties": { - "AssumeRolePolicyDocument": { - "Statement": [ - { - "Action": "sts:AssumeRole", - "Effect": "Allow", - "Principal": { - "Service": "lambda.amazonaws.com" - } - } - ], - "Version": "2012-10-17" + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ] + ] + } + ] + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "UserTablePrivilegesProviderframeworkonEventServiceRoleDefaultPolicy3B6EF50C": { + "Type": "AWS::IAM::Policy", + "Properties": { + "PolicyDocument": { + "Statement": [ + { + "Action": "lambda:InvokeFunction", + "Effect": "Allow", + "Resource": [ + { + "Fn::GetAtt": [ + "QueryRedshiftDatabase3de5bea727da479686625efb56431b5f3DF81997", + "Arn" + ] }, - "ManagedPolicyArns": [ - { - "Fn::Join": [ - "", - [ - "arn:", - { - "Ref": "AWS::Partition" - }, - ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" - ] + { + "Fn::Join": [ + "", + [ + { + "Fn::GetAtt": [ + "QueryRedshiftDatabase3de5bea727da479686625efb56431b5f3DF81997", + "Arn" ] - } - ] - }, - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "UserProviderframeworkonEventServiceRoleDefaultPolicy9A9E044F": { - "Type": "AWS::IAM::Policy", - "Properties": { - "PolicyDocument": { - "Statement": [ - { - "Action": "lambda:InvokeFunction", - "Effect": "Allow", - "Resource": [ - { - "Fn::GetAtt": [ - "QueryRedshiftDatabase3de5bea727da479686625efb56431b5f3DF81997", - "Arn" - ] - }, - { - "Fn::Join": [ - "", - [ - { - "Fn::GetAtt": [ - "QueryRedshiftDatabase3de5bea727da479686625efb56431b5f3DF81997", - "Arn" - ] - }, - ":*" - ] - ] - } - ] - } - ], - "Version": "2012-10-17" - }, - "PolicyName": "UserProviderframeworkonEventServiceRoleDefaultPolicy9A9E044F", - "Roles": [ - { - "Ref": "UserProviderframeworkonEventServiceRole8FBA2FBD" - } - ] - }, - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "UserProviderframeworkonEvent4EC32885": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Code": { - "S3Bucket": { - "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" - }, - "S3Key": "a8a62b989c7866e3ad5b24f3eb6228f8ca91ebff5f5c76f1da466f6c805c0585.zip" - }, - "Role": { - "Fn::GetAtt": [ - "UserProviderframeworkonEventServiceRole8FBA2FBD", - "Arn" + }, + ":*" ] - }, - "Description": "AWS CDK resource provider framework - onEvent (aws-cdk-redshift-cluster-database/User/Resource/Provider)", - "Environment": { - "Variables": { - "USER_ON_EVENT_FUNCTION_ARN": { - "Fn::GetAtt": [ - "QueryRedshiftDatabase3de5bea727da479686625efb56431b5f3DF81997", - "Arn" - ] - } - } - }, - "Handler": "framework.onEvent", - "Runtime": "nodejs14.x", - "Timeout": 900 - }, - "DependsOn": [ - "UserProviderframeworkonEventServiceRoleDefaultPolicy9A9E044F", - "UserProviderframeworkonEventServiceRole8FBA2FBD" - ], - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "UserFDDCDD17": { - "Type": "Custom::RedshiftDatabaseQuery", - "Properties": { - "ServiceToken": { - "Fn::GetAtt": ["UserProviderframeworkonEvent4EC32885", "Arn"] - }, - "handler": "user", - "clusterName": { - "Ref": "ClusterEB0386A7" - }, - "adminUserArn": { - "Ref": "ClusterSecretAttachment769E6258" - }, - "databaseName": "my_db", - "username": "awscdkredshiftclusterdatabaseuserc17d5ebd", - "passwordSecretArn": { - "Ref": "UserSecretAttachment02022609" + ] } + ] + } + ], + "Version": "2012-10-17" + }, + "PolicyName": "UserTablePrivilegesProviderframeworkonEventServiceRoleDefaultPolicy3B6EF50C", + "Roles": [ + { + "Ref": "UserTablePrivilegesProviderframeworkonEventServiceRole56BAEC9A" + } + ] + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "UserTablePrivilegesProviderframeworkonEvent3F5C1851": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": { + "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" + }, + "S3Key": "a8a62b989c7866e3ad5b24f3eb6228f8ca91ebff5f5c76f1da466f6c805c0585.zip" + }, + "Role": { + "Fn::GetAtt": [ + "UserTablePrivilegesProviderframeworkonEventServiceRole56BAEC9A", + "Arn" + ] + }, + "Description": "AWS CDK resource provider framework - onEvent (aws-cdk-redshift-cluster-database/User/TablePrivileges/Resource/Provider)", + "Environment": { + "Variables": { + "USER_ON_EVENT_FUNCTION_ARN": { + "Fn::GetAtt": [ + "QueryRedshiftDatabase3de5bea727da479686625efb56431b5f3DF81997", + "Arn" + ] + } + } + }, + "Handler": "framework.onEvent", + "Runtime": "nodejs14.x", + "Timeout": 900 + }, + "DependsOn": [ + "UserTablePrivilegesProviderframeworkonEventServiceRoleDefaultPolicy3B6EF50C", + "UserTablePrivilegesProviderframeworkonEventServiceRole56BAEC9A" + ], + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "UserTablePrivileges3829D614": { + "Type": "Custom::RedshiftDatabaseQuery", + "Properties": { + "ServiceToken": { + "Fn::GetAtt": [ + "UserTablePrivilegesProviderframeworkonEvent3F5C1851", + "Arn" + ] + }, + "handler": "user-table-privileges", + "clusterName": { + "Ref": "ClusterEB0386A7" + }, + "adminUserArn": { + "Ref": "ClusterSecretAttachment769E6258" + }, + "databaseName": "my_db", + "username": { + "Fn::GetAtt": [ + "UserFDDCDD17", + "username" + ] + }, + "tablePrivileges": [ + { + "tableId": "Table", + "tableName": { + "Ref": "Table7ABB320E" }, - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "UserTablePrivilegesProviderframeworkonEventServiceRole56BAEC9A": { - "Type": "AWS::IAM::Role", - "Properties": { - "AssumeRolePolicyDocument": { - "Statement": [ - { - "Action": "sts:AssumeRole", - "Effect": "Allow", - "Principal": { - "Service": "lambda.amazonaws.com" - } - } - ], - "Version": "2012-10-17" - }, - "ManagedPolicyArns": [ - { - "Fn::Join": [ - "", - [ - "arn:", - { - "Ref": "AWS::Partition" - }, - ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" - ] - ] - } - ] - }, - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "UserTablePrivilegesProviderframeworkonEventServiceRoleDefaultPolicy3B6EF50C": { - "Type": "AWS::IAM::Policy", - "Properties": { - "PolicyDocument": { - "Statement": [ - { - "Action": "lambda:InvokeFunction", - "Effect": "Allow", - "Resource": [ - { - "Fn::GetAtt": [ - "QueryRedshiftDatabase3de5bea727da479686625efb56431b5f3DF81997", - "Arn" - ] - }, - { - "Fn::Join": [ - "", - [ - { - "Fn::GetAtt": [ - "QueryRedshiftDatabase3de5bea727da479686625efb56431b5f3DF81997", - "Arn" - ] - }, - ":*" - ] - ] - } - ] - } - ], - "Version": "2012-10-17" - }, - "PolicyName": "UserTablePrivilegesProviderframeworkonEventServiceRoleDefaultPolicy3B6EF50C", - "Roles": [ - { - "Ref": "UserTablePrivilegesProviderframeworkonEventServiceRole56BAEC9A" - } - ] - }, - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "UserTablePrivilegesProviderframeworkonEvent3F5C1851": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Code": { - "S3Bucket": { - "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" - }, - "S3Key": "a8a62b989c7866e3ad5b24f3eb6228f8ca91ebff5f5c76f1da466f6c805c0585.zip" - }, - "Role": { - "Fn::GetAtt": [ - "UserTablePrivilegesProviderframeworkonEventServiceRole56BAEC9A", - "Arn" - ] - }, - "Description": "AWS CDK resource provider framework - onEvent (aws-cdk-redshift-cluster-database/User/TablePrivileges/Resource/Provider)", - "Environment": { - "Variables": { - "USER_ON_EVENT_FUNCTION_ARN": { - "Fn::GetAtt": [ - "QueryRedshiftDatabase3de5bea727da479686625efb56431b5f3DF81997", - "Arn" - ] - } - } - }, - "Handler": "framework.onEvent", - "Runtime": "nodejs14.x", - "Timeout": 900 - }, - "DependsOn": [ - "UserTablePrivilegesProviderframeworkonEventServiceRoleDefaultPolicy3B6EF50C", - "UserTablePrivilegesProviderframeworkonEventServiceRole56BAEC9A" - ], - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "UserTablePrivileges3829D614": { - "Type": "Custom::RedshiftDatabaseQuery", - "Properties": { - "ServiceToken": { - "Fn::GetAtt": [ - "UserTablePrivilegesProviderframeworkonEvent3F5C1851", - "Arn" - ] - }, - "handler": "user-table-privileges", - "clusterName": { - "Ref": "ClusterEB0386A7" - }, - "adminUserArn": { - "Ref": "ClusterSecretAttachment769E6258" - }, - "databaseName": "my_db", - "username": { - "Fn::GetAtt": ["UserFDDCDD17", "username"] - }, - "tablePrivileges": [ - { - "tableName": { - "Ref": "Table7ABB320E" - }, - "actions": ["INSERT", "DELETE", "SELECT"] - } - ] - }, - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "QueryRedshiftDatabase3de5bea727da479686625efb56431b5fServiceRole0A90D717": { - "Type": "AWS::IAM::Role", - "Properties": { - "AssumeRolePolicyDocument": { - "Statement": [ - { - "Action": "sts:AssumeRole", - "Effect": "Allow", - "Principal": { - "Service": "lambda.amazonaws.com" - } - } - ], - "Version": "2012-10-17" - }, - "ManagedPolicyArns": [ - { - "Fn::Join": [ - "", - [ - "arn:", - { - "Ref": "AWS::Partition" - }, - ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" - ] - ] - } - ] - }, - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "QueryRedshiftDatabase3de5bea727da479686625efb56431b5fServiceRoleDefaultPolicyDDD1388D": { - "Type": "AWS::IAM::Policy", - "Properties": { - "PolicyDocument": { - "Statement": [ - { - "Action": [ - "redshift-data:DescribeStatement", - "redshift-data:ExecuteStatement" - ], - "Effect": "Allow", - "Resource": "*" - }, - { - "Action": [ - "secretsmanager:DescribeSecret", - "secretsmanager:GetSecretValue" - ], - "Effect": "Allow", - "Resource": [ - { - "Ref": "ClusterSecretAttachment769E6258" - }, - { - "Ref": "UserSecretAttachment02022609" - } - ] - } - ], - "Version": "2012-10-17" + "actions": [ + "INSERT", + "DELETE", + "SELECT" + ] + } + ] + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "QueryRedshiftDatabase3de5bea727da479686625efb56431b5fServiceRole0A90D717": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "ManagedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" }, - "PolicyName": "QueryRedshiftDatabase3de5bea727da479686625efb56431b5fServiceRoleDefaultPolicyDDD1388D", - "Roles": [ - { - "Ref": "QueryRedshiftDatabase3de5bea727da479686625efb56431b5fServiceRole0A90D717" - } - ] + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ] + ] + } + ] + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "QueryRedshiftDatabase3de5bea727da479686625efb56431b5fServiceRoleDefaultPolicyDDD1388D": { + "Type": "AWS::IAM::Policy", + "Properties": { + "PolicyDocument": { + "Statement": [ + { + "Action": [ + "redshift-data:DescribeStatement", + "redshift-data:ExecuteStatement" + ], + "Effect": "Allow", + "Resource": "*" }, - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "QueryRedshiftDatabase3de5bea727da479686625efb56431b5f3DF81997": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Code": { - "S3Bucket": { - "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" - }, - "S3Key": "169a8c0beb97c903ee155ea9653e39b0884c9e3b860ac72ffbe906b3c1f4e338.zip" + { + "Action": [ + "secretsmanager:DescribeSecret", + "secretsmanager:GetSecretValue" + ], + "Effect": "Allow", + "Resource": [ + { + "Ref": "ClusterSecretAttachment769E6258" }, - "Role": { - "Fn::GetAtt": [ - "QueryRedshiftDatabase3de5bea727da479686625efb56431b5fServiceRole0A90D717", - "Arn" - ] + { + "Ref": "UserSecretAttachment02022609" + } + ] + } + ], + "Version": "2012-10-17" + }, + "PolicyName": "QueryRedshiftDatabase3de5bea727da479686625efb56431b5fServiceRoleDefaultPolicyDDD1388D", + "Roles": [ + { + "Ref": "QueryRedshiftDatabase3de5bea727da479686625efb56431b5fServiceRole0A90D717" + } + ] + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "QueryRedshiftDatabase3de5bea727da479686625efb56431b5f3DF81997": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": { + "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" + }, + "S3Key": "df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a.zip" + }, + "Role": { + "Fn::GetAtt": [ + "QueryRedshiftDatabase3de5bea727da479686625efb56431b5fServiceRole0A90D717", + "Arn" + ] + }, + "Handler": "index.handler", + "Runtime": "nodejs14.x", + "Timeout": 60 + }, + "DependsOn": [ + "QueryRedshiftDatabase3de5bea727da479686625efb56431b5fServiceRoleDefaultPolicyDDD1388D", + "QueryRedshiftDatabase3de5bea727da479686625efb56431b5fServiceRole0A90D717" + ], + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "TableProviderframeworkonEventServiceRoleC3128F67": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "ManagedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" }, - "Handler": "index.handler", - "Runtime": "nodejs14.x", - "Timeout": 60 - }, - "DependsOn": [ - "QueryRedshiftDatabase3de5bea727da479686625efb56431b5fServiceRoleDefaultPolicyDDD1388D", - "QueryRedshiftDatabase3de5bea727da479686625efb56431b5fServiceRole0A90D717" - ], - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "TableProviderframeworkonEventServiceRoleC3128F67": { - "Type": "AWS::IAM::Role", - "Properties": { - "AssumeRolePolicyDocument": { - "Statement": [ - { - "Action": "sts:AssumeRole", - "Effect": "Allow", - "Principal": { - "Service": "lambda.amazonaws.com" - } - } - ], - "Version": "2012-10-17" + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ] + ] + } + ] + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "TableProviderframeworkonEventServiceRoleDefaultPolicyAD08715D": { + "Type": "AWS::IAM::Policy", + "Properties": { + "PolicyDocument": { + "Statement": [ + { + "Action": "lambda:InvokeFunction", + "Effect": "Allow", + "Resource": [ + { + "Fn::GetAtt": [ + "QueryRedshiftDatabase3de5bea727da479686625efb56431b5f3DF81997", + "Arn" + ] }, - "ManagedPolicyArns": [ - { - "Fn::Join": [ - "", - [ - "arn:", - { - "Ref": "AWS::Partition" - }, - ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" - ] + { + "Fn::Join": [ + "", + [ + { + "Fn::GetAtt": [ + "QueryRedshiftDatabase3de5bea727da479686625efb56431b5f3DF81997", + "Arn" ] - } - ] - }, - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "TableProviderframeworkonEventServiceRoleDefaultPolicyAD08715D": { - "Type": "AWS::IAM::Policy", - "Properties": { - "PolicyDocument": { - "Statement": [ - { - "Action": "lambda:InvokeFunction", - "Effect": "Allow", - "Resource": [ - { - "Fn::GetAtt": [ - "QueryRedshiftDatabase3de5bea727da479686625efb56431b5f3DF81997", - "Arn" - ] - }, - { - "Fn::Join": [ - "", - [ - { - "Fn::GetAtt": [ - "QueryRedshiftDatabase3de5bea727da479686625efb56431b5f3DF81997", - "Arn" - ] - }, - ":*" - ] - ] - } - ] - } - ], - "Version": "2012-10-17" - }, - "PolicyName": "TableProviderframeworkonEventServiceRoleDefaultPolicyAD08715D", - "Roles": [ - { - "Ref": "TableProviderframeworkonEventServiceRoleC3128F67" - } - ] - }, - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "TableProviderframeworkonEvent97F3951A": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Code": { - "S3Bucket": { - "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" - }, - "S3Key": "a8a62b989c7866e3ad5b24f3eb6228f8ca91ebff5f5c76f1da466f6c805c0585.zip" - }, - "Role": { - "Fn::GetAtt": [ - "TableProviderframeworkonEventServiceRoleC3128F67", - "Arn" + }, + ":*" ] - }, - "Description": "AWS CDK resource provider framework - onEvent (aws-cdk-redshift-cluster-database/Table/Resource/Provider)", - "Environment": { - "Variables": { - "USER_ON_EVENT_FUNCTION_ARN": { - "Fn::GetAtt": [ - "QueryRedshiftDatabase3de5bea727da479686625efb56431b5f3DF81997", - "Arn" - ] - } - } - }, - "Handler": "framework.onEvent", - "Runtime": "nodejs14.x", - "Timeout": 900 - }, - "DependsOn": [ - "TableProviderframeworkonEventServiceRoleDefaultPolicyAD08715D", - "TableProviderframeworkonEventServiceRoleC3128F67" - ], - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - }, - "Table7ABB320E": { - "Type": "Custom::RedshiftDatabaseQuery", - "Properties": { - "ServiceToken": { - "Fn::GetAtt": ["TableProviderframeworkonEvent97F3951A", "Arn"] - }, - "handler": "table", - "clusterName": { - "Ref": "ClusterEB0386A7" - }, - "adminUserArn": { - "Ref": "ClusterSecretAttachment769E6258" - }, - "databaseName": "my_db", - "tableName": { - "prefix": "awscdkredshiftclusterdatabaseTable24923533", - "generateSuffix": "true" - }, - "tableColumns": [ - { - "name": "col1", - "dataType": "varchar(4)", - "distKey": true, - "comment": "A test column", - "encoding": "LZO" - }, - { - "name": "col2", - "dataType": "float", - "sortKey": true, - "comment": "A test column" - }, - { - "name": "col3", - "dataType": "float", - "comment": "A test column", - "encoding": "RAW" - } - ], - "distStyle": "KEY", - "sortStyle": "INTERLEAVED", - "tableComment": "A test table", - "useColumnIds": true - }, - "UpdateReplacePolicy": "Delete", - "DeletionPolicy": "Delete" - } + ] + } + ] + } + ], + "Version": "2012-10-17" + }, + "PolicyName": "TableProviderframeworkonEventServiceRoleDefaultPolicyAD08715D", + "Roles": [ + { + "Ref": "TableProviderframeworkonEventServiceRoleC3128F67" + } + ] + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" }, - "Parameters": { - "BootstrapVersion": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/cdk-bootstrap/hnb659fds/version", - "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" - } + "TableProviderframeworkonEvent97F3951A": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": { + "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" + }, + "S3Key": "a8a62b989c7866e3ad5b24f3eb6228f8ca91ebff5f5c76f1da466f6c805c0585.zip" + }, + "Role": { + "Fn::GetAtt": [ + "TableProviderframeworkonEventServiceRoleC3128F67", + "Arn" + ] + }, + "Description": "AWS CDK resource provider framework - onEvent (aws-cdk-redshift-cluster-database/Table/Resource/Provider)", + "Environment": { + "Variables": { + "USER_ON_EVENT_FUNCTION_ARN": { + "Fn::GetAtt": [ + "QueryRedshiftDatabase3de5bea727da479686625efb56431b5f3DF81997", + "Arn" + ] + } + } + }, + "Handler": "framework.onEvent", + "Runtime": "nodejs14.x", + "Timeout": 900 + }, + "DependsOn": [ + "TableProviderframeworkonEventServiceRoleDefaultPolicyAD08715D", + "TableProviderframeworkonEventServiceRoleC3128F67" + ], + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" }, - "Rules": { - "CheckBootstrapVersion": { - "Assertions": [ - { - "Assert": { - "Fn::Not": [ - { - "Fn::Contains": [ - ["1", "2", "3", "4", "5"], - { - "Ref": "BootstrapVersion" - } - ] - } - ] - }, - "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." - } + "Table7ABB320E": { + "Type": "Custom::RedshiftDatabaseQuery", + "Properties": { + "ServiceToken": { + "Fn::GetAtt": [ + "TableProviderframeworkonEvent97F3951A", + "Arn" + ] + }, + "handler": "table", + "clusterName": { + "Ref": "ClusterEB0386A7" + }, + "adminUserArn": { + "Ref": "ClusterSecretAttachment769E6258" + }, + "databaseName": "my_db", + "tableName": { + "prefix": "awscdkredshiftclusterdatabaseTable24923533", + "generateSuffix": "true" + }, + "tableColumns": [ + { + "name": "col1", + "dataType": "varchar(4)", + "distKey": true, + "comment": "A test column", + "encoding": "LZO" + }, + { + "name": "col2", + "dataType": "float", + "sortKey": true, + "comment": "A test column" + }, + { + "name": "col3", + "dataType": "float", + "comment": "A test column", + "encoding": "RAW" + } + ], + "distStyle": "KEY", + "sortStyle": "INTERLEAVED", + "tableComment": "A test table", + "useColumnIds": true + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + } + }, + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." } + ] } -} + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/cdk.out b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/cdk.out index 22aff0ee1a3eb..7925065efbcc4 100644 --- a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/cdk.out +++ b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/cdk.out @@ -1 +1 @@ -{"version":"30.1.0"} +{"version":"31.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/integ.json b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/integ.json index f38ac471f573e..fc3008141193f 100644 --- a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/integ.json +++ b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/integ.json @@ -1,10 +1,12 @@ { - "version": "30.1.0", + "version": "31.0.0", "testCases": { "redshift-cluster-database-integ/DefaultTest": { - "stacks": ["aws-cdk-redshift-cluster-database"], + "stacks": [ + "aws-cdk-redshift-cluster-database" + ], "assertionStack": "redshift-cluster-database-integ/DefaultTest/DeployAssert", "assertionStackName": "redshiftclusterdatabaseintegDefaultTestDeployAssert4339FB48" } } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/manifest.json b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/manifest.json index 371f1970d61c0..314941f6ad571 100644 --- a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/manifest.json +++ b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/manifest.json @@ -1,5 +1,5 @@ { - "version": "30.1.0", + "version": "31.0.0", "artifacts": { "aws-cdk-redshift-cluster-database.assets": { "type": "cdk:asset-manifest", @@ -17,17 +17,21 @@ "validateOnSynth": false, "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/297bfa1758edc6b71a084153702165132d111eb7914b4bf8ed951da4b98faede.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/f2cf2a437f9007286a4d7bc2cb4d6008231236f7c800e4503142a26d808b75d7.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", - "additionalDependencies": ["aws-cdk-redshift-cluster-database.assets"], + "additionalDependencies": [ + "aws-cdk-redshift-cluster-database.assets" + ], "lookupRole": { "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", "requiresBootstrapStackVersion": 8, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" } }, - "dependencies": ["aws-cdk-redshift-cluster-database.assets"], + "dependencies": [ + "aws-cdk-redshift-cluster-database.assets" + ], "metadata": { "/aws-cdk-redshift-cluster-database/custom-kms-key/Resource": [ { @@ -380,4 +384,4 @@ } } } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/redshiftclusterdatabaseintegDefaultTestDeployAssert4339FB48.assets.json b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/redshiftclusterdatabaseintegDefaultTestDeployAssert4339FB48.assets.json index 76d14311f460d..9613960c74a68 100644 --- a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/redshiftclusterdatabaseintegDefaultTestDeployAssert4339FB48.assets.json +++ b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/redshiftclusterdatabaseintegDefaultTestDeployAssert4339FB48.assets.json @@ -1,5 +1,5 @@ { - "version": "30.1.0", + "version": "31.0.0", "files": { "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { "source": { @@ -16,4 +16,4 @@ } }, "dockerImages": {} -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/tree.json b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/tree.json index 1a18995b967cc..9b35f754c7499 100644 --- a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/tree.json +++ b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/tree.json @@ -1228,7 +1228,7 @@ }, "constructInfo": { "fqn": "constructs.Construct", - "version": "10.1.252" + "version": "10.1.264" } }, "TablePrivileges": { @@ -1470,13 +1470,13 @@ }, "constructInfo": { "fqn": "constructs.Construct", - "version": "10.1.252" + "version": "10.1.264" } } }, "constructInfo": { "fqn": "constructs.Construct", - "version": "10.1.252" + "version": "10.1.264" } } }, @@ -1639,7 +1639,7 @@ "s3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "s3Key": "169a8c0beb97c903ee155ea9653e39b0884c9e3b860ac72ffbe906b3c1f4e338.zip" + "s3Key": "df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a.zip" }, "role": { "Fn::GetAtt": [ @@ -1902,7 +1902,7 @@ }, "constructInfo": { "fqn": "constructs.Construct", - "version": "10.1.252" + "version": "10.1.264" } } }, @@ -1946,7 +1946,7 @@ "path": "redshift-cluster-database-integ/DefaultTest/Default", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.1.252" + "version": "10.1.264" } }, "DeployAssert": { @@ -1992,7 +1992,7 @@ "path": "Tree", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.1.252" + "version": "10.1.264" } } }, @@ -2001,4 +2001,4 @@ "version": "0.0.0" } } -} +} \ No newline at end of file From 88582a024bf1e090193500d602f4b6232bf9b9cd Mon Sep 17 00:00:00 2001 From: Rizbir Khan Date: Thu, 30 Mar 2023 15:55:12 +0000 Subject: [PATCH 02/21] post integration snapshot --- .../handler-name.js | 10 + .../index.js | 21 +++ .../privileges.js | 69 +++++++ .../redshift-data.js | 37 ++++ .../table.js | 171 ++++++++++++++++++ .../types.js | 24 +++ .../user.js | 70 +++++++ .../util.js | 34 ++++ 8 files changed, 436 insertions(+) create mode 100644 packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/handler-name.js create mode 100644 packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/index.js create mode 100644 packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/privileges.js create mode 100644 packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/redshift-data.js create mode 100644 packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/table.js create mode 100644 packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/types.js create mode 100644 packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/user.js create mode 100644 packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/util.js diff --git a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/handler-name.js b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/handler-name.js new file mode 100644 index 0000000000000..4983115a93834 --- /dev/null +++ b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/handler-name.js @@ -0,0 +1,10 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.HandlerName = void 0; +var HandlerName; +(function (HandlerName) { + HandlerName["User"] = "user"; + HandlerName["Table"] = "table"; + HandlerName["UserTablePrivileges"] = "user-table-privileges"; +})(HandlerName = exports.HandlerName || (exports.HandlerName = {})); +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGFuZGxlci1uYW1lLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiaGFuZGxlci1uYW1lLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLElBQVksV0FJWDtBQUpELFdBQVksV0FBVztJQUNyQiw0QkFBYSxDQUFBO0lBQ2IsOEJBQWUsQ0FBQTtJQUNmLDREQUE2QyxDQUFBO0FBQy9DLENBQUMsRUFKVyxXQUFXLEdBQVgsbUJBQVcsS0FBWCxtQkFBVyxRQUl0QiIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBlbnVtIEhhbmRsZXJOYW1lIHtcbiAgVXNlciA9ICd1c2VyJyxcbiAgVGFibGUgPSAndGFibGUnLFxuICBVc2VyVGFibGVQcml2aWxlZ2VzID0gJ3VzZXItdGFibGUtcHJpdmlsZWdlcycsXG59XG4iXX0= \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/index.js b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/index.js new file mode 100644 index 0000000000000..d7a8b52f2944c --- /dev/null +++ b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/index.js @@ -0,0 +1,21 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.handler = void 0; +const handler_name_1 = require("./handler-name"); +const privileges_1 = require("./privileges"); +const table_1 = require("./table"); +const user_1 = require("./user"); +const HANDLERS = { + [handler_name_1.HandlerName.Table]: table_1.handler, + [handler_name_1.HandlerName.User]: user_1.handler, + [handler_name_1.HandlerName.UserTablePrivileges]: privileges_1.handler, +}; +async function handler(event) { + const subHandler = HANDLERS[event.ResourceProperties.handler]; + if (!subHandler) { + throw new Error(`Requested handler ${event.ResourceProperties.handler} is not in supported set: ${JSON.stringify(Object.keys(HANDLERS))}`); + } + return subHandler(event.ResourceProperties, event); +} +exports.handler = handler; +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJpbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFFQSxpREFBNkM7QUFDN0MsNkNBQTJEO0FBQzNELG1DQUFpRDtBQUNqRCxpQ0FBK0M7QUFFL0MsTUFBTSxRQUFRLEdBQWlIO0lBQzdILENBQUMsMEJBQVcsQ0FBQyxLQUFLLENBQUMsRUFBRSxlQUFXO0lBQ2hDLENBQUMsMEJBQVcsQ0FBQyxJQUFJLENBQUMsRUFBRSxjQUFVO0lBQzlCLENBQUMsMEJBQVcsQ0FBQyxtQkFBbUIsQ0FBQyxFQUFFLG9CQUFnQjtDQUNwRCxDQUFDO0FBRUssS0FBSyxVQUFVLE9BQU8sQ0FBQyxLQUFrRDtJQUM5RSxNQUFNLFVBQVUsR0FBRyxRQUFRLENBQUMsS0FBSyxDQU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FnZVVzZXIsXG4gIFtIYW5kbGVyTmFtZS5Vc2VyVGFibGVQcml2aWxlZ2VzXTogbWFuYWdlUHJpdmlsZWdlcyxcbn07XG5cbmV4cG9ydCBhc3luYyBmdW5jdGlvbiBoYW5kbGVyKGV2ZW50OiBBV1NMYW1iZGEuQ2xvdWRGb3JtYXRpb25DdXN0b21SZXNvdXJjZUV2ZW50KSB7XG4gIGNvbnN0IHN1YkhhbmRsZXIgPSBIQU5ETEVSU1tldmVudC5SZXNvdXJjZVByb3BlcnRpZXMuaGFuZGxlciBhcyBIYW5kbGVyTmFtZV07XG4gIGlmICghc3ViSGFuZGxlcikge1xuICAgIHRocm93IG5ldyBFcnJvcihgUmVxdWVzdGVkIGhhbmRsZXIgJHtldmVudC5SZXNvdXJjZVByb3BlcnRpZXMuaGFuZGxlcn0gaXMgbm90IGluIHN1cHBvcnRlZCBzZXQ6ICR7SlNPTi5zdHJpbmdpZnkoT2JqZWN0LmtleXMoSEFORExFUlMpKX1gKTtcbiAgfVxuICByZXR1cm4gc3ViSGFuZGxlcihldmVudC5SZXNvdXJjZVByb3BlcnRpZXMsIGV2ZW50KTtcbn1cbiJdfQ== \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/privileges.js b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/privileges.js new file mode 100644 index 0000000000000..ce2abc7191d26 --- /dev/null +++ b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/privileges.js @@ -0,0 +1,69 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.handler = void 0; +const redshift_data_1 = require("./redshift-data"); +const util_1 = require("./util"); +async function handler(props, event) { + const username = props.username; + const tablePrivileges = props.tablePrivileges; + const clusterProps = props; + if (event.RequestType === 'Create') { + await grantPrivileges(username, tablePrivileges, clusterProps); + return { PhysicalResourceId: util_1.makePhysicalId(username, clusterProps, event.RequestId) }; + } + else if (event.RequestType === 'Delete') { + await revokePrivileges(username, tablePrivileges, clusterProps); + return; + } + else if (event.RequestType === 'Update') { + const { replace } = await updatePrivileges(username, tablePrivileges, clusterProps, event.OldResourceProperties); + const physicalId = replace ? util_1.makePhysicalId(username, clusterProps, event.RequestId) : event.PhysicalResourceId; + return { PhysicalResourceId: physicalId }; + } + else { + /* eslint-disable-next-line dot-notation */ + throw new Error(`Unrecognized event type: ${event['RequestType']}`); + } +} +exports.handler = handler; +async function revokePrivileges(username, tablePrivileges, clusterProps) { + await Promise.all(tablePrivileges.map(({ tableName, actions }) => { + return redshift_data_1.executeStatement(`REVOKE ${actions.join(', ')} ON ${tableName} FROM ${username}`, clusterProps); + })); +} +async function grantPrivileges(username, tablePrivileges, clusterProps) { + await Promise.all(tablePrivileges.map(({ tableName, actions }) => { + return redshift_data_1.executeStatement(`GRANT ${actions.join(', ')} ON ${tableName} TO ${username}`, clusterProps); + })); +} +async function updatePrivileges(username, tablePrivileges, clusterProps, oldResourceProperties) { + const oldClusterProps = oldResourceProperties; + if (clusterProps.clusterName !== oldClusterProps.clusterName || clusterProps.databaseName !== oldClusterProps.databaseName) { + await grantPrivileges(username, tablePrivileges, clusterProps); + return { replace: true }; + } + const oldUsername = oldResourceProperties.username; + if (oldUsername !== username) { + await grantPrivileges(username, tablePrivileges, clusterProps); + return { replace: true }; + } + const oldTablePrivileges = oldResourceProperties.tablePrivileges; + const tablesToRevoke = oldTablePrivileges.filter(({ tableId, actions }) => { + const tableRemoved = !tablePrivileges.find(({ tableId: otherTableId }) => tableId === otherTableId); + const actionsRemoved = tablePrivileges.find(({ tableId: otherTableId, actions: otherActions }) => (tableId === otherTableId && actions.some(action => !otherActions.includes(action)))); + return tableRemoved || actionsRemoved; + }); + if (tablesToRevoke.length > 0) { + await revokePrivileges(username, tablesToRevoke, clusterProps); + } + const tablesToGrant = tablePrivileges.filter(({ tableId, tableName, actions }) => { + const tableAdded = !oldTablePrivileges.find(({ tableId: otherTableId, tableName: otherTableName }) => (tableId === otherTableId && tableName === otherTableName)); + const actionsAdded = oldTablePrivileges.find(({ tableId: otherTableId, actions: otherActions }) => (tableId === otherTableId && otherActions.some(action => !actions.includes(action)))); + return tableAdded || actionsAdded; + }); + if (tablesToGrant.length > 0) { + await grantPrivileges(username, tablesToGrant, clusterProps); + } + return { replace: false }; +} +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJpdmlsZWdlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInByaXZpbGVnZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBRUEsbURBQW1EO0FBRW5ELGlDQUF3QztBQUdqQyxLQUFLLFVBQVUsT0FBTyxDQUFDLEtBQXFELEVBQUUsS0FBa0Q7SUFDckksTUFBTSxRQUFRLEdBQUcsS0FBSyxDQUFDLFFBQVEsQ0FBQztJQUNoQyxNQUFNLGVBQWUsR0FBRyxLQUFLLENBQUMsZUFBZSxDQUFDO0lBQzlDLE1BQU0sWUFBWSxHQUFHLEtBQUssQ0FBQztJQUUzQixJQUFJLEtBQUssQ0FBQyxXQUFXLEtBQUssUUFBUSxFQUFFO1FBQ2xDLE1BQU0sZUFBZSxDQUFDLFFBQVEsRUFBRSxlQUFlLEVBQUUsWUFBWSxDQUFDLENBQUM7UUFDL0QsT0FBTyxFQUFFLGtCQUFrQixFQUFFLHFCQUFjLENBQUMsUUFBUSxFQUFFLFlBQVksRUFBRSxLQUFLLENBQUMsU0FBUyxDQUFDLEVBQUUsQ0FBQztLQUN4RjtTQUFNLElBQUksS0FBSyxDQUFDLFdBQVcsS0FBSyxRQUFRLEVBQUU7UUFDekMsTUFBTSxnQkFBZ0IsQ0FBQyxRQUFRLEVBQU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vbnMgfSkgPT4ge1xuICAgIGNvbnN0IHRhYmxlQWRkZWQgPSAhb2xkVGFibGVQcml2aWxlZ2VzLmZpbmQoKHsgdGFibGVJZDogb3RoZXJUYWJsZUlkLCB0YWJsZU5hbWU6IG90aGVyVGFibGVOYW1lIH0pID0+IChcbiAgICAgIHRhYmxlSWQgPT09IG90aGVyVGFibGVJZCAmJiB0YWJsZU5hbWUgPT09IG90aGVyVGFibGVOYW1lXG4gICAgKSk7XG4gICAgY29uc3QgYWN0aW9uc0FkZGVkID0gb2xkVGFibGVQcml2aWxlZ2VzLmZpbmQoKHsgdGFibGVJZDogb3RoZXJUYWJsZUlkLCBhY3Rpb25zOiBvdGhlckFjdGlvbnMgfSkgPT4gKFxuICAgICAgdGFibGVJZCA9PT0gb3RoZXJUYWJsZUlkICYmIG90aGVyQWN0aW9ucy5zb21lKGFjdGlvbiA9PiAhYWN0aW9ucy5pbmNsdWRlcyhhY3Rpb24pKVxuICAgICkpO1xuICAgIHJldHVybiB0YWJsZUFkZGVkIHx8IGFjdGlvbnNBZGRlZDtcbiAgfSk7XG4gIGlmICh0YWJsZXNUb0dyYW50Lmxlbmd0aCA+IDApIHtcbiAgICBhd2FpdCBncmFudFByaXZpbGVnZXModXNlcm5hbWUsIHRhYmxlc1RvR3JhbnQsIGNsdXN0ZXJQcm9wcyk7XG4gIH1cblxuICByZXR1cm4geyByZXBsYWNlOiBmYWxzZSB9O1xufVxuIl19 \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/redshift-data.js b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/redshift-data.js new file mode 100644 index 0000000000000..e65374f4ab7e0 --- /dev/null +++ b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/redshift-data.js @@ -0,0 +1,37 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.executeStatement = void 0; +/* eslint-disable-next-line import/no-extraneous-dependencies */ +const RedshiftData = require("aws-sdk/clients/redshiftdata"); +const redshiftData = new RedshiftData(); +async function executeStatement(statement, clusterProps) { + const executeStatementProps = { + ClusterIdentifier: clusterProps.clusterName, + Database: clusterProps.databaseName, + SecretArn: clusterProps.adminUserArn, + Sql: statement, + }; + const executedStatement = await redshiftData.executeStatement(executeStatementProps).promise(); + if (!executedStatement.Id) { + throw new Error('Service error: Statement execution did not return a statement ID'); + } + await waitForStatementComplete(executedStatement.Id); +} +exports.executeStatement = executeStatement; +const waitTimeout = 100; +async function waitForStatementComplete(statementId) { + await new Promise((resolve) => { + setTimeout(() => resolve(), waitTimeout); + }); + const statement = await redshiftData.describeStatement({ Id: statementId }).promise(); + if (statement.Status !== 'FINISHED' && statement.Status !== 'FAILED' && statement.Status !== 'ABORTED') { + return waitForStatementComplete(statementId); + } + else if (statement.Status === 'FINISHED') { + return; + } + else { + throw new Error(`Statement status was ${statement.Status}: ${statement.Error}`); + } +} +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVkc2hpZnQtZGF0YS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInJlZHNoaWZ0LWRhdGEudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsZ0VBQWdFO0FBQ2hFLDZEQUE2RDtBQUc3RCxNQUFNLFlBQVksR0FBRyxJQUFJLFlBQVksRUFBRSxDQUFDO0FBRWpDLEtBQUssVUFBVSxnQkFBZ0IsQ0FBQyxTQUFpQixFQUFFLFlBQTBCO0lBQ2xGLE1BQU0scUJBQXFCLEdBQUc7UUFDNUIsaUJBQWlCLEVBQUUsWUFBWSxDQUFDLFdBQVc7UUFDM0MsUUFBUSxFQUFFLFlBQ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packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/table.js b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/table.js new file mode 100644 index 0000000000000..8b7f3f6a680fa --- /dev/null +++ b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/table.js @@ -0,0 +1,171 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.handler = void 0; +const redshift_data_1 = require("./redshift-data"); +const types_1 = require("./types"); +const util_1 = require("./util"); +async function handler(props, event) { + const tableNamePrefix = props.tableName.prefix; + const tableNameSuffix = props.tableName.generateSuffix === 'true' ? `${event.RequestId.substring(0, 8)}` : ''; + const tableColumns = props.tableColumns; + const tableAndClusterProps = props; + const useColumnIds = props.useColumnIds; + if (event.RequestType === 'Create') { + const tableName = await createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps); + return { PhysicalResourceId: tableName }; + } + else if (event.RequestType === 'Delete') { + await dropTable(event.PhysicalResourceId, tableAndClusterProps); + return; + } + else if (event.RequestType === 'Update') { + const tableName = await updateTable(event.PhysicalResourceId, tableNamePrefix, tableNameSuffix, tableColumns, useColumnIds, tableAndClusterProps, event.OldResourceProperties); + return { PhysicalResourceId: tableName }; + } + else { + /* eslint-disable-next-line dot-notation */ + throw new Error(`Unrecognized event type: ${event['RequestType']}`); + } +} +exports.handler = handler; +async function createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps) { + const tableName = tableNamePrefix + tableNameSuffix; + const tableColumnsString = tableColumns.map(column => `${column.name} ${column.dataType}${getEncodingColumnString(column)}`).join(); + let statement = `CREATE TABLE ${tableName} (${tableColumnsString})`; + if (tableAndClusterProps.distStyle) { + statement += ` DISTSTYLE ${tableAndClusterProps.distStyle}`; + } + const distKeyColumn = util_1.getDistKeyColumn(tableColumns); + if (distKeyColumn) { + statement += ` DISTKEY(${distKeyColumn.name})`; + } + const sortKeyColumns = util_1.getSortKeyColumns(tableColumns); + if (sortKeyColumns.length > 0) { + const sortKeyColumnsString = getSortKeyColumnsString(sortKeyColumns); + statement += ` ${tableAndClusterProps.sortStyle} SORTKEY(${sortKeyColumnsString})`; + } + await redshift_data_1.executeStatement(statement, tableAndClusterProps); + for (const column of tableColumns) { + if (column.comment) { + await redshift_data_1.executeStatement(`COMMENT ON COLUMN ${tableName}.${column.name} IS '${column.comment}'`, tableAndClusterProps); + } + } + if (tableAndClusterProps.tableComment) { + await redshift_data_1.executeStatement(`COMMENT ON TABLE ${tableName} IS '${tableAndClusterProps.tableComment}'`, tableAndClusterProps); + } + return tableName; +} +async function dropTable(tableName, clusterProps) { + await redshift_data_1.executeStatement(`DROP TABLE ${tableName}`, clusterProps); +} +async function updateTable(tableName, tableNamePrefix, tableNameSuffix, tableColumns, useColumnIds, tableAndClusterProps, oldResourceProperties) { + const alterationStatements = []; + const oldClusterProps = oldResourceProperties; + if (tableAndClusterProps.clusterName !== oldClusterProps.clusterName || tableAndClusterProps.databaseName !== oldClusterProps.databaseName) { + return createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps); + } + const oldTableNamePrefix = oldResourceProperties.tableName.prefix; + if (tableNamePrefix !== oldTableNamePrefix) { + return createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps); + } + const oldTableColumns = oldResourceProperties.tableColumns; + const columnDeletions = oldTableColumns.filter(oldColumn => (tableColumns.every(column => { + if (useColumnIds) { + return oldColumn.id ? oldColumn.id !== column.id : oldColumn.name !== column.name; + } + return oldColumn.name !== column.name; + }))); + if (columnDeletions.length > 0) { + alterationStatements.push(...columnDeletions.map(column => `ALTER TABLE ${tableName} DROP COLUMN ${column.name}`)); + } + const columnAdditions = tableColumns.filter(column => { + return !oldTableColumns.some(oldColumn => { + if (useColumnIds) { + return oldColumn.id ? oldColumn.id === column.id : oldColumn.name === column.name; + } + return oldColumn.name === column.name; + }); + }).map(column => `ADD ${column.name} ${column.dataType}`); + if (columnAdditions.length > 0) { + alterationStatements.push(...columnAdditions.map(addition => `ALTER TABLE ${tableName} ${addition}`)); + } + const columnEncoding = tableColumns.filter(column => { + return oldTableColumns.some(oldColumn => column.name === oldColumn.name && column.encoding !== oldColumn.encoding); + }).map(column => `ALTER COLUMN ${column.name} ENCODE ${column.encoding || 'AUTO'}`); + if (columnEncoding.length > 0) { + alterationStatements.push(`ALTER TABLE ${tableName} ${columnEncoding.join(', ')}`); + } + const columnComments = tableColumns.filter(column => { + return oldTableColumns.some(oldColumn => column.name === oldColumn.name && column.comment !== oldColumn.comment); + }).map(column => `COMMENT ON COLUMN ${tableName}.${column.name} IS ${column.comment ? `'${column.comment}'` : 'NULL'}`); + if (columnComments.length > 0) { + alterationStatements.push(...columnComments); + } + if (useColumnIds) { + const columnNameUpdates = tableColumns.reduce((updates, column) => { + const oldColumn = oldTableColumns.find(oldCol => oldCol.id && oldCol.id === column.id); + if (oldColumn && oldColumn.name !== column.name) { + updates[oldColumn.name] = column.name; + } + return updates; + }, {}); + if (Object.keys(columnNameUpdates).length > 0) { + alterationStatements.push(...Object.entries(columnNameUpdates).map(([oldName, newName]) => (`ALTER TABLE ${tableName} RENAME COLUMN ${oldName} TO ${newName}`))); + } + } + const oldDistStyle = oldResourceProperties.distStyle; + if ((!oldDistStyle && tableAndClusterProps.distStyle) || + (oldDistStyle && !tableAndClusterProps.distStyle)) { + return createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps); + } + else if (oldDistStyle !== tableAndClusterProps.distStyle) { + alterationStatements.push(`ALTER TABLE ${tableName} ALTER DISTSTYLE ${tableAndClusterProps.distStyle}`); + } + const oldDistKey = util_1.getDistKeyColumn(oldTableColumns)?.name; + const newDistKey = util_1.getDistKeyColumn(tableColumns)?.name; + if ((!oldDistKey && newDistKey) || (oldDistKey && !newDistKey)) { + return createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps); + } + else if (oldDistKey !== newDistKey) { + alterationStatements.push(`ALTER TABLE ${tableName} ALTER DISTKEY ${newDistKey}`); + } + const oldSortKeyColumns = util_1.getSortKeyColumns(oldTableColumns); + const newSortKeyColumns = util_1.getSortKeyColumns(tableColumns); + const oldSortStyle = oldResourceProperties.sortStyle; + const newSortStyle = tableAndClusterProps.sortStyle; + if ((oldSortStyle === newSortStyle && !util_1.areColumnsEqual(oldSortKeyColumns, newSortKeyColumns)) + || (oldSortStyle !== newSortStyle)) { + switch (newSortStyle) { + case types_1.TableSortStyle.INTERLEAVED: + // INTERLEAVED sort key addition requires replacement. + // https://docs.aws.amazon.com/redshift/latest/dg/r_ALTER_TABLE.html + return createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps); + case types_1.TableSortStyle.COMPOUND: { + const sortKeyColumnsString = getSortKeyColumnsString(newSortKeyColumns); + alterationStatements.push(`ALTER TABLE ${tableName} ALTER ${newSortStyle} SORTKEY(${sortKeyColumnsString})`); + break; + } + case types_1.TableSortStyle.AUTO: { + alterationStatements.push(`ALTER TABLE ${tableName} ALTER SORTKEY ${newSortStyle}`); + break; + } + } + } + const oldComment = oldResourceProperties.tableComment; + const newComment = tableAndClusterProps.tableComment; + if (oldComment !== newComment) { + alterationStatements.push(`COMMENT ON TABLE ${tableName} IS ${newComment ? `'${newComment}'` : 'NULL'}`); + } + await Promise.all(alterationStatements.map(statement => redshift_data_1.executeStatement(statement, tableAndClusterProps))); + return tableName; +} +function getSortKeyColumnsString(sortKeyColumns) { + return sortKeyColumns.map(column => column.name).join(); +} +function getEncodingColumnString(column) { + if (column.encoding) { + return ` ENCODE ${column.encoding}`; + } + return ''; +} +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFibGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJ0YWJ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b2x1bW46IENvbHVtbik6IHN0cmluZyB7XG4gIGlmIChjb2x1bW4uZW5jb2RpbmcpIHtcbiAgICByZXR1cm4gYCBFTkNPREUgJHtjb2x1bW4uZW5jb2Rpbmd9YDtcbiAgfVxuICByZXR1cm4gJyc7XG59XG4iXX0= \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/types.js b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/types.js new file mode 100644 index 0000000000000..070bb11c1600e --- /dev/null +++ b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/types.js @@ -0,0 +1,24 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.TableSortStyle = void 0; +/** + * The sort style of a table. + * This has been duplicated here to exporting private types. + */ +var TableSortStyle; +(function (TableSortStyle) { + /** + * Amazon Redshift assigns an optimal sort key based on the table data. + */ + TableSortStyle["AUTO"] = "AUTO"; + /** + * Specifies that the data is sorted using a compound key made up of all of the listed columns, + * in the order they are listed. + */ + TableSortStyle["COMPOUND"] = "COMPOUND"; + /** + * Specifies that the data is sorted using an interleaved sort key. + */ + TableSortStyle["INTERLEAVED"] = "INTERLEAVED"; +})(TableSortStyle = exports.TableSortStyle || (exports.TableSortStyle = {})); +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJ0eXBlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFLQTs7O0dBR0c7QUFDSCxJQUFZLGNBZ0JYO0FBaEJELFdBQVksY0FBYztJQUN4Qjs7T0FFRztJQUNILCtCQUFhLENBQ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aWZpZXMgdGhhdCB0aGUgZGF0YSBpcyBzb3J0ZWQgdXNpbmcgYW4gaW50ZXJsZWF2ZWQgc29ydCBrZXkuXG4gICAqL1xuICBJTlRFUkxFQVZFRCA9ICdJTlRFUkxFQVZFRCcsXG59XG4iXX0= \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/user.js b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/user.js new file mode 100644 index 0000000000000..f097ae1836462 --- /dev/null +++ b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/user.js @@ -0,0 +1,70 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.handler = void 0; +/* eslint-disable-next-line import/no-extraneous-dependencies */ +const SecretsManager = require("aws-sdk/clients/secretsmanager"); +const redshift_data_1 = require("./redshift-data"); +const util_1 = require("./util"); +const secretsManager = new SecretsManager(); +async function handler(props, event) { + const username = props.username; + const passwordSecretArn = props.passwordSecretArn; + const clusterProps = props; + if (event.RequestType === 'Create') { + await createUser(username, passwordSecretArn, clusterProps); + return { PhysicalResourceId: util_1.makePhysicalId(username, clusterProps, event.RequestId), Data: { username: username } }; + } + else if (event.RequestType === 'Delete') { + await dropUser(username, clusterProps); + return; + } + else if (event.RequestType === 'Update') { + const { replace } = await updateUser(username, passwordSecretArn, clusterProps, event.OldResourceProperties); + const physicalId = replace ? util_1.makePhysicalId(username, clusterProps, event.RequestId) : event.PhysicalResourceId; + return { PhysicalResourceId: physicalId, Data: { username: username } }; + } + else { + /* eslint-disable-next-line dot-notation */ + throw new Error(`Unrecognized event type: ${event['RequestType']}`); + } +} +exports.handler = handler; +async function dropUser(username, clusterProps) { + await redshift_data_1.executeStatement(`DROP USER ${username}`, clusterProps); +} +async function createUser(username, passwordSecretArn, clusterProps) { + const password = await getPasswordFromSecret(passwordSecretArn); + await redshift_data_1.executeStatement(`CREATE USER ${username} PASSWORD '${password}'`, clusterProps); +} +async function updateUser(username, passwordSecretArn, clusterProps, oldResourceProperties) { + const oldClusterProps = oldResourceProperties; + if (clusterProps.clusterName !== oldClusterProps.clusterName || clusterProps.databaseName !== oldClusterProps.databaseName) { + await createUser(username, passwordSecretArn, clusterProps); + return { replace: true }; + } + const oldUsername = oldResourceProperties.username; + const oldPasswordSecretArn = oldResourceProperties.passwordSecretArn; + const oldPassword = await getPasswordFromSecret(oldPasswordSecretArn); + const password = await getPasswordFromSecret(passwordSecretArn); + if (username !== oldUsername) { + await createUser(username, passwordSecretArn, clusterProps); + return { replace: true }; + } + if (password !== oldPassword) { + await redshift_data_1.executeStatement(`ALTER USER ${username} PASSWORD '${password}'`, clusterProps); + return { replace: false }; + } + return { replace: false }; +} +async function getPasswordFromSecret(passwordSecretArn) { + const secretValue = await secretsManager.getSecretValue({ + SecretId: passwordSecretArn, + }).promise(); + const secretString = secretValue.SecretString; + if (!secretString) { + throw new Error(`Secret string for ${passwordSecretArn} was empty`); + } + const { password } = JSON.parse(secretString); + return password; +} +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXNlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInVzZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBRUEsZ0VBQWdFO0FBQ2hFLGlFQUFpRTtBQUNqRSxtREFBbUQ7QUFFbkQsaUNBQXdDO0FBR3hDLE1BQU0sY0FBYyxHQUFHLElBQUksY0FBYyxFQUFFLENBQUM7QUFFckMsS0FBSyxVQUFVLE9BQU8sQ0FBQyxLQUFzQyxFQUFFLEtBQWtEO0lBQ3RILE1BQU0sUUFBUSxHQUFHLEtBQUssQ0FBQyxRQUFRLENBQUM7SUFDa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z4ge1xuICBjb25zdCBzZWNyZXRWYWx1ZSA9IGF3YWl0IHNlY3JldHNNYW5hZ2VyLmdldFNlY3JldFZhbHVlKHtcbiAgICBTZWNyZXRJZDogcGFzc3dvcmRTZWNyZXRBcm4sXG4gIH0pLnByb21pc2UoKTtcbiAgY29uc3Qgc2VjcmV0U3RyaW5nID0gc2VjcmV0VmFsdWUuU2VjcmV0U3RyaW5nO1xuICBpZiAoIXNlY3JldFN0cmluZykge1xuICAgIHRocm93IG5ldyBFcnJvcihgU2VjcmV0IHN0cmluZyBmb3IgJHtwYXNzd29yZFNlY3JldEFybn0gd2FzIGVtcHR5YCk7XG4gIH1cbiAgY29uc3QgeyBwYXNzd29yZCB9ID0gSlNPTi5wYXJzZShzZWNyZXRTdHJpbmcpO1xuXG4gIHJldHVybiBwYXNzd29yZDtcbn1cbiJdfQ== \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/util.js b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/util.js new file mode 100644 index 0000000000000..d8dc8cad799c9 --- /dev/null +++ b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/util.js @@ -0,0 +1,34 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.areColumnsEqual = exports.getSortKeyColumns = exports.getDistKeyColumn = exports.makePhysicalId = void 0; +function makePhysicalId(resourceName, clusterProps, requestId) { + return `${clusterProps.clusterName}:${clusterProps.databaseName}:${resourceName}:${requestId}`; +} +exports.makePhysicalId = makePhysicalId; +function getDistKeyColumn(columns) { + // string comparison is required for custom resource since everything is passed as string + const distKeyColumns = columns.filter(column => column.distKey === true || column.distKey === 'true'); + if (distKeyColumns.length === 0) { + return undefined; + } + else if (distKeyColumns.length > 1) { + throw new Error('Multiple dist key columns found'); + } + return distKeyColumns[0]; +} +exports.getDistKeyColumn = getDistKeyColumn; +function getSortKeyColumns(columns) { + // string comparison is required for custom resource since everything is passed as string + return columns.filter(column => column.sortKey === true || column.sortKey === 'true'); +} +exports.getSortKeyColumns = getSortKeyColumns; +function areColumnsEqual(columnsA, columnsB) { + if (columnsA.length !== columnsB.length) { + return false; + } + return columnsA.every(columnA => { + return columnsB.find(column => column.name === columnA.name && column.dataType === columnA.dataType); + }); +} +exports.areColumnsEqual = areColumnsEqual; +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInV0aWwudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBR0EsU0FBZ0IsY0FBYyxDQUFDLFlBQW9CLEVBQUUsWUFBMEIsRUFBRSxTQUFpQjtJQUNoRyxPQUFPLEdBQUcsWUFBWSxDQUFDLFdBQVcsSUFBSSxZQUFZLENBQUMsWUFBWSxJQUFJLFlBQVksSUFBSSxTQUFTLEVBQUUsQ0FBQztBQUNqRyxDQUFDO0FBRkQsd0NBRUM7QUFFRCxTQUFnQixnQkFBZ0IsQ0FBQyxPQUFpQjtJQUNoRCx5RkFBeUY7SUFDekYsTUFBTSxjQUFjLEdBQUcsT0FBTyxDQUFDLE1BQU0sQ0FBQyxNQUFNLENBQUMsRUFBRSxDQUFDLE1BQU0sQ0FBQyxPQUFPLEtBQUssSUFBSSxJQUFLLE1BQU0sQ0FBQyxPQUE2QixLQUFLLE1BQU0sQ0FBQyxDQUFDO0lBRTdILElBQUksY0FBYyxDQUFDLE1BQU0sS0FBSyxDQUFDLEVBQUU7UUFDL0IsT0FBTyxTQUFTLENBQUM7S0FDbEI7U0FBTSxJQUFJLGNBQWMsQ0FBQyxNQUFNLEdBQUcsQ0FBQyxFQUFFO1FBQ3B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pbmdcbiAgcmV0dXJuIGNvbHVtbnMuZmlsdGVyKGNvbHVtbiA9PiBjb2x1bW4uc29ydEtleSA9PT0gdHJ1ZSB8fCAoY29sdW1uLnNvcnRLZXkgYXMgdW5rbm93biBhcyBzdHJpbmcpID09PSAndHJ1ZScpO1xufVxuXG5leHBvcnQgZnVuY3Rpb24gYXJlQ29sdW1uc0VxdWFsKGNvbHVtbnNBOiBDb2x1bW5bXSwgY29sdW1uc0I6IENvbHVtbltdKTogYm9vbGVhbiB7XG4gIGlmIChjb2x1bW5zQS5sZW5ndGggIT09IGNvbHVtbnNCLmxlbmd0aCkge1xuICAgIHJldHVybiBmYWxzZTtcbiAgfVxuICByZXR1cm4gY29sdW1uc0EuZXZlcnkoY29sdW1uQSA9PiB7XG4gICAgcmV0dXJuIGNvbHVtbnNCLmZpbmQoY29sdW1uID0+IGNvbHVtbi5uYW1lID09PSBjb2x1bW5BLm5hbWUgJiYgY29sdW1uLmRhdGFUeXBlID09PSBjb2x1bW5BLmRhdGFUeXBlKTtcbiAgfSk7XG59XG4iXX0= \ No newline at end of file From 8b41c77467d9030dd03bbb7fd9dca62cf4ac0395 Mon Sep 17 00:00:00 2001 From: Rizbir Khan Date: Fri, 14 Apr 2023 14:44:29 +0000 Subject: [PATCH 03/21] post merge fix --- .../handler-name.js | 10 - .../index.js | 21 --- .../privileges.js | 69 ------- .../redshift-data.js | 37 ---- .../table.js | 171 ------------------ .../types.js | 24 --- .../user.js | 70 ------- .../util.js | 34 ---- 8 files changed, 436 deletions(-) delete mode 100644 packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/handler-name.js delete mode 100644 packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/index.js delete mode 100644 packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/privileges.js delete mode 100644 packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/redshift-data.js delete mode 100644 packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/table.js delete mode 100644 packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/types.js delete mode 100644 packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/user.js delete mode 100644 packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/util.js diff --git a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/handler-name.js b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/handler-name.js deleted file mode 100644 index 4983115a93834..0000000000000 --- a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/handler-name.js +++ /dev/null @@ -1,10 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.HandlerName = void 0; -var HandlerName; -(function (HandlerName) { - HandlerName["User"] = "user"; - HandlerName["Table"] = "table"; - HandlerName["UserTablePrivileges"] = "user-table-privileges"; -})(HandlerName = exports.HandlerName || (exports.HandlerName = {})); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGFuZGxlci1uYW1lLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiaGFuZGxlci1uYW1lLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLElBQVksV0FJWDtBQUpELFdBQVksV0FBVztJQUNyQiw0QkFBYSxDQUFBO0lBQ2IsOEJBQWUsQ0FBQTtJQUNmLDREQUE2QyxDQUFBO0FBQy9DLENBQUMsRUFKVyxXQUFXLEdBQVgsbUJBQVcsS0FBWCxtQkFBVyxRQUl0QiIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBlbnVtIEhhbmRsZXJOYW1lIHtcbiAgVXNlciA9ICd1c2VyJyxcbiAgVGFibGUgPSAndGFibGUnLFxuICBVc2VyVGFibGVQcml2aWxlZ2VzID0gJ3VzZXItdGFibGUtcHJpdmlsZWdlcycsXG59XG4iXX0= \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/index.js b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/index.js deleted file mode 100644 index d7a8b52f2944c..0000000000000 --- a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/index.js +++ /dev/null @@ -1,21 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.handler = void 0; -const handler_name_1 = require("./handler-name"); -const privileges_1 = require("./privileges"); -const table_1 = require("./table"); -const user_1 = require("./user"); -const HANDLERS = { - [handler_name_1.HandlerName.Table]: table_1.handler, - [handler_name_1.HandlerName.User]: user_1.handler, - [handler_name_1.HandlerName.UserTablePrivileges]: privileges_1.handler, -}; -async function handler(event) { - const subHandler = HANDLERS[event.ResourceProperties.handler]; - if (!subHandler) { - throw new Error(`Requested handler ${event.ResourceProperties.handler} is not in supported set: ${JSON.stringify(Object.keys(HANDLERS))}`); - } - return subHandler(event.ResourceProperties, event); -} -exports.handler = handler; -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJpbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFFQSxpREFBNkM7QUFDN0MsNkNBQTJEO0FBQzNELG1DQUFpRDtBQUNqRCxpQ0FBK0M7QUFFL0MsTUFBTSxRQUFRLEdBQWlIO0lBQzdILENBQUMsMEJBQVcsQ0FBQyxLQUFLLENBQUMsRUFBRSxlQUFXO0lBQ2hDLENBQUMsMEJBQVcsQ0FBQyxJQUFJLENBQUMsRUFBRSxjQUFVO0lBQzlCLENBQUMsMEJBQVcsQ0FBQyxtQkFBbUIsQ0FBQyxFQUFFLG9CQUFnQjtDQUNwRCxDQUFDO0FBRUssS0FBSyxVQUFVLE9BQU8sQ0FBQyxLQUFrRDtJQUM5RSxNQUFNLFVBQVUsR0FBRyxRQUFRLENBQUMsS0FBSyxDQUFDLGtCQUFrQixDQUFDLE9BQXNCLENBQUMsQ0FBQztJQUM3RSxJQUFJLENBQUMsVUFBVSxFQUFFO1FBQ2YsTUFBTSxJQUFJLEtBQUssQ0FBQyxxQkFBcUIsS0FBSyxDQUFDLGtCQUFrQixDQUFDLE9BQU8sNkJBQTZCLElBQUksQ0FBQyxTQUFTLENBQUMsTUFBTSxDQUFDLElBQUksQ0FBQyxRQUFRLENBQUMsQ0FBQyxFQUFFLENBQUMsQ0FBQztLQUM1STtJQUNELE9BQU8sVUFBVSxDQUFDLEtBQUssQ0FBQyxrQkFBa0IsRUFBRSxLQUFLLENBQUMsQ0FBQztBQUNyRCxDQUFDO0FBTkQsMEJBTUMiLCJzb3VyY2VzQ29udGVudCI6WyIvKiBlc2xpbnQtZGlzYWJsZS1uZXh0LWxpbmUgaW1wb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XMgbm90IGluIHN1cHBvcnRlZCBzZXQ6ICR7SlNPTi5zdHJpbmdpZnkoT2JqZWN0LmtleXMoSEFORExFUlMpKX1gKTtcbiAgfVxuICByZXR1cm4gc3ViSGFuZGxlcihldmVudC5SZXNvdXJjZVByb3BlcnRpZXMsIGV2ZW50KTtcbn1cbiJdfQ== \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/privileges.js b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/privileges.js deleted file mode 100644 index ce2abc7191d26..0000000000000 --- a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/privileges.js +++ /dev/null @@ -1,69 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.handler = void 0; -const redshift_data_1 = require("./redshift-data"); -const util_1 = require("./util"); -async function handler(props, event) { - const username = props.username; - const tablePrivileges = props.tablePrivileges; - const clusterProps = props; - if (event.RequestType === 'Create') { - await grantPrivileges(username, tablePrivileges, clusterProps); - return { PhysicalResourceId: util_1.makePhysicalId(username, clusterProps, event.RequestId) }; - } - else if (event.RequestType === 'Delete') { - await revokePrivileges(username, tablePrivileges, clusterProps); - return; - } - else if (event.RequestType === 'Update') { - const { replace } = await updatePrivileges(username, tablePrivileges, clusterProps, event.OldResourceProperties); - const physicalId = replace ? util_1.makePhysicalId(username, clusterProps, event.RequestId) : event.PhysicalResourceId; - return { PhysicalResourceId: physicalId }; - } - else { - /* eslint-disable-next-line dot-notation */ - throw new Error(`Unrecognized event type: ${event['RequestType']}`); - } -} -exports.handler = handler; -async function revokePrivileges(username, tablePrivileges, clusterProps) { - await Promise.all(tablePrivileges.map(({ tableName, actions }) => { - return redshift_data_1.executeStatement(`REVOKE ${actions.join(', ')} ON ${tableName} FROM ${username}`, clusterProps); - })); -} -async function grantPrivileges(username, tablePrivileges, clusterProps) { - await Promise.all(tablePrivileges.map(({ tableName, actions }) => { - return redshift_data_1.executeStatement(`GRANT ${actions.join(', ')} ON ${tableName} TO ${username}`, clusterProps); - })); -} -async function updatePrivileges(username, tablePrivileges, clusterProps, oldResourceProperties) { - const oldClusterProps = oldResourceProperties; - if (clusterProps.clusterName !== oldClusterProps.clusterName || clusterProps.databaseName !== oldClusterProps.databaseName) { - await grantPrivileges(username, tablePrivileges, clusterProps); - return { replace: true }; - } - const oldUsername = oldResourceProperties.username; - if (oldUsername !== username) { - await grantPrivileges(username, tablePrivileges, clusterProps); - return { replace: true }; - } - const oldTablePrivileges = oldResourceProperties.tablePrivileges; - const tablesToRevoke = oldTablePrivileges.filter(({ tableId, actions }) => { - const tableRemoved = !tablePrivileges.find(({ tableId: otherTableId }) => tableId === otherTableId); - const actionsRemoved = tablePrivileges.find(({ tableId: otherTableId, actions: otherActions }) => (tableId === otherTableId && actions.some(action => !otherActions.includes(action)))); - return tableRemoved || actionsRemoved; - }); - if (tablesToRevoke.length > 0) { - await revokePrivileges(username, tablesToRevoke, clusterProps); - } - const tablesToGrant = tablePrivileges.filter(({ tableId, tableName, actions }) => { - const tableAdded = !oldTablePrivileges.find(({ tableId: otherTableId, tableName: otherTableName }) => (tableId === otherTableId && tableName === otherTableName)); - const actionsAdded = oldTablePrivileges.find(({ tableId: otherTableId, actions: otherActions }) => (tableId === otherTableId && otherActions.some(action => !actions.includes(action)))); - return tableAdded || actionsAdded; - }); - if (tablesToGrant.length > 0) { - await grantPrivileges(username, tablesToGrant, clusterProps); - } - return { replace: false }; -} -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJpdmlsZWdlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInByaXZpbGVnZXMudHMiXSwibmFtZXMiOltdLCJt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WN0aW9ucy5zb21lKGFjdGlvbiA9PiAhYWN0aW9ucy5pbmNsdWRlcyhhY3Rpb24pKVxuICAgICkpO1xuICAgIHJldHVybiB0YWJsZUFkZGVkIHx8IGFjdGlvbnNBZGRlZDtcbiAgfSk7XG4gIGlmICh0YWJsZXNUb0dyYW50Lmxlbmd0aCA+IDApIHtcbiAgICBhd2FpdCBncmFudFByaXZpbGVnZXModXNlcm5hbWUsIHRhYmxlc1RvR3JhbnQsIGNsdXN0ZXJQcm9wcyk7XG4gIH1cblxuICByZXR1cm4geyByZXBsYWNlOiBmYWxzZSB9O1xufVxuIl19 \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/redshift-data.js b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/redshift-data.js deleted file mode 100644 index e65374f4ab7e0..0000000000000 --- a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/redshift-data.js +++ /dev/null @@ -1,37 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.executeStatement = void 0; -/* eslint-disable-next-line import/no-extraneous-dependencies */ -const RedshiftData = require("aws-sdk/clients/redshiftdata"); -const redshiftData = new RedshiftData(); -async function executeStatement(statement, clusterProps) { - const executeStatementProps = { - ClusterIdentifier: clusterProps.clusterName, - Database: clusterProps.databaseName, - SecretArn: clusterProps.adminUserArn, - Sql: statement, - }; - const executedStatement = await redshiftData.executeStatement(executeStatementProps).promise(); - if (!executedStatement.Id) { - throw new Error('Service error: Statement execution did not return a statement ID'); - } - await waitForStatementComplete(executedStatement.Id); -} -exports.executeStatement = executeStatement; -const waitTimeout = 100; -async function waitForStatementComplete(statementId) { - await new Promise((resolve) => { - setTimeout(() => resolve(), waitTimeout); - }); - const statement = await redshiftData.describeStatement({ Id: statementId }).promise(); - if (statement.Status !== 'FINISHED' && statement.Status !== 'FAILED' && statement.Status !== 'ABORTED') { - return waitForStatementComplete(statementId); - } - else if (statement.Status === 'FINISHED') { - return; - } - else { - throw new Error(`Statement status was ${statement.Status}: ${statement.Error}`); - } -} -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVkc2hpZnQtZGF0YS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInJlZHNoaWZ0LWRhdGEudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsZ0VBQWdFO0FBQ2hFLDZEQUE2RDtBQUc3RCxNQUFNLFlBQVksR0FBRyxJQUFJLFlBQVksRUFBRSxDQUFDO0FBRWpDLEtBQUssVUFBVSxnQkFBZ0IsQ0FBQyxTQUFpQixFQUFFLFlBQTBCO0lBQ2xGLE1BQU0scUJBQXFCLEdBQUc7UUFDNUIsaUJBQWlCLEVBQUUsWUFBWSxDQUFDLFdBQVc7UUFDM0MsUUFBUSxFQUFFLFlBQVksQ0FBQyxZQUFZO1FBQ25DLFNBQVMsRUFBRSxZQUFZLENBQUMsWUFBWTtRQUNwQyxHQUFHLEVBQUUsU0FBUztLQUNmLENBQUM7SUFDRixNQUFNLGlCQUFpQixHQUFHLE1BQU0sWUFBWSxDQUFDLGdCQUFnQixDQUFDLHFCQUFxQixDQUFDLENBQUMsT0FBTyxFQUFFLENBQUM7SUFDL0YsSUFBSSxDQUFDLGlCQUFpQixDQUFDLEVBQUUsRUFBRTtRQUN6QixNQUFNLElBQUksS0FBSyxDQUFDLGtFQUFrRSxDQUFDLENBQUM7S0FDckY7SUFDRCxNQUFNLHdCQUF3QixDQUFDLGlCQUFpQixDQUFDLEVBQUUsQ0FBQyxDQUFDO0FBQ3ZELENBQUM7QUFaRCw0Q0FZQztBQUVELE1BQU0sV0FBVyxHQUF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0+IHJlc29sdmUoKSwgd2FpdFRpbWVvdXQpO1xuICB9KTtcbiAgY29uc3Qgc3RhdGVtZW50ID0gYXdhaXQgcmVkc2hpZnREYXRhLmRlc2NyaWJlU3RhdGVtZW50KHsgSWQ6IHN0YXRlbWVudElkIH0pLnByb21pc2UoKTtcbiAgaWYgKHN0YXRlbWVudC5TdGF0dXMgIT09ICdGSU5JU0hFRCcgJiYgc3RhdGVtZW50LlN0YXR1cyAhPT0gJ0ZBSUxFRCcgJiYgc3RhdGVtZW50LlN0YXR1cyAhPT0gJ0FCT1JURUQnKSB7XG4gICAgcmV0dXJuIHdhaXRGb3JTdGF0ZW1lbnRDb21wbGV0ZShzdGF0ZW1lbnRJZCk7XG4gIH0gZWxzZSBpZiAoc3RhdGVtZW50LlN0YXR1cyA9PT0gJ0ZJTklTSEVEJykge1xuICAgIHJldHVybjtcbiAgfSBlbHNlIHtcbiAgICB0aHJvdyBuZXcgRXJyb3IoYFN0YXRlbWVudCBzdGF0dXMgd2FzICR7c3RhdGVtZW50LlN0YXR1c306ICR7c3RhdGVtZW50LkVycm9yfWApO1xuICB9XG59XG4iXX0= \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/table.js b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/table.js deleted file mode 100644 index 8b7f3f6a680fa..0000000000000 --- a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/table.js +++ /dev/null @@ -1,171 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.handler = void 0; -const redshift_data_1 = require("./redshift-data"); -const types_1 = require("./types"); -const util_1 = require("./util"); -async function handler(props, event) { - const tableNamePrefix = props.tableName.prefix; - const tableNameSuffix = props.tableName.generateSuffix === 'true' ? `${event.RequestId.substring(0, 8)}` : ''; - const tableColumns = props.tableColumns; - const tableAndClusterProps = props; - const useColumnIds = props.useColumnIds; - if (event.RequestType === 'Create') { - const tableName = await createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps); - return { PhysicalResourceId: tableName }; - } - else if (event.RequestType === 'Delete') { - await dropTable(event.PhysicalResourceId, tableAndClusterProps); - return; - } - else if (event.RequestType === 'Update') { - const tableName = await updateTable(event.PhysicalResourceId, tableNamePrefix, tableNameSuffix, tableColumns, useColumnIds, tableAndClusterProps, event.OldResourceProperties); - return { PhysicalResourceId: tableName }; - } - else { - /* eslint-disable-next-line dot-notation */ - throw new Error(`Unrecognized event type: ${event['RequestType']}`); - } -} -exports.handler = handler; -async function createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps) { - const tableName = tableNamePrefix + tableNameSuffix; - const tableColumnsString = tableColumns.map(column => `${column.name} ${column.dataType}${getEncodingColumnString(column)}`).join(); - let statement = `CREATE TABLE ${tableName} (${tableColumnsString})`; - if (tableAndClusterProps.distStyle) { - statement += ` DISTSTYLE ${tableAndClusterProps.distStyle}`; - } - const distKeyColumn = util_1.getDistKeyColumn(tableColumns); - if (distKeyColumn) { - statement += ` DISTKEY(${distKeyColumn.name})`; - } - const sortKeyColumns = util_1.getSortKeyColumns(tableColumns); - if (sortKeyColumns.length > 0) { - const sortKeyColumnsString = getSortKeyColumnsString(sortKeyColumns); - statement += ` ${tableAndClusterProps.sortStyle} SORTKEY(${sortKeyColumnsString})`; - } - await redshift_data_1.executeStatement(statement, tableAndClusterProps); - for (const column of tableColumns) { - if (column.comment) { - await redshift_data_1.executeStatement(`COMMENT ON COLUMN ${tableName}.${column.name} IS '${column.comment}'`, tableAndClusterProps); - } - } - if (tableAndClusterProps.tableComment) { - await redshift_data_1.executeStatement(`COMMENT ON TABLE ${tableName} IS '${tableAndClusterProps.tableComment}'`, tableAndClusterProps); - } - return tableName; -} -async function dropTable(tableName, clusterProps) { - await redshift_data_1.executeStatement(`DROP TABLE ${tableName}`, clusterProps); -} -async function updateTable(tableName, tableNamePrefix, tableNameSuffix, tableColumns, useColumnIds, tableAndClusterProps, oldResourceProperties) { - const alterationStatements = []; - const oldClusterProps = oldResourceProperties; - if (tableAndClusterProps.clusterName !== oldClusterProps.clusterName || tableAndClusterProps.databaseName !== oldClusterProps.databaseName) { - return createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps); - } - const oldTableNamePrefix = oldResourceProperties.tableName.prefix; - if (tableNamePrefix !== oldTableNamePrefix) { - return createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps); - } - const oldTableColumns = oldResourceProperties.tableColumns; - const columnDeletions = oldTableColumns.filter(oldColumn => (tableColumns.every(column => { - if (useColumnIds) { - return oldColumn.id ? oldColumn.id !== column.id : oldColumn.name !== column.name; - } - return oldColumn.name !== column.name; - }))); - if (columnDeletions.length > 0) { - alterationStatements.push(...columnDeletions.map(column => `ALTER TABLE ${tableName} DROP COLUMN ${column.name}`)); - } - const columnAdditions = tableColumns.filter(column => { - return !oldTableColumns.some(oldColumn => { - if (useColumnIds) { - return oldColumn.id ? oldColumn.id === column.id : oldColumn.name === column.name; - } - return oldColumn.name === column.name; - }); - }).map(column => `ADD ${column.name} ${column.dataType}`); - if (columnAdditions.length > 0) { - alterationStatements.push(...columnAdditions.map(addition => `ALTER TABLE ${tableName} ${addition}`)); - } - const columnEncoding = tableColumns.filter(column => { - return oldTableColumns.some(oldColumn => column.name === oldColumn.name && column.encoding !== oldColumn.encoding); - }).map(column => `ALTER COLUMN ${column.name} ENCODE ${column.encoding || 'AUTO'}`); - if (columnEncoding.length > 0) { - alterationStatements.push(`ALTER TABLE ${tableName} ${columnEncoding.join(', ')}`); - } - const columnComments = tableColumns.filter(column => { - return oldTableColumns.some(oldColumn => column.name === oldColumn.name && column.comment !== oldColumn.comment); - }).map(column => `COMMENT ON COLUMN ${tableName}.${column.name} IS ${column.comment ? `'${column.comment}'` : 'NULL'}`); - if (columnComments.length > 0) { - alterationStatements.push(...columnComments); - } - if (useColumnIds) { - const columnNameUpdates = tableColumns.reduce((updates, column) => { - const oldColumn = oldTableColumns.find(oldCol => oldCol.id && oldCol.id === column.id); - if (oldColumn && oldColumn.name !== column.name) { - updates[oldColumn.name] = column.name; - } - return updates; - }, {}); - if (Object.keys(columnNameUpdates).length > 0) { - alterationStatements.push(...Object.entries(columnNameUpdates).map(([oldName, newName]) => (`ALTER TABLE ${tableName} RENAME COLUMN ${oldName} TO ${newName}`))); - } - } - const oldDistStyle = oldResourceProperties.distStyle; - if ((!oldDistStyle && tableAndClusterProps.distStyle) || - (oldDistStyle && !tableAndClusterProps.distStyle)) { - return createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps); - } - else if (oldDistStyle !== tableAndClusterProps.distStyle) { - alterationStatements.push(`ALTER TABLE ${tableName} ALTER DISTSTYLE ${tableAndClusterProps.distStyle}`); - } - const oldDistKey = util_1.getDistKeyColumn(oldTableColumns)?.name; - const newDistKey = util_1.getDistKeyColumn(tableColumns)?.name; - if ((!oldDistKey && newDistKey) || (oldDistKey && !newDistKey)) { - return createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps); - } - else if (oldDistKey !== newDistKey) { - alterationStatements.push(`ALTER TABLE ${tableName} ALTER DISTKEY ${newDistKey}`); - } - const oldSortKeyColumns = util_1.getSortKeyColumns(oldTableColumns); - const newSortKeyColumns = util_1.getSortKeyColumns(tableColumns); - const oldSortStyle = oldResourceProperties.sortStyle; - const newSortStyle = tableAndClusterProps.sortStyle; - if ((oldSortStyle === newSortStyle && !util_1.areColumnsEqual(oldSortKeyColumns, newSortKeyColumns)) - || (oldSortStyle !== newSortStyle)) { - switch (newSortStyle) { - case types_1.TableSortStyle.INTERLEAVED: - // INTERLEAVED sort key addition requires replacement. - // https://docs.aws.amazon.com/redshift/latest/dg/r_ALTER_TABLE.html - return createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps); - case types_1.TableSortStyle.COMPOUND: { - const sortKeyColumnsString = getSortKeyColumnsString(newSortKeyColumns); - alterationStatements.push(`ALTER TABLE ${tableName} ALTER ${newSortStyle} SORTKEY(${sortKeyColumnsString})`); - break; - } - case types_1.TableSortStyle.AUTO: { - alterationStatements.push(`ALTER TABLE ${tableName} ALTER SORTKEY ${newSortStyle}`); - break; - } - } - } - const oldComment = oldResourceProperties.tableComment; - const newComment = tableAndClusterProps.tableComment; - if (oldComment !== newComment) { - alterationStatements.push(`COMMENT ON TABLE ${tableName} IS ${newComment ? `'${newComment}'` : 'NULL'}`); - } - await Promise.all(alterationStatements.map(statement => redshift_data_1.executeStatement(statement, tableAndClusterProps))); - return tableName; -} -function getSortKeyColumnsString(sortKeyColumns) { - return sortKeyColumns.map(column => column.name).join(); -} -function getEncodingColumnString(column) { - if (column.encoding) { - return ` ENCODE ${column.encoding}`; - } - return ''; -} -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFibGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJ0YWJsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFFQSxtREFBbUQ7QUFDbkQsbUNBQTZFO0FBQzdFLGlDQUE4RTtBQUd2RSxLQUFLLFVBQVUsT0FBTyxDQUFDLEtBQTJCLEVBQUUsS0FBa0Q7SUFDM0csTUFBTSxlQUFlLEdBQUcsS0FBSyxDQUFDLFNBQVMsQ0FBQyxNQUFNLENBQUM7SUFDL0MsTUFBTSxlQUFlLEdBQUcsS0FBSyxDQUFDLFNBQVMsQ0FBQyxjQUFjLEtBQUssTUFBTSxDQUFDLENBQUMsQ0FBQyxHQUFHLEtBQUssQ0FBQyxTQUFTLENBQUMsU0FBUyxDQUFDLENBQUMsRUFBRSxDQUFDLENBQUMsRUFBRSxDQUFDLENBQUMsQ0FBQyxFQUFFLENBQUM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BzLnRhYmxlQ29tbWVudDtcbiAgaWYgKG9sZENvbW1lbnQgIT09IG5ld0NvbW1lbnQpIHtcbiAgICBhbHRlcmF0aW9uU3RhdGVtZW50cy5wdXNoKGBDT01NRU5UIE9OIFRBQkxFICR7dGFibGVOYW1lfSBJUyAke25ld0NvbW1lbnQgPyBgJyR7bmV3Q29tbWVudH0nYCA6ICdOVUxMJ31gKTtcbiAgfVxuXG4gIGF3YWl0IFByb21pc2UuYWxsKGFsdGVyYXRpb25TdGF0ZW1lbnRzLm1hcChzdGF0ZW1lbnQgPT4gZXhlY3V0ZVN0YXRlbWVudChzdGF0ZW1lbnQsIHRhYmxlQW5kQ2x1c3RlclByb3BzKSkpO1xuXG4gIHJldHVybiB0YWJsZU5hbWU7XG59XG5cbmZ1bmN0aW9uIGdldFNvcnRLZXlDb2x1bW5zU3RyaW5nKHNvcnRLZXlDb2x1bW5zOiBDb2x1bW5bXSkge1xuICByZXR1cm4gc29ydEtleUNvbHVtbnMubWFwKGNvbHVtbiA9PiBjb2x1bW4ubmFtZSkuam9pbigpO1xufVxuXG5mdW5jdGlvbiBnZXRFbmNvZGluZ0NvbHVtblN0cmluZyhjb2x1bW46IENvbHVtbik6IHN0cmluZyB7XG4gIGlmIChjb2x1bW4uZW5jb2RpbmcpIHtcbiAgICByZXR1cm4gYCBFTkNPREUgJHtjb2x1bW4uZW5jb2Rpbmd9YDtcbiAgfVxuICByZXR1cm4gJyc7XG59XG4iXX0= \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/types.js b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/types.js deleted file mode 100644 index 070bb11c1600e..0000000000000 --- a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/types.js +++ /dev/null @@ -1,24 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.TableSortStyle = void 0; -/** - * The sort style of a table. - * This has been duplicated here to exporting private types. - */ -var TableSortStyle; -(function (TableSortStyle) { - /** - * Amazon Redshift assigns an optimal sort key based on the table data. - */ - TableSortStyle["AUTO"] = "AUTO"; - /** - * Specifies that the data is sorted using a compound key made up of all of the listed columns, - * in the order they are listed. - */ - TableSortStyle["COMPOUND"] = "COMPOUND"; - /** - * Specifies that the data is sorted using an interleaved sort key. - */ - TableSortStyle["INTERLEAVED"] = "INTERLEAVED"; -})(TableSortStyle = exports.TableSortStyle || (exports.TableSortStyle = {})); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJ0eXBlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFLQTs7O0dBR0c7QUFDSCxJQUFZLGNBZ0JYO0FBaEJELFdBQVksY0FBYztJQUN4Qjs7T0FFRztJQUNILCtCQUFhLENBQUE7SUFFYjs7O09BR0c7SUFDSCx1Q0FBcUIsQ0FBQTtJQUVyQjs7T0FFRztJQUNILDZDQUEyQixDQUFBO0FBQzdCLENBQUMsRUFoQlcsY0FBYyxHQUFkLHNCQUFjLEtBQWQsc0JBQWMsUUFnQnpCIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgRGF0YWJhc2VRdWVyeUhhbmRsZXJQcm9wcywgVGFibGVIYW5kbGVyUHJvcHMgfSBmcm9tICcuLi9oYW5kbGVyLXByb3BzJztcblxuZXhwb3J0IHR5cGUgQ2x1c3RlclByb3BzID0gT21pdDxEYXRhYmFzZVF1ZXJ5SGFuZGxlclByb3BzLCAnaGFuZGxlcic+O1xuZXhwb3J0IHR5cGUgVGFibGVBbmRDbHVzdGVyUHJvcHMgPSBUYWJsZUhhbmRsZXJQcm9wcyAmIENsdXN0ZXJQcm9wcztcblxuLyoqXG4gKiBUaGUgc29ydCBzdHlsZSBvZiBhIHRhYmxlLlxuICogVGhpcyBoYXMgYmVlbiBkdXBsaWNhdGVkIGhlcmUgdG8gZXhwb3J0aW5nIHByaXZhdGUgdHlwZXMuXG4gKi9cbmV4cG9ydCBlbnVtIFRhYmxlU29ydFN0eWxlIHtcbiAgLyoqXG4gICAqIEFtYXpvbiBSZWRzaGlmdCBhc3NpZ25zIGFuIG9wdGltYWwgc29ydCBrZXkgYmFzZWQgb24gdGhlIHRhYmxlIGRhdGEuXG4gICAqL1xuICBBVVRPID0gJ0FVVE8nLFxuXG4gIC8qKlxuICAgKiBTcGVjaWZpZXMgdGhhdCB0aGUgZGF0YSBpcyBzb3J0ZWQgdXNpbmcgYSBjb21wb3VuZCBrZXkgbWFkZSB1cCBvZiBhbGwgb2YgdGhlIGxpc3RlZCBjb2x1bW5zLFxuICAgKiBpbiB0aGUgb3JkZXIgdGhleSBhcmUgbGlzdGVkLlxuICAgKi9cbiAgQ09NUE9VTkQgPSAnQ09NUE9VTkQnLFxuXG4gIC8qKlxuICAgKiBTcGVjaWZpZXMgdGhhdCB0aGUgZGF0YSBpcyBzb3J0ZWQgdXNpbmcgYW4gaW50ZXJsZWF2ZWQgc29ydCBrZXkuXG4gICAqL1xuICBJTlRFUkxFQVZFRCA9ICdJTlRFUkxFQVZFRCcsXG59XG4iXX0= \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/user.js b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/user.js deleted file mode 100644 index f097ae1836462..0000000000000 --- a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/user.js +++ /dev/null @@ -1,70 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.handler = void 0; -/* eslint-disable-next-line import/no-extraneous-dependencies */ -const SecretsManager = require("aws-sdk/clients/secretsmanager"); -const redshift_data_1 = require("./redshift-data"); -const util_1 = require("./util"); -const secretsManager = new SecretsManager(); -async function handler(props, event) { - const username = props.username; - const passwordSecretArn = props.passwordSecretArn; - const clusterProps = props; - if (event.RequestType === 'Create') { - await createUser(username, passwordSecretArn, clusterProps); - return { PhysicalResourceId: util_1.makePhysicalId(username, clusterProps, event.RequestId), Data: { username: username } }; - } - else if (event.RequestType === 'Delete') { - await dropUser(username, clusterProps); - return; - } - else if (event.RequestType === 'Update') { - const { replace } = await updateUser(username, passwordSecretArn, clusterProps, event.OldResourceProperties); - const physicalId = replace ? util_1.makePhysicalId(username, clusterProps, event.RequestId) : event.PhysicalResourceId; - return { PhysicalResourceId: physicalId, Data: { username: username } }; - } - else { - /* eslint-disable-next-line dot-notation */ - throw new Error(`Unrecognized event type: ${event['RequestType']}`); - } -} -exports.handler = handler; -async function dropUser(username, clusterProps) { - await redshift_data_1.executeStatement(`DROP USER ${username}`, clusterProps); -} -async function createUser(username, passwordSecretArn, clusterProps) { - const password = await getPasswordFromSecret(passwordSecretArn); - await redshift_data_1.executeStatement(`CREATE USER ${username} PASSWORD '${password}'`, clusterProps); -} -async function updateUser(username, passwordSecretArn, clusterProps, oldResourceProperties) { - const oldClusterProps = oldResourceProperties; - if (clusterProps.clusterName !== oldClusterProps.clusterName || clusterProps.databaseName !== oldClusterProps.databaseName) { - await createUser(username, passwordSecretArn, clusterProps); - return { replace: true }; - } - const oldUsername = oldResourceProperties.username; - const oldPasswordSecretArn = oldResourceProperties.passwordSecretArn; - const oldPassword = await getPasswordFromSecret(oldPasswordSecretArn); - const password = await getPasswordFromSecret(passwordSecretArn); - if (username !== oldUsername) { - await createUser(username, passwordSecretArn, clusterProps); - return { replace: true }; - } - if (password !== oldPassword) { - await redshift_data_1.executeStatement(`ALTER USER ${username} PASSWORD '${password}'`, clusterProps); - return { replace: false }; - } - return { replace: false }; -} -async function getPasswordFromSecret(passwordSecretArn) { - const secretValue = await secretsManager.getSecretValue({ - SecretId: passwordSecretArn, - }).promise(); - const secretString = secretValue.SecretString; - if (!secretString) { - throw new Error(`Secret string for ${passwordSecretArn} was empty`); - } - const { password } = JSON.parse(secretString); - return password; -} -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXNlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInVzZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBRUEsZ0VBQWdFO0FBQ2hFLGlFQUFpRTtBQUNqRSxtREFBbUQ7QUFFbkQsaUNBQXdDO0FBR3hDLE1BQU0sY0FBYyxHQUFHLElBQUksY0FBYyxFQUFFLENBQUM7QUFFckMsS0FBSyxVQUFVLE9BQU8sQ0FBQyxLQUFzQyxFQUFFLEtBQWtEO0lBQ3RILE1BQU0sUUFBUSxHQUFHLEtBQUssQ0FBQyxRQUFRLENBQUM7SUFDaEMsTUFBTSxpQkFBaUIsR0FBRyxLQUFLLENBQUMsaUJBQWlCLENBQUM7SUFDbEQsTUFBTSxZQUFZLEdBQUcsS0FBSyxDQUFDO0lBRTNCLElBQUksS0FBSyxDQUFDLFdBQVcsS0FBSyxRQUFRLEVBQUU7UUFDbEMsTUFBTSxVQUFVLENBQUMsUUFBUSxFQUFFLGlCQUFpQixFQUFFLFlBQVksQ0FBQyxDQUFDO1FBQzVELE9BQU8sRUFBRSxrQkFBa0IsRUFBRSxxQkFBYyxDQUFDLFFBQVEsRUFBRSxZQUFZLEVBQUUsS0FBSyxDQUFDLFNBQVMsQ0FBQyxFQUFFLElBQUksRUFBRSxFQUFFLFFBQVEsRUFBRSxRQUFRLEVBQUUsRUFBRSxDQUFDO0tBQ3RIO1NBQU0sSUFBSSxLQU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XNzd29yZDtcbn1cbiJdfQ== \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/util.js b/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/util.js deleted file mode 100644 index d8dc8cad799c9..0000000000000 --- a/packages/@aws-cdk/aws-redshift/test/integ.database.js.snapshot/asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a/util.js +++ /dev/null @@ -1,34 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.areColumnsEqual = exports.getSortKeyColumns = exports.getDistKeyColumn = exports.makePhysicalId = void 0; -function makePhysicalId(resourceName, clusterProps, requestId) { - return `${clusterProps.clusterName}:${clusterProps.databaseName}:${resourceName}:${requestId}`; -} -exports.makePhysicalId = makePhysicalId; -function getDistKeyColumn(columns) { - // string comparison is required for custom resource since everything is passed as string - const distKeyColumns = columns.filter(column => column.distKey === true || column.distKey === 'true'); - if (distKeyColumns.length === 0) { - return undefined; - } - else if (distKeyColumns.length > 1) { - throw new Error('Multiple dist key columns found'); - } - return distKeyColumns[0]; -} -exports.getDistKeyColumn = getDistKeyColumn; -function getSortKeyColumns(columns) { - // string comparison is required for custom resource since everything is passed as string - return columns.filter(column => column.sortKey === true || column.sortKey === 'true'); -} -exports.getSortKeyColumns = getSortKeyColumns; -function areColumnsEqual(columnsA, columnsB) { - if (columnsA.length !== columnsB.length) { - return false; - } - return columnsA.every(columnA => { - return columnsB.find(column => column.name === columnA.name && column.dataType === columnA.dataType); - }); -} -exports.areColumnsEqual = areColumnsEqual; -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInV0aWwudHMiXSwibmF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tbnNCLmZpbmQoY29sdW1uID0+IGNvbHVtbi5uYW1lID09PSBjb2x1bW5BLm5hbWUgJiYgY29sdW1uLmRhdGFUeXBlID09PSBjb2x1bW5BLmRhdGFUeXBlKTtcbiAgfSk7XG59XG4iXX0= \ No newline at end of file From e4841f253e41336d0a6672e710adea994d05994b Mon Sep 17 00:00:00 2001 From: Rizbir Khan Date: Mon, 17 Apr 2023 14:16:20 +0000 Subject: [PATCH 04/21] change to test file, was failing build --- .../aws-ec2/test/machine-image.test.ts | 36 +++++++++---------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/packages/aws-cdk-lib/aws-ec2/test/machine-image.test.ts b/packages/aws-cdk-lib/aws-ec2/test/machine-image.test.ts index 3375f1736f9be..f73b481525a76 100644 --- a/packages/aws-cdk-lib/aws-ec2/test/machine-image.test.ts +++ b/packages/aws-cdk-lib/aws-ec2/test/machine-image.test.ts @@ -272,7 +272,9 @@ test('cached lookups of Amazon Linux 2022 with kernel 5.x', () => { describe('latest amazon linux', () => { test('latestAmazonLinux2', () => { // WHEN - ec2.MachineImage.latestAmazonLinux2().getImage(stack); + ec2.MachineImage.latestAmazonLinux({ + generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2, + }).getImage(stack); // THEN Template.fromStack(stack).hasParameter('*', { @@ -283,13 +285,9 @@ describe('latest amazon linux', () => { test('AmazonLinux2ImageSsmParameter', () => { // WHEN - const ami = new ec2.AmazonLinux2ImageSsmParameter({ - cpuType: ec2.AmazonLinuxCpuType.ARM_64, - edition: ec2.AmazonLinuxEdition.MINIMAL, - virtualization: ec2.AmazonLinuxVirt.PV, - storage: ec2.AmazonLinuxStorage.EBS, - kernel: ec2.AmazonLinux2Kernel.DEFAULT, - }).getImage(stack).imageId; + const ami = ec2.AmazonLinuxImage.ssmParameterName({ + generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2, + }); // THEN expect(ami).toEqual('dummy-value-for-/aws/service/ami-amazon-linux-latest/amzn2-ami-minimal-pv-arm64-ebs'); @@ -309,7 +307,9 @@ describe('latest amazon linux', () => { test('latestAmazonLinux2022', () => { // WHEN - ec2.MachineImage.latestAmazonLinux2022().getImage(stack); + ec2.MachineImage.latestAmazonLinux({ + generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2022, + }).getImage(stack); // THEN Template.fromStack(stack).hasParameter('*', { @@ -320,11 +320,9 @@ describe('latest amazon linux', () => { test('AmazonLinux2022ImageSsmParameter', () => { // WHEN - const ami = new ec2.AmazonLinux2022ImageSsmParameter({ - cpuType: ec2.AmazonLinuxCpuType.ARM_64, - edition: ec2.AmazonLinuxEdition.MINIMAL, - kernel: ec2.AmazonLinux2022Kernel.DEFAULT, - }).getImage(stack).imageId; + const ami = ec2.AmazonLinuxImage.ssmParameterName({ + generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2022, + }); // THEN expect(ami).toEqual('dummy-value-for-/aws/service/ami-amazon-linux-latest/al2022-ami-minimal-kernel-default-arm64'); @@ -344,7 +342,7 @@ describe('latest amazon linux', () => { test('latestAmazonLinux2023', () => { // WHEN - ec2.MachineImage.latestAmazonLinux2023().getImage(stack); + ec2.MachineImage.latestAmazonLinux().getImage(stack); // THEN Template.fromStack(stack).hasParameter('*', { @@ -355,11 +353,9 @@ describe('latest amazon linux', () => { test('AmazonLinux2023ImageSsmParameter', () => { // WHEN - const ami = new ec2.AmazonLinux2023ImageSsmParameter({ - cpuType: ec2.AmazonLinuxCpuType.ARM_64, - edition: ec2.AmazonLinuxEdition.MINIMAL, - kernel: ec2.AmazonLinux2023Kernel.DEFAULT, - }).getImage(stack).imageId; + const ami = ec2.AmazonLinuxImage.ssmParameterName({ + generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX, + }); // THEN expect(ami).toEqual('dummy-value-for-/aws/service/ami-amazon-linux-latest/al2023-ami-minimal-kernel-default-arm64'); From 5c585d70a4b06662261a000ad2311902be79a260 Mon Sep 17 00:00:00 2001 From: Rizbir Khan Date: Mon, 17 Apr 2023 14:16:30 +0000 Subject: [PATCH 05/21] integ test --- .../table.js | 171 ------------ .../cfn-response.js | 87 ++++++ .../consts.js | 0 .../framework.js | 170 ++++++++++++ .../outbound.js | 69 +++++ .../util.js | 0 .../handler-name.js | 10 + .../index.js | 0 .../privileges.js | 69 +++++ .../redshift-data.js | 37 +++ .../table.js | 171 ++++++++++++ .../types.js | 0 .../user.js | 70 +++++ .../util.js | 34 +++ .../cfn-response.js | 87 ------ .../framework.js | 168 ------------ .../outbound.js | 69 ----- ...-cdk-redshift-cluster-database.assets.json | 18 +- ...dk-redshift-cluster-database.template.json | 9 +- .../integ.database.js.snapshot/manifest.json | 12 +- .../test/integ.database.js.snapshot/tree.json | 248 +++++++++--------- 21 files changed, 863 insertions(+), 636 deletions(-) delete mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1a159599b617b432864ddf9e4e9ec70b884de7656daa51073d4149a3080c5f79/table.js create mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746/cfn-response.js rename packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/{asset.a8a62b989c7866e3ad5b24f3eb6228f8ca91ebff5f5c76f1da466f6c805c0585 => asset.1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746}/consts.js (100%) create mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746/framework.js create mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746/outbound.js rename packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/{asset.a8a62b989c7866e3ad5b24f3eb6228f8ca91ebff5f5c76f1da466f6c805c0585 => asset.1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746}/util.js (100%) create mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/handler-name.js rename packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/{asset.1a159599b617b432864ddf9e4e9ec70b884de7656daa51073d4149a3080c5f79 => asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c}/index.js (100%) create mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/privileges.js create mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/redshift-data.js create mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/table.js rename packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/{asset.1a159599b617b432864ddf9e4e9ec70b884de7656daa51073d4149a3080c5f79 => asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c}/types.js (100%) create mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/user.js create mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/util.js delete mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.a8a62b989c7866e3ad5b24f3eb6228f8ca91ebff5f5c76f1da466f6c805c0585/cfn-response.js delete mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.a8a62b989c7866e3ad5b24f3eb6228f8ca91ebff5f5c76f1da466f6c805c0585/framework.js delete mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.a8a62b989c7866e3ad5b24f3eb6228f8ca91ebff5f5c76f1da466f6c805c0585/outbound.js diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1a159599b617b432864ddf9e4e9ec70b884de7656daa51073d4149a3080c5f79/table.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1a159599b617b432864ddf9e4e9ec70b884de7656daa51073d4149a3080c5f79/table.js deleted file mode 100644 index 8b7f3f6a680fa..0000000000000 --- a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1a159599b617b432864ddf9e4e9ec70b884de7656daa51073d4149a3080c5f79/table.js +++ /dev/null @@ -1,171 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.handler = void 0; -const redshift_data_1 = require("./redshift-data"); -const types_1 = require("./types"); -const util_1 = require("./util"); -async function handler(props, event) { - const tableNamePrefix = props.tableName.prefix; - const tableNameSuffix = props.tableName.generateSuffix === 'true' ? `${event.RequestId.substring(0, 8)}` : ''; - const tableColumns = props.tableColumns; - const tableAndClusterProps = props; - const useColumnIds = props.useColumnIds; - if (event.RequestType === 'Create') { - const tableName = await createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps); - return { PhysicalResourceId: tableName }; - } - else if (event.RequestType === 'Delete') { - await dropTable(event.PhysicalResourceId, tableAndClusterProps); - return; - } - else if (event.RequestType === 'Update') { - const tableName = await updateTable(event.PhysicalResourceId, tableNamePrefix, tableNameSuffix, tableColumns, useColumnIds, tableAndClusterProps, event.OldResourceProperties); - return { PhysicalResourceId: tableName }; - } - else { - /* eslint-disable-next-line dot-notation */ - throw new Error(`Unrecognized event type: ${event['RequestType']}`); - } -} -exports.handler = handler; -async function createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps) { - const tableName = tableNamePrefix + tableNameSuffix; - const tableColumnsString = tableColumns.map(column => `${column.name} ${column.dataType}${getEncodingColumnString(column)}`).join(); - let statement = `CREATE TABLE ${tableName} (${tableColumnsString})`; - if (tableAndClusterProps.distStyle) { - statement += ` DISTSTYLE ${tableAndClusterProps.distStyle}`; - } - const distKeyColumn = util_1.getDistKeyColumn(tableColumns); - if (distKeyColumn) { - statement += ` DISTKEY(${distKeyColumn.name})`; - } - const sortKeyColumns = util_1.getSortKeyColumns(tableColumns); - if (sortKeyColumns.length > 0) { - const sortKeyColumnsString = getSortKeyColumnsString(sortKeyColumns); - statement += ` ${tableAndClusterProps.sortStyle} SORTKEY(${sortKeyColumnsString})`; - } - await redshift_data_1.executeStatement(statement, tableAndClusterProps); - for (const column of tableColumns) { - if (column.comment) { - await redshift_data_1.executeStatement(`COMMENT ON COLUMN ${tableName}.${column.name} IS '${column.comment}'`, tableAndClusterProps); - } - } - if (tableAndClusterProps.tableComment) { - await redshift_data_1.executeStatement(`COMMENT ON TABLE ${tableName} IS '${tableAndClusterProps.tableComment}'`, tableAndClusterProps); - } - return tableName; -} -async function dropTable(tableName, clusterProps) { - await redshift_data_1.executeStatement(`DROP TABLE ${tableName}`, clusterProps); -} -async function updateTable(tableName, tableNamePrefix, tableNameSuffix, tableColumns, useColumnIds, tableAndClusterProps, oldResourceProperties) { - const alterationStatements = []; - const oldClusterProps = oldResourceProperties; - if (tableAndClusterProps.clusterName !== oldClusterProps.clusterName || tableAndClusterProps.databaseName !== oldClusterProps.databaseName) { - return createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps); - } - const oldTableNamePrefix = oldResourceProperties.tableName.prefix; - if (tableNamePrefix !== oldTableNamePrefix) { - return createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps); - } - const oldTableColumns = oldResourceProperties.tableColumns; - const columnDeletions = oldTableColumns.filter(oldColumn => (tableColumns.every(column => { - if (useColumnIds) { - return oldColumn.id ? oldColumn.id !== column.id : oldColumn.name !== column.name; - } - return oldColumn.name !== column.name; - }))); - if (columnDeletions.length > 0) { - alterationStatements.push(...columnDeletions.map(column => `ALTER TABLE ${tableName} DROP COLUMN ${column.name}`)); - } - const columnAdditions = tableColumns.filter(column => { - return !oldTableColumns.some(oldColumn => { - if (useColumnIds) { - return oldColumn.id ? oldColumn.id === column.id : oldColumn.name === column.name; - } - return oldColumn.name === column.name; - }); - }).map(column => `ADD ${column.name} ${column.dataType}`); - if (columnAdditions.length > 0) { - alterationStatements.push(...columnAdditions.map(addition => `ALTER TABLE ${tableName} ${addition}`)); - } - const columnEncoding = tableColumns.filter(column => { - return oldTableColumns.some(oldColumn => column.name === oldColumn.name && column.encoding !== oldColumn.encoding); - }).map(column => `ALTER COLUMN ${column.name} ENCODE ${column.encoding || 'AUTO'}`); - if (columnEncoding.length > 0) { - alterationStatements.push(`ALTER TABLE ${tableName} ${columnEncoding.join(', ')}`); - } - const columnComments = tableColumns.filter(column => { - return oldTableColumns.some(oldColumn => column.name === oldColumn.name && column.comment !== oldColumn.comment); - }).map(column => `COMMENT ON COLUMN ${tableName}.${column.name} IS ${column.comment ? `'${column.comment}'` : 'NULL'}`); - if (columnComments.length > 0) { - alterationStatements.push(...columnComments); - } - if (useColumnIds) { - const columnNameUpdates = tableColumns.reduce((updates, column) => { - const oldColumn = oldTableColumns.find(oldCol => oldCol.id && oldCol.id === column.id); - if (oldColumn && oldColumn.name !== column.name) { - updates[oldColumn.name] = column.name; - } - return updates; - }, {}); - if (Object.keys(columnNameUpdates).length > 0) { - alterationStatements.push(...Object.entries(columnNameUpdates).map(([oldName, newName]) => (`ALTER TABLE ${tableName} RENAME COLUMN ${oldName} TO ${newName}`))); - } - } - const oldDistStyle = oldResourceProperties.distStyle; - if ((!oldDistStyle && tableAndClusterProps.distStyle) || - (oldDistStyle && !tableAndClusterProps.distStyle)) { - return createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps); - } - else if (oldDistStyle !== tableAndClusterProps.distStyle) { - alterationStatements.push(`ALTER TABLE ${tableName} ALTER DISTSTYLE ${tableAndClusterProps.distStyle}`); - } - const oldDistKey = util_1.getDistKeyColumn(oldTableColumns)?.name; - const newDistKey = util_1.getDistKeyColumn(tableColumns)?.name; - if ((!oldDistKey && newDistKey) || (oldDistKey && !newDistKey)) { - return createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps); - } - else if (oldDistKey !== newDistKey) { - alterationStatements.push(`ALTER TABLE ${tableName} ALTER DISTKEY ${newDistKey}`); - } - const oldSortKeyColumns = util_1.getSortKeyColumns(oldTableColumns); - const newSortKeyColumns = util_1.getSortKeyColumns(tableColumns); - const oldSortStyle = oldResourceProperties.sortStyle; - const newSortStyle = tableAndClusterProps.sortStyle; - if ((oldSortStyle === newSortStyle && !util_1.areColumnsEqual(oldSortKeyColumns, newSortKeyColumns)) - || (oldSortStyle !== newSortStyle)) { - switch (newSortStyle) { - case types_1.TableSortStyle.INTERLEAVED: - // INTERLEAVED sort key addition requires replacement. - // https://docs.aws.amazon.com/redshift/latest/dg/r_ALTER_TABLE.html - return createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps); - case types_1.TableSortStyle.COMPOUND: { - const sortKeyColumnsString = getSortKeyColumnsString(newSortKeyColumns); - alterationStatements.push(`ALTER TABLE ${tableName} ALTER ${newSortStyle} SORTKEY(${sortKeyColumnsString})`); - break; - } - case types_1.TableSortStyle.AUTO: { - alterationStatements.push(`ALTER TABLE ${tableName} ALTER SORTKEY ${newSortStyle}`); - break; - } - } - } - const oldComment = oldResourceProperties.tableComment; - const newComment = tableAndClusterProps.tableComment; - if (oldComment !== newComment) { - alterationStatements.push(`COMMENT ON TABLE ${tableName} IS ${newComment ? `'${newComment}'` : 'NULL'}`); - } - await Promise.all(alterationStatements.map(statement => redshift_data_1.executeStatement(statement, tableAndClusterProps))); - return tableName; -} -function getSortKeyColumnsString(sortKeyColumns) { - return sortKeyColumns.map(column => column.name).join(); -} -function getEncodingColumnString(column) { - if (column.encoding) { - return ` ENCODE ${column.enc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c29ydEtleUNvbHVtbnMubWFwKGNvbHVtbiA9PiBjb2x1bW4ubmFtZSkuam9pbigpO1xufVxuXG5mdW5jdGlvbiBnZXRFbmNvZGluZ0NvbHVtblN0cmluZyhjb2x1bW46IENvbHVtbik6IHN0cmluZyB7XG4gIGlmIChjb2x1bW4uZW5jb2RpbmcpIHtcbiAgICByZXR1cm4gYCBFTkNPREUgJHtjb2x1bW4uZW5jb2Rpbmd9YDtcbiAgfVxuICByZXR1cm4gJyc7XG59XG4iXX0= \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746/cfn-response.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746/cfn-response.js new file mode 100644 index 0000000000000..18467aae70501 --- /dev/null +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746/cfn-response.js @@ -0,0 +1,87 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Retry = exports.safeHandler = exports.includeStackTraces = exports.submitResponse = exports.MISSING_PHYSICAL_ID_MARKER = exports.CREATE_FAILED_PHYSICAL_ID_MARKER = void 0; +/* eslint-disable max-len */ +/* eslint-disable no-console */ +const url = require("url"); +const outbound_1 = require("./outbound"); +const util_1 = require("./util"); +exports.CREATE_FAILED_PHYSICAL_ID_MARKER = 'AWSCDK::CustomResourceProviderFramework::CREATE_FAILED'; +exports.MISSING_PHYSICAL_ID_MARKER = 'AWSCDK::CustomResourceProviderFramework::MISSING_PHYSICAL_ID'; +async function submitResponse(status, event, options = {}) { + const json = { + Status: status, + Reason: options.reason || status, + StackId: event.StackId, + RequestId: event.RequestId, + PhysicalResourceId: event.PhysicalResourceId || exports.MISSING_PHYSICAL_ID_MARKER, + LogicalResourceId: event.LogicalResourceId, + NoEcho: options.noEcho, + Data: event.Data, + }; + (0, util_1.log)('submit response to cloudformation', json); + const responseBody = JSON.stringify(json); + const parsedUrl = url.parse(event.ResponseURL); + const retryOptions = { + attempts: 5, + sleep: 1000, + }; + await (0, util_1.withRetries)(retryOptions, outbound_1.httpRequest)({ + hostname: parsedUrl.hostname, + path: parsedUrl.path, + method: 'PUT', + headers: { + 'content-type': '', + 'content-length': Buffer.byteLength(responseBody, 'utf8'), + }, + }, responseBody); +} +exports.submitResponse = submitResponse; +exports.includeStackTraces = true; // for unit tests +function safeHandler(block) { + return async (event) => { + // ignore DELETE event when the physical resource ID is the marker that + // indicates that this DELETE is a subsequent DELETE to a failed CREATE + // operation. + if (event.RequestType === 'Delete' && event.PhysicalResourceId === exports.CREATE_FAILED_PHYSICAL_ID_MARKER) { + (0, util_1.log)('ignoring DELETE event caused by a failed CREATE event'); + await submitResponse('SUCCESS', event); + return; + } + try { + await block(event); + } + catch (e) { + // tell waiter state machine to retry + if (e instanceof Retry) { + (0, util_1.log)('retry requested by handler'); + throw e; + } + if (!event.PhysicalResourceId) { + // special case: if CREATE fails, which usually implies, we usually don't + // have a physical resource id. in this case, the subsequent DELETE + // operation does not have any meaning, and will likely fail as well. to + // address this, we use a marker so the provider framework can simply + // ignore the subsequent DELETE. + if (event.RequestType === 'Create') { + (0, util_1.log)('CREATE failed, responding with a marker physical resource id so that the subsequent DELETE will be ignored'); + event.PhysicalResourceId = exports.CREATE_FAILED_PHYSICAL_ID_MARKER; + } + else { + // otherwise, if PhysicalResourceId is not specified, something is + // terribly wrong because all other events should have an ID. + (0, util_1.log)(`ERROR: Malformed event. "PhysicalResourceId" is required: ${JSON.stringify({ ...event, ResponseURL: '...' })}`); + } + } + // this is an actual error, fail the activity altogether and exist. + await submitResponse('FAILED', event, { + reason: exports.includeStackTraces ? e.stack : e.message, + }); + } + }; +} +exports.safeHandler = safeHandler; +class Retry extends Error { +} +exports.Retry = Retry; +//# sourceMappingURL=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zZSBhbGwgb3RoZXIgZXZlbnRzIHNob3VsZCBoYXZlIGFuIElELlxuICAgICAgICAgIGxvZyhgRVJST1I6IE1hbGZvcm1lZCBldmVudC4gXCJQaHlzaWNhbFJlc291cmNlSWRcIiBpcyByZXF1aXJlZDogJHtKU09OLnN0cmluZ2lmeSh7IC4uLmV2ZW50LCBSZXNwb25zZVVSTDogJy4uLicgfSl9YCk7XG4gICAgICAgIH1cbiAgICAgIH1cblxuICAgICAgLy8gdGhpcyBpcyBhbiBhY3R1YWwgZXJyb3IsIGZhaWwgdGhlIGFjdGl2aXR5IGFsdG9nZXRoZXIgYW5kIGV4aXN0LlxuICAgICAgYXdhaXQgc3VibWl0UmVzcG9uc2UoJ0ZBSUxFRCcsIGV2ZW50LCB7XG4gICAgICAgIHJlYXNvbjogaW5jbHVkZVN0YWNrVHJhY2VzID8gZS5zdGFjayA6IGUubWVzc2FnZSxcbiAgICAgIH0pO1xuICAgIH1cbiAgfTtcbn1cblxuZXhwb3J0IGNsYXNzIFJldHJ5IGV4dGVuZHMgRXJyb3IgeyB9XG4iXX0= \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.a8a62b989c7866e3ad5b24f3eb6228f8ca91ebff5f5c76f1da466f6c805c0585/consts.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746/consts.js similarity index 100% rename from packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.a8a62b989c7866e3ad5b24f3eb6228f8ca91ebff5f5c76f1da466f6c805c0585/consts.js rename to packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746/consts.js diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746/framework.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746/framework.js new file mode 100644 index 0000000000000..f844797756840 --- /dev/null +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746/framework.js @@ -0,0 +1,170 @@ +"use strict"; +/* eslint-disable max-len */ +/* eslint-disable no-console */ +const cfnResponse = require("./cfn-response"); +const consts = require("./consts"); +const outbound_1 = require("./outbound"); +const util_1 = require("./util"); +/** + * The main runtime entrypoint of the async custom resource lambda function. + * + * Any lifecycle event changes to the custom resources will invoke this handler, which will, in turn, + * interact with the user-defined `onEvent` and `isComplete` handlers. + * + * This function will always succeed. If an error occurs + * + * @param cfnRequest The cloudformation custom resource event. + */ +async function onEvent(cfnRequest) { + const sanitizedRequest = { ...cfnRequest, ResponseURL: '...' }; + (0, util_1.log)('onEventHandler', sanitizedRequest); + cfnRequest.ResourceProperties = cfnRequest.ResourceProperties || {}; + const onEventResult = await invokeUserFunction(consts.USER_ON_EVENT_FUNCTION_ARN_ENV, sanitizedRequest, cfnRequest.ResponseURL); + (0, util_1.log)('onEvent returned:', onEventResult); + // merge the request and the result from onEvent to form the complete resource event + // this also performs validation. + const resourceEvent = createResponseEvent(cfnRequest, onEventResult); + (0, util_1.log)('event:', onEventResult); + // determine if this is an async provider based on whether we have an isComplete handler defined. + // if it is not defined, then we are basically ready to return a positive response. + if (!process.env[consts.USER_IS_COMPLETE_FUNCTION_ARN_ENV]) { + return cfnResponse.submitResponse('SUCCESS', resourceEvent, { noEcho: resourceEvent.NoEcho }); + } + // ok, we are not complete, so kick off the waiter workflow + const waiter = { + stateMachineArn: (0, util_1.getEnv)(consts.WAITER_STATE_MACHINE_ARN_ENV), + name: resourceEvent.RequestId, + input: JSON.stringify(resourceEvent), + }; + (0, util_1.log)('starting waiter', waiter); + // kick off waiter state machine + await (0, outbound_1.startExecution)(waiter); +} +// invoked a few times until `complete` is true or until it times out. +async function isComplete(event) { + const sanitizedRequest = { ...event, ResponseURL: '...' }; + (0, util_1.log)('isComplete', sanitizedRequest); + const isCompleteResult = await invokeUserFunction(consts.USER_IS_COMPLETE_FUNCTION_ARN_ENV, sanitizedRequest, event.ResponseURL); + (0, util_1.log)('user isComplete returned:', isCompleteResult); + // if we are not complete, return false, and don't send a response back. + if (!isCompleteResult.IsComplete) { + if (isCompleteResult.Data && Object.keys(isCompleteResult.Data).length > 0) { + throw new Error('"Data" is not allowed if "IsComplete" is "False"'); + } + // This must be the full event, it will be deserialized in `onTimeout` to send the response to CloudFormation + throw new cfnResponse.Retry(JSON.stringify(event)); + } + const response = { + ...event, + ...isCompleteResult, + Data: { + ...event.Data, + ...isCompleteResult.Data, + }, + }; + await cfnResponse.submitResponse('SUCCESS', response, { noEcho: event.NoEcho }); +} +// invoked when completion retries are exhaused. +async function onTimeout(timeoutEvent) { + (0, util_1.log)('timeoutHandler', timeoutEvent); + const isCompleteRequest = JSON.parse(JSON.parse(timeoutEvent.Cause).errorMessage); + await cfnResponse.submitResponse('FAILED', isCompleteRequest, { + reason: 'Operation timed out', + }); +} +async function invokeUserFunction(functionArnEnv, sanitizedPayload, responseUrl) { + const functionArn = (0, util_1.getEnv)(functionArnEnv); + (0, util_1.log)(`executing user function ${functionArn} with payload`, sanitizedPayload); + // transient errors such as timeouts, throttling errors (429), and other + // errors that aren't caused by a bad request (500 series) are retried + // automatically by the JavaScript SDK. + const resp = await (0, outbound_1.invokeFunction)({ + FunctionName: functionArn, + // Cannot strip 'ResponseURL' here as this would be a breaking change even though the downstream CR doesn't need it + Payload: JSON.stringify({ ...sanitizedPayload, ResponseURL: responseUrl }), + }); + (0, util_1.log)('user function response:', resp, typeof (resp)); + const jsonPayload = parseJsonPayload(resp.Payload); + if (resp.FunctionError) { + (0, util_1.log)('user function threw an error:', resp.FunctionError); + const errorMessage = jsonPayload.errorMessage || 'error'; + // parse function name from arn + // arn:${Partition}:lambda:${Region}:${Account}:function:${FunctionName} + const arn = functionArn.split(':'); + const functionName = arn[arn.length - 1]; + // append a reference to the log group. + const message = [ + errorMessage, + '', + `Logs: /aws/lambda/${functionName}`, + '', + ].join('\n'); + const e = new Error(message); + // the output that goes to CFN is what's in `stack`, not the error message. + // if we have a remote trace, construct a nice message with log group information + if (jsonPayload.trace) { + // skip first trace line because it's the message + e.stack = [message, ...jsonPayload.trace.slice(1)].join('\n'); + } + throw e; + } + return jsonPayload; +} +function parseJsonPayload(payload) { + if (!payload) { + return {}; + } + const text = payload.toString(); + try { + return JSON.parse(text); + } + catch { + throw new Error(`return values from user-handlers must be JSON objects. got: "${text}"`); + } +} +function createResponseEvent(cfnRequest, onEventResult) { + // + // validate that onEventResult always includes a PhysicalResourceId + onEventResult = onEventResult || {}; + // if physical ID is not returned, we have some defaults for you based + // on the request type. + const physicalResourceId = onEventResult.PhysicalResourceId || defaultPhysicalResourceId(cfnRequest); + // if we are in DELETE and physical ID was changed, it's an error. + if (cfnRequest.RequestType === 'Delete' && physicalResourceId !== cfnRequest.PhysicalResourceId) { + throw new Error(`DELETE: cannot change the physical resource ID from "${cfnRequest.PhysicalResourceId}" to "${onEventResult.PhysicalResourceId}" during deletion`); + } + // if we are in UPDATE and physical ID was changed, it's a replacement (just log) + if (cfnRequest.RequestType === 'Update' && physicalResourceId !== cfnRequest.PhysicalResourceId) { + (0, util_1.log)(`UPDATE: changing physical resource ID from "${cfnRequest.PhysicalResourceId}" to "${onEventResult.PhysicalResourceId}"`); + } + // merge request event and result event (result prevails). + return { + ...cfnRequest, + ...onEventResult, + PhysicalResourceId: physicalResourceId, + }; +} +/** + * Calculates the default physical resource ID based in case user handler did + * not return a PhysicalResourceId. + * + * For "CREATE", it uses the RequestId. + * For "UPDATE" and "DELETE" and returns the current PhysicalResourceId (the one provided in `event`). + */ +function defaultPhysicalResourceId(req) { + switch (req.RequestType) { + case 'Create': + return req.RequestId; + case 'Update': + case 'Delete': + return req.PhysicalResourceId; + default: + throw new Error(`Invalid "RequestType" in request "${JSON.stringify(req)}"`); + } +} +module.exports = { + [consts.FRAMEWORK_ON_EVENT_HANDLER_NAME]: cfnResponse.safeHandler(onEvent), + [consts.FRAMEWORK_IS_COMPLETE_HANDLER_NAME]: cfnResponse.safeHandler(isComplete), + [consts.FRAMEWORK_ON_TIMEOUT_HANDLER_NAME]: onTimeout, +}; +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZnJhbWV3b3JrLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiZnJhbWV3b3JrLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSw0QkFBNEI7QUFDNUIsK0JBQStCO0FBQy9CLDhDQUE4QztBQUM5QyxtQ0FBbUM7QUFDbkMseUNBQTREO0FBQzVELGlDQUFxQztBQVVyQzs7Ozs7Ozs7O0dBU0c7QUFDSCxLQUFLLFVBQVUsT0FBTyxDQUFDLFVBQXVEO0lBQzVFLE1BQU0sZ0JBQWdCLEdBQUcsRUFBRSxHQUFHLFVBQVUsRUFBRSxXQUFXLEVBQUUsS0FBSyxFQUFXLENBQUM7SUFDeEUsSUFBQSxVQUFHLEVBQUMsZ0JBQWdCLEVBQUUsZ0JBQWdCLENBQUMsQ0FBQztJQUV4QyxVQUFVLENBQUMsa0JBQWtCLEdBQUcsVUFBVSxDQUFDLGtCQUFrQixJQUFJLEVBQUcsQ0FBQztJQUVyRSxNQUFNLGFBQWEsR0FBRyxNQUFNLGtCQUFrQixDQUFDLE1BQU0sQ0FBQyw4QkFBOEIsRUFBRSxnQkFBZ0IsRUFBRSxVQUFVLENBQUMsV0FBVyxDQUFvQixDQUFDO0lBQ25KLElBQUEsVUFBRyxFQUFDLG1CQUFtQixFQUFFLGFBQWEsQ0FBQyxDQUFDO0lBRXhDLG9GQUFvRjtJQUNwRixpQ0FBaUM7SUFDakMsTUFBTSxhQUFhLEdBQUcsbUJ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W5kbGVyIGRpZFxuICogbm90IHJldHVybiBhIFBoeXNpY2FsUmVzb3VyY2VJZC5cbiAqXG4gKiBGb3IgXCJDUkVBVEVcIiwgaXQgdXNlcyB0aGUgUmVxdWVzdElkLlxuICogRm9yIFwiVVBEQVRFXCIgYW5kIFwiREVMRVRFXCIgYW5kIHJldHVybnMgdGhlIGN1cnJlbnQgUGh5c2ljYWxSZXNvdXJjZUlkICh0aGUgb25lIHByb3ZpZGVkIGluIGBldmVudGApLlxuICovXG5mdW5jdGlvbiBkZWZhdWx0UGh5c2ljYWxSZXNvdXJjZUlkKHJlcTogQVdTTGFtYmRhLkNsb3VkRm9ybWF0aW9uQ3VzdG9tUmVzb3VyY2VFdmVudCk6IHN0cmluZyB7XG4gIHN3aXRjaCAocmVxLlJlcXVlc3RUeXBlKSB7XG4gICAgY2FzZSAnQ3JlYXRlJzpcbiAgICAgIHJldHVybiByZXEuUmVxdWVzdElkO1xuXG4gICAgY2FzZSAnVXBkYXRlJzpcbiAgICBjYXNlICdEZWxldGUnOlxuICAgICAgcmV0dXJuIHJlcS5QaHlzaWNhbFJlc291cmNlSWQ7XG5cbiAgICBkZWZhdWx0OlxuICAgICAgdGhyb3cgbmV3IEVycm9yKGBJbnZhbGlkIFwiUmVxdWVzdFR5cGVcIiBpbiByZXF1ZXN0IFwiJHtKU09OLnN0cmluZ2lmeShyZXEpfVwiYCk7XG4gIH1cbn1cbiJdfQ== \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746/outbound.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746/outbound.js new file mode 100644 index 0000000000000..633482cec2767 --- /dev/null +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746/outbound.js @@ -0,0 +1,69 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.httpRequest = exports.invokeFunction = exports.startExecution = void 0; +/* istanbul ignore file */ +const https = require("https"); +// eslint-disable-next-line import/no-extraneous-dependencies +const AWS = require("aws-sdk"); +const FRAMEWORK_HANDLER_TIMEOUT = 900000; // 15 minutes +// In order to honor the overall maximum timeout set for the target process, +// the default 2 minutes from AWS SDK has to be overriden: +// https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#httpOptions-property +const awsSdkConfig = { + httpOptions: { timeout: FRAMEWORK_HANDLER_TIMEOUT }, +}; +async function defaultHttpRequest(options, responseBody) { + return new Promise((resolve, reject) => { + try { + const request = https.request(options, resolve); + request.on('error', reject); + request.write(responseBody); + request.end(); + } + catch (e) { + reject(e); + } + }); +} +let sfn; +let lambda; +async function defaultStartExecution(req) { + if (!sfn) { + sfn = new AWS.StepFunctions(awsSdkConfig); + } + return sfn.startExecution(req).promise(); +} +async function defaultInvokeFunction(req) { + if (!lambda) { + lambda = new AWS.Lambda(awsSdkConfig); + } + try { + /** + * Try an initial invoke. + * + * When you try to invoke a function that is inactive, the invocation fails and Lambda sets + * the function to pending state until the function resources are recreated. + * If Lambda fails to recreate the resources, the function is set to the inactive state. + * + * We're using invoke first because `waitFor` doesn't trigger an inactive function to do anything, + * it just runs `getFunction` and checks the state. + */ + return await lambda.invoke(req).promise(); + } + catch { + /** + * The status of the Lambda function is checked every second for up to 300 seconds. + * Exits the loop on 'Active' state and throws an error on 'Inactive' or 'Failed'. + * + * And now we wait. + */ + await lambda.waitFor('functionActiveV2', { + FunctionName: req.FunctionName, + }).promise(); + return await lambda.invoke(req).promise(); + } +} +exports.startExecution = defaultStartExecution; +exports.invokeFunction = defaultInvokeFunction; +exports.httpRequest = defaultHttpRequest; +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3V0Ym91bmQuanMiLCJzb3VyY2VS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cnQgbGV0IGludm9rZUZ1bmN0aW9uID0gZGVmYXVsdEludm9rZUZ1bmN0aW9uO1xuZXhwb3J0IGxldCBodHRwUmVxdWVzdCA9IGRlZmF1bHRIdHRwUmVxdWVzdDtcbiJdfQ== \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.a8a62b989c7866e3ad5b24f3eb6228f8ca91ebff5f5c76f1da466f6c805c0585/util.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746/util.js similarity index 100% rename from packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.a8a62b989c7866e3ad5b24f3eb6228f8ca91ebff5f5c76f1da466f6c805c0585/util.js rename to packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746/util.js diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/handler-name.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/handler-name.js new file mode 100644 index 0000000000000..4983115a93834 --- /dev/null +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/handler-name.js @@ -0,0 +1,10 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.HandlerName = void 0; +var HandlerName; +(function (HandlerName) { + HandlerName["User"] = "user"; + HandlerName["Table"] = "table"; + HandlerName["UserTablePrivileges"] = "user-table-privileges"; +})(HandlerName = exports.HandlerName || (exports.HandlerName = {})); +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGFuZGxlci1uYW1lLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiaGFuZGxlci1uYW1lLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLElBQVksV0FJWDtBQUpELFdBQVksV0FBVztJQUNyQiw0QkFBYSxDQUFBO0lBQ2IsOEJBQWUsQ0FBQTtJQUNmLDREQUE2QyxDQUFBO0FBQy9DLENBQUMsRUFKVyxXQUFXLEdBQVgsbUJBQVcsS0FBWCxtQkFBVyxRQUl0QiIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBlbnVtIEhhbmRsZXJOYW1lIHtcbiAgVXNlciA9ICd1c2VyJyxcbiAgVGFibGUgPSAndGFibGUnLFxuICBVc2VyVGFibGVQcml2aWxlZ2VzID0gJ3VzZXItdGFibGUtcHJpdmlsZWdlcycsXG59XG4iXX0= \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1a159599b617b432864ddf9e4e9ec70b884de7656daa51073d4149a3080c5f79/index.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/index.js similarity index 100% rename from packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1a159599b617b432864ddf9e4e9ec70b884de7656daa51073d4149a3080c5f79/index.js rename to packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/index.js diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/privileges.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/privileges.js new file mode 100644 index 0000000000000..22d622acfbd79 --- /dev/null +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/privileges.js @@ -0,0 +1,69 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.handler = void 0; +const redshift_data_1 = require("./redshift-data"); +const util_1 = require("./util"); +async function handler(props, event) { + const username = props.username; + const tablePrivileges = props.tablePrivileges; + const clusterProps = props; + if (event.RequestType === 'Create') { + await grantPrivileges(username, tablePrivileges, clusterProps); + return { PhysicalResourceId: (0, util_1.makePhysicalId)(username, clusterProps, event.RequestId) }; + } + else if (event.RequestType === 'Delete') { + await revokePrivileges(username, tablePrivileges, clusterProps); + return; + } + else if (event.RequestType === 'Update') { + const { replace } = await updatePrivileges(username, tablePrivileges, clusterProps, event.OldResourceProperties); + const physicalId = replace ? (0, util_1.makePhysicalId)(username, clusterProps, event.RequestId) : event.PhysicalResourceId; + return { PhysicalResourceId: physicalId }; + } + else { + /* eslint-disable-next-line dot-notation */ + throw new Error(`Unrecognized event type: ${event['RequestType']}`); + } +} +exports.handler = handler; +async function revokePrivileges(username, tablePrivileges, clusterProps) { + await Promise.all(tablePrivileges.map(({ tableName, actions }) => { + return (0, redshift_data_1.executeStatement)(`REVOKE ${actions.join(', ')} ON ${tableName} FROM ${username}`, clusterProps); + })); +} +async function grantPrivileges(username, tablePrivileges, clusterProps) { + await Promise.all(tablePrivileges.map(({ tableName, actions }) => { + return (0, redshift_data_1.executeStatement)(`GRANT ${actions.join(', ')} ON ${tableName} TO ${username}`, clusterProps); + })); +} +async function updatePrivileges(username, tablePrivileges, clusterProps, oldResourceProperties) { + const oldClusterProps = oldResourceProperties; + if (clusterProps.clusterName !== oldClusterProps.clusterName || clusterProps.databaseName !== oldClusterProps.databaseName) { + await grantPrivileges(username, tablePrivileges, clusterProps); + return { replace: true }; + } + const oldUsername = oldResourceProperties.username; + if (oldUsername !== username) { + await grantPrivileges(username, tablePrivileges, clusterProps); + return { replace: true }; + } + const oldTablePrivileges = oldResourceProperties.tablePrivileges; + const tablesToRevoke = oldTablePrivileges.filter(({ tableId, actions }) => { + const tableRemoved = !tablePrivileges.find(({ tableId: otherTableId }) => tableId === otherTableId); + const actionsRemoved = tablePrivileges.find(({ tableId: otherTableId, actions: otherActions }) => (tableId === otherTableId && actions.some(action => !otherActions.includes(action)))); + return tableRemoved || actionsRemoved; + }); + if (tablesToRevoke.length > 0) { + await revokePrivileges(username, tablesToRevoke, clusterProps); + } + const tablesToGrant = tablePrivileges.filter(({ tableId, tableName, actions }) => { + const tableAdded = !oldTablePrivileges.find(({ tableId: otherTableId, tableName: otherTableName }) => (tableId === otherTableId && tableName === otherTableName)); + const actionsAdded = oldTablePrivileges.find(({ tableId: otherTableId, actions: otherActions }) => (tableId === otherTableId && otherActions.some(action => !actions.includes(action)))); + return tableAdded || actionsAdded; + }); + if (tablesToGrant.length > 0) { + await grantPrivileges(username, tablesToGrant, clusterProps); + } + return { replace: false }; +} +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJpdmlsZWdlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInByaXZpbGVnZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBRUEsbURBQW1EO0FBRW5ELGlDQUF3QztBQUdqQyxLQUFLLFVBQVUsT0FBTyxDQUFDLEtBQXFELEVBQUUsS0FBa0Q7SUFDckksTUFBTSxRQUFRLEdBQUcsS0FBSyxDQUFDLFFBQVEsQ0FBQztJQUNoQyxNQUFNLGVBQWUsR0FBRyxLQUFLLENBQUMsZUFBZSxDQUFDO0lBQzlDLE1BQU0sWUFBWSxHQUFHLEtBQUssQ0FBQztJQUUzQixJQUFJLEtBQUssQ0FBQyxXQUFXLEtBQUssUUFBUSxFQUFFO1FBQ2xDLE1BQU0sZUFBZSxDQUFDLFFBQVEsRUFBRSxlQUFlLEVBQUUsWUFBWSxDQUFDLENBQUM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 No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/redshift-data.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/redshift-data.js new file mode 100644 index 0000000000000..e65374f4ab7e0 --- /dev/null +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/redshift-data.js @@ -0,0 +1,37 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.executeStatement = void 0; +/* eslint-disable-next-line import/no-extraneous-dependencies */ +const RedshiftData = require("aws-sdk/clients/redshiftdata"); +const redshiftData = new RedshiftData(); +async function executeStatement(statement, clusterProps) { + const executeStatementProps = { + ClusterIdentifier: clusterProps.clusterName, + Database: clusterProps.databaseName, + SecretArn: clusterProps.adminUserArn, + Sql: statement, + }; + const executedStatement = await redshiftData.executeStatement(executeStatementProps).promise(); + if (!executedStatement.Id) { + throw new Error('Service error: Statement execution did not return a statement ID'); + } + await waitForStatementComplete(executedStatement.Id); +} +exports.executeStatement = executeStatement; +const waitTimeout = 100; +async function waitForStatementComplete(statementId) { + await new Promise((resolve) => { + setTimeout(() => resolve(), waitTimeout); + }); + const statement = await redshiftData.describeStatement({ Id: statementId }).promise(); + if (statement.Status !== 'FINISHED' && statement.Status !== 'FAILED' && statement.Status !== 'ABORTED') { + return waitForStatementComplete(statementId); + } + else if (statement.Status === 'FINISHED') { + return; + } + else { + throw new Error(`Statement status was ${statement.Status}: ${statement.Error}`); + } +} +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVkc2hpZnQtZGF0YS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInJlZHNoaWZ0LWRhdGEudHMi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IHdhaXRGb3JTdGF0ZW1lbnRDb21wbGV0ZShzdGF0ZW1lbnRJZCk7XG4gIH0gZWxzZSBpZiAoc3RhdGVtZW50LlN0YXR1cyA9PT0gJ0ZJTklTSEVEJykge1xuICAgIHJldHVybjtcbiAgfSBlbHNlIHtcbiAgICB0aHJvdyBuZXcgRXJyb3IoYFN0YXRlbWVudCBzdGF0dXMgd2FzICR7c3RhdGVtZW50LlN0YXR1c306ICR7c3RhdGVtZW50LkVycm9yfWApO1xuICB9XG59XG4iXX0= \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/table.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/table.js new file mode 100644 index 0000000000000..b1d964720f151 --- /dev/null +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/table.js @@ -0,0 +1,171 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.handler = void 0; +const redshift_data_1 = require("./redshift-data"); +const types_1 = require("./types"); +const util_1 = require("./util"); +async function handler(props, event) { + const tableNamePrefix = props.tableName.prefix; + const tableNameSuffix = props.tableName.generateSuffix === 'true' ? `${event.RequestId.substring(0, 8)}` : ''; + const tableColumns = props.tableColumns; + const tableAndClusterProps = props; + const useColumnIds = props.useColumnIds; + if (event.RequestType === 'Create') { + const tableName = await createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps); + return { PhysicalResourceId: tableName }; + } + else if (event.RequestType === 'Delete') { + await dropTable(event.PhysicalResourceId, tableAndClusterProps); + return; + } + else if (event.RequestType === 'Update') { + const tableName = await updateTable(event.PhysicalResourceId, tableNamePrefix, tableNameSuffix, tableColumns, useColumnIds, tableAndClusterProps, event.OldResourceProperties); + return { PhysicalResourceId: tableName }; + } + else { + /* eslint-disable-next-line dot-notation */ + throw new Error(`Unrecognized event type: ${event['RequestType']}`); + } +} +exports.handler = handler; +async function createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps) { + const tableName = tableNamePrefix + tableNameSuffix; + const tableColumnsString = tableColumns.map(column => `${column.name} ${column.dataType}${getEncodingColumnString(column)}`).join(); + let statement = `CREATE TABLE ${tableName} (${tableColumnsString})`; + if (tableAndClusterProps.distStyle) { + statement += ` DISTSTYLE ${tableAndClusterProps.distStyle}`; + } + const distKeyColumn = (0, util_1.getDistKeyColumn)(tableColumns); + if (distKeyColumn) { + statement += ` DISTKEY(${distKeyColumn.name})`; + } + const sortKeyColumns = (0, util_1.getSortKeyColumns)(tableColumns); + if (sortKeyColumns.length > 0) { + const sortKeyColumnsString = getSortKeyColumnsString(sortKeyColumns); + statement += ` ${tableAndClusterProps.sortStyle} SORTKEY(${sortKeyColumnsString})`; + } + await (0, redshift_data_1.executeStatement)(statement, tableAndClusterProps); + for (const column of tableColumns) { + if (column.comment) { + await (0, redshift_data_1.executeStatement)(`COMMENT ON COLUMN ${tableName}.${column.name} IS '${column.comment}'`, tableAndClusterProps); + } + } + if (tableAndClusterProps.tableComment) { + await (0, redshift_data_1.executeStatement)(`COMMENT ON TABLE ${tableName} IS '${tableAndClusterProps.tableComment}'`, tableAndClusterProps); + } + return tableName; +} +async function dropTable(tableName, clusterProps) { + await (0, redshift_data_1.executeStatement)(`DROP TABLE ${tableName}`, clusterProps); +} +async function updateTable(tableName, tableNamePrefix, tableNameSuffix, tableColumns, useColumnIds, tableAndClusterProps, oldResourceProperties) { + const alterationStatements = []; + const oldClusterProps = oldResourceProperties; + if (tableAndClusterProps.clusterName !== oldClusterProps.clusterName || tableAndClusterProps.databaseName !== oldClusterProps.databaseName) { + return createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps); + } + const oldTableNamePrefix = oldResourceProperties.tableName.prefix; + if (tableNamePrefix !== oldTableNamePrefix) { + return createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps); + } + const oldTableColumns = oldResourceProperties.tableColumns; + const columnDeletions = oldTableColumns.filter(oldColumn => (tableColumns.every(column => { + if (useColumnIds) { + return oldColumn.id ? oldColumn.id !== column.id : oldColumn.name !== column.name; + } + return oldColumn.name !== column.name; + }))); + if (columnDeletions.length > 0) { + alterationStatements.push(...columnDeletions.map(column => `ALTER TABLE ${tableName} DROP COLUMN ${column.name}`)); + } + const columnAdditions = tableColumns.filter(column => { + return !oldTableColumns.some(oldColumn => { + if (useColumnIds) { + return oldColumn.id ? oldColumn.id === column.id : oldColumn.name === column.name; + } + return oldColumn.name === column.name; + }); + }).map(column => `ADD ${column.name} ${column.dataType}`); + if (columnAdditions.length > 0) { + alterationStatements.push(...columnAdditions.map(addition => `ALTER TABLE ${tableName} ${addition}`)); + } + const columnEncoding = tableColumns.filter(column => { + return oldTableColumns.some(oldColumn => column.name === oldColumn.name && column.encoding !== oldColumn.encoding); + }).map(column => `ALTER COLUMN ${column.name} ENCODE ${column.encoding || 'AUTO'}`); + if (columnEncoding.length > 0) { + alterationStatements.push(`ALTER TABLE ${tableName} ${columnEncoding.join(', ')}`); + } + const columnComments = tableColumns.filter(column => { + return oldTableColumns.some(oldColumn => column.name === oldColumn.name && column.comment !== oldColumn.comment); + }).map(column => `COMMENT ON COLUMN ${tableName}.${column.name} IS ${column.comment ? `'${column.comment}'` : 'NULL'}`); + if (columnComments.length > 0) { + alterationStatements.push(...columnComments); + } + if (useColumnIds) { + const columnNameUpdates = tableColumns.reduce((updates, column) => { + const oldColumn = oldTableColumns.find(oldCol => oldCol.id && oldCol.id === column.id); + if (oldColumn && oldColumn.name !== column.name) { + updates[oldColumn.name] = column.name; + } + return updates; + }, {}); + if (Object.keys(columnNameUpdates).length > 0) { + alterationStatements.push(...Object.entries(columnNameUpdates).map(([oldName, newName]) => (`ALTER TABLE ${tableName} RENAME COLUMN ${oldName} TO ${newName}`))); + } + } + const oldDistStyle = oldResourceProperties.distStyle; + if ((!oldDistStyle && tableAndClusterProps.distStyle) || + (oldDistStyle && !tableAndClusterProps.distStyle)) { + return createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps); + } + else if (oldDistStyle !== tableAndClusterProps.distStyle) { + alterationStatements.push(`ALTER TABLE ${tableName} ALTER DISTSTYLE ${tableAndClusterProps.distStyle}`); + } + const oldDistKey = (0, util_1.getDistKeyColumn)(oldTableColumns)?.name; + const newDistKey = (0, util_1.getDistKeyColumn)(tableColumns)?.name; + if ((!oldDistKey && newDistKey) || (oldDistKey && !newDistKey)) { + return createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps); + } + else if (oldDistKey !== newDistKey) { + alterationStatements.push(`ALTER TABLE ${tableName} ALTER DISTKEY ${newDistKey}`); + } + const oldSortKeyColumns = (0, util_1.getSortKeyColumns)(oldTableColumns); + const newSortKeyColumns = (0, util_1.getSortKeyColumns)(tableColumns); + const oldSortStyle = oldResourceProperties.sortStyle; + const newSortStyle = tableAndClusterProps.sortStyle; + if ((oldSortStyle === newSortStyle && !(0, util_1.areColumnsEqual)(oldSortKeyColumns, newSortKeyColumns)) + || (oldSortStyle !== newSortStyle)) { + switch (newSortStyle) { + case types_1.TableSortStyle.INTERLEAVED: + // INTERLEAVED sort key addition requires replacement. + // https://docs.aws.amazon.com/redshift/latest/dg/r_ALTER_TABLE.html + return createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps); + case types_1.TableSortStyle.COMPOUND: { + const sortKeyColumnsString = getSortKeyColumnsString(newSortKeyColumns); + alterationStatements.push(`ALTER TABLE ${tableName} ALTER ${newSortStyle} SORTKEY(${sortKeyColumnsString})`); + break; + } + case types_1.TableSortStyle.AUTO: { + alterationStatements.push(`ALTER TABLE ${tableName} ALTER SORTKEY ${newSortStyle}`); + break; + } + } + } + const oldComment = oldResourceProperties.tableComment; + const newComment = tableAndClusterProps.tableComment; + if (oldComment !== newComment) { + alterationStatements.push(`COMMENT ON TABLE ${tableName} IS ${newComment ? `'${newComment}'` : 'NULL'}`); + } + await Promise.all(alterationStatements.map(statement => (0, redshift_data_1.executeStatement)(statement, tableAndClusterProps))); + return tableName; +} +function getSortKeyColumnsString(sortKeyColumns) { + return sortKeyColumns.map(column => column.name).join(); +} +function getEncodingColumnString(column) { + if (column.encoding) { + return ` ENCODE ${column.encoding}`; + } + return ''; +} +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFibGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJ0YWJsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFFQSxtREFBbUQ7QUFDbkQsbUNBQTZFO0FBQzdFLGlDQUE4RTtBQUd2RSxLQUFLLFVBQVUsT0FBTyxDQUFDLEtBQTJCLEVBQUUsS0FBa0Q7SUFDM0csTUFBTSxlQUFlLEdBQUcsS0FBSyxDQUFDLFNBQVMsQ0FBQyxNQUFNLENBQUM7SUFDL0MsTUFBTSxlQUFlLEdBQUcsS0FBSyxDQUFDLFNBQVMsQ0FBQyxjQUFjLEtBQUssTUFBTSxDQUFDLENBQUMsQ0FBQyxHQUFHLEtBQUssQ0FBQyxTQUFTLENBQUMsU0FBUyxDQUFDLENBQUMsRUFBRSxDQUFDLENBQUMsRUFBRSxDQUFDLENBQUMsQ0FBQyxFQUFFLENBQUM7SUFDOUcsTUFBTSxZQUFZLEdBQUcsS0FBSyxDQUFDLFlBQVksQ0FBQztJQUN4QyxNQUFNLG9CQUFvQixHQUFHLEtBQUssQ0FBQztJQUNuQyxNQUFNLFlBQVksR0FBRyxLQUFLLENBQUMsWUFBWSxDQUFDO0lBRXhDLElBQUksS0FBSyxDQUFDLFdBQVcsS0FBSyxRQUFRLEVBQUU7UUFDbEMsTUFBTSxTQUFTLEdBQUcsTUFBTSxXQUFXLENBQUMsZUFBZSxFQUFFLGVBQWUsR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AgfVxuXG4gIGF3YWl0IFByb21pc2UuYWxsKGFsdGVyYXRpb25TdGF0ZW1lbnRzLm1hcChzdGF0ZW1lbnQgPT4gZXhlY3V0ZVN0YXRlbWVudChzdGF0ZW1lbnQsIHRhYmxlQW5kQ2x1c3RlclByb3BzKSkpO1xuXG4gIHJldHVybiB0YWJsZU5hbWU7XG59XG5cbmZ1bmN0aW9uIGdldFNvcnRLZXlDb2x1bW5zU3RyaW5nKHNvcnRLZXlDb2x1bW5zOiBDb2x1bW5bXSkge1xuICByZXR1cm4gc29ydEtleUNvbHVtbnMubWFwKGNvbHVtbiA9PiBjb2x1bW4ubmFtZSkuam9pbigpO1xufVxuXG5mdW5jdGlvbiBnZXRFbmNvZGluZ0NvbHVtblN0cmluZyhjb2x1bW46IENvbHVtbik6IHN0cmluZyB7XG4gIGlmIChjb2x1bW4uZW5jb2RpbmcpIHtcbiAgICByZXR1cm4gYCBFTkNPREUgJHtjb2x1bW4uZW5jb2Rpbmd9YDtcbiAgfVxuICByZXR1cm4gJyc7XG59XG4iXX0= \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1a159599b617b432864ddf9e4e9ec70b884de7656daa51073d4149a3080c5f79/types.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/types.js similarity index 100% rename from packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1a159599b617b432864ddf9e4e9ec70b884de7656daa51073d4149a3080c5f79/types.js rename to packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/types.js diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/user.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/user.js new file mode 100644 index 0000000000000..5dd198f92a512 --- /dev/null +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/user.js @@ -0,0 +1,70 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.handler = void 0; +/* eslint-disable-next-line import/no-extraneous-dependencies */ +const SecretsManager = require("aws-sdk/clients/secretsmanager"); +const redshift_data_1 = require("./redshift-data"); +const util_1 = require("./util"); +const secretsManager = new SecretsManager(); +async function handler(props, event) { + const username = props.username; + const passwordSecretArn = props.passwordSecretArn; + const clusterProps = props; + if (event.RequestType === 'Create') { + await createUser(username, passwordSecretArn, clusterProps); + return { PhysicalResourceId: (0, util_1.makePhysicalId)(username, clusterProps, event.RequestId), Data: { username: username } }; + } + else if (event.RequestType === 'Delete') { + await dropUser(username, clusterProps); + return; + } + else if (event.RequestType === 'Update') { + const { replace } = await updateUser(username, passwordSecretArn, clusterProps, event.OldResourceProperties); + const physicalId = replace ? (0, util_1.makePhysicalId)(username, clusterProps, event.RequestId) : event.PhysicalResourceId; + return { PhysicalResourceId: physicalId, Data: { username: username } }; + } + else { + /* eslint-disable-next-line dot-notation */ + throw new Error(`Unrecognized event type: ${event['RequestType']}`); + } +} +exports.handler = handler; +async function dropUser(username, clusterProps) { + await (0, redshift_data_1.executeStatement)(`DROP USER ${username}`, clusterProps); +} +async function createUser(username, passwordSecretArn, clusterProps) { + const password = await getPasswordFromSecret(passwordSecretArn); + await (0, redshift_data_1.executeStatement)(`CREATE USER ${username} PASSWORD '${password}'`, clusterProps); +} +async function updateUser(username, passwordSecretArn, clusterProps, oldResourceProperties) { + const oldClusterProps = oldResourceProperties; + if (clusterProps.clusterName !== oldClusterProps.clusterName || clusterProps.databaseName !== oldClusterProps.databaseName) { + await createUser(username, passwordSecretArn, clusterProps); + return { replace: true }; + } + const oldUsername = oldResourceProperties.username; + const oldPasswordSecretArn = oldResourceProperties.passwordSecretArn; + const oldPassword = await getPasswordFromSecret(oldPasswordSecretArn); + const password = await getPasswordFromSecret(passwordSecretArn); + if (username !== oldUsername) { + await createUser(username, passwordSecretArn, clusterProps); + return { replace: true }; + } + if (password !== oldPassword) { + await (0, redshift_data_1.executeStatement)(`ALTER USER ${username} PASSWORD '${password}'`, clusterProps); + return { replace: false }; + } + return { replace: false }; +} +async function getPasswordFromSecret(passwordSecretArn) { + const secretValue = await secretsManager.getSecretValue({ + SecretId: passwordSecretArn, + }).promise(); + const secretString = secretValue.SecretString; + if (!secretString) { + throw new Error(`Secret string for ${passwordSecretArn} was empty`); + } + const { password } = JSON.parse(secretString); + return password; +} +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXNlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInVzZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBRUEsZ0VBQWdFO0FBQ2hFLGlFQUFpRTtBQUNqRSxtREFBbUQ7QUFFbkQsaUNBQXdDO0FBR3hDLE1BQU0sY0FBYyxHQUFHLElBQUksY0FBYyxFQUFFLENBQUM7QUFFckMsS0FBSyxVQUFVLE9BQU8sQ0FBQyxLQUFzQyxFQUFFLEtBQWtEO0lBQ3RILE1BQU0sUUFBUSxHQUFHLEtBQUssQ0FBQyxRQUFRLENBQUM7SUFDaEMsTUFBTSxpQkFBaUIsR0FBRyxLQUFLLENBQUMsaUJBQWlCLENBQUM7SUFDbEQsTUFBTSxZQUFZLEdBQUcsS0FBSyxDQUFDO0lBRTNCLElBQUksS0FBSyxDQUFDLFdBQVcsS0FBSyxRQUFRLEVBQUU7UUFDbEMsTUFBTSxVQUFVLENBQUMsUUFBUSxFQUFFLGlCQUFpQixFQUFFLFlBQVksQ0FBQyxDQUFDO1FBQzVELE9BQU8sRUFBRSxrQkFB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HVlLlNlY3JldFN0cmluZztcbiAgaWYgKCFzZWNyZXRTdHJpbmcpIHtcbiAgICB0aHJvdyBuZXcgRXJyb3IoYFNlY3JldCBzdHJpbmcgZm9yICR7cGFzc3dvcmRTZWNyZXRBcm59IHdhcyBlbXB0eWApO1xuICB9XG4gIGNvbnN0IHsgcGFzc3dvcmQgfSA9IEpTT04ucGFyc2Uoc2VjcmV0U3RyaW5nKTtcblxuICByZXR1cm4gcGFzc3dvcmQ7XG59XG4iXX0= \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/util.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/util.js new file mode 100644 index 0000000000000..d8dc8cad799c9 --- /dev/null +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/util.js @@ -0,0 +1,34 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.areColumnsEqual = exports.getSortKeyColumns = exports.getDistKeyColumn = exports.makePhysicalId = void 0; +function makePhysicalId(resourceName, clusterProps, requestId) { + return `${clusterProps.clusterName}:${clusterProps.databaseName}:${resourceName}:${requestId}`; +} +exports.makePhysicalId = makePhysicalId; +function getDistKeyColumn(columns) { + // string comparison is required for custom resource since everything is passed as string + const distKeyColumns = columns.filter(column => column.distKey === true || column.distKey === 'true'); + if (distKeyColumns.length === 0) { + return undefined; + } + else if (distKeyColumns.length > 1) { + throw new Error('Multiple dist key columns found'); + } + return distKeyColumns[0]; +} +exports.getDistKeyColumn = getDistKeyColumn; +function getSortKeyColumns(columns) { + // string comparison is required for custom resource since everything is passed as string + return columns.filter(column => column.sortKey === true || column.sortKey === 'true'); +} +exports.getSortKeyColumns = getSortKeyColumns; +function areColumnsEqual(columnsA, columnsB) { + if (columnsA.length !== columnsB.length) { + return false; + } + return columnsA.every(columnA => { + return columnsB.find(column => column.name === columnA.name && column.dataType === columnA.dataType); + }); +} +exports.areColumnsEqual = areColumnsEqual; +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInV0aWwudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBR0EsU0FBZ0IsY0FBYyxDQUFDLFlBQW9CLEVBQUUsWUFBMEIsRUFBRSxTQUFpQjtJQUNoRyxPQUFPLEdBQUcsWUFBWSxDQUFDLFdBQVcsSUFBSSxZQUFZLENBQUMsWUFBWSxJQUFJLFlBQVksSUFBSSxTQUFTLEVBQUUsQ0FBQztBQUNqRyxDQUFDO0FBRkQsd0NBRUM7QUFFRCxTQUFnQixnQkFBZ0IsQ0FBQyxPQUFpQjtJQUNoRCx5RkFBeUY7SUFDekYsTUFBTSxjQUFjLEdBQUcsT0FBTyxDQUFDLE1BQU0sQ0FBQyxNQUFNLENBQUMsRUFBRSxDQUFDLE1BQU0sQ0FBQyxPQUFPLEtBQUssSUFBSSxJQUFLLE1BQU0sQ0FBQyxPQUE2QixLQUFLLE1BQU0sQ0FBQyxDQUFDO0lBRTdILElBQUksY0FBYyxDQUFDLE1BQU0sS0FBSyxDQUFDLEVBQUU7UUFDL0IsT0FBTyxTQUFTLENBQUM7S0FDbEI7U0FBTSxJQUFJLGNBQWMsQ0FBQyxNQUFNLEdBQUcsQ0FBQyxFQUFFO1FBQ3BDLE1BQU0sSUFBSSxLQUFLLENBQUMsaUNBQWlDLENBQUMsQ0FBQztLQUNwRDtJQUVELE9BQU8sY0FBYyxDQUFDLENBQUMsQ0FBQyxDQUFDO0FBQzNCLENBQUM7QUFYRCw0Q0FXQztBQUVELFNBQWdCLGlCQUFpQixDQUFDLE9BQWlCO0lBQ2pELHlGQUF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Q29sdW1uc0VxdWFsKGNvbHVtbnNBOiBDb2x1bW5bXSwgY29sdW1uc0I6IENvbHVtbltdKTogYm9vbGVhbiB7XG4gIGlmIChjb2x1bW5zQS5sZW5ndGggIT09IGNvbHVtbnNCLmxlbmd0aCkge1xuICAgIHJldHVybiBmYWxzZTtcbiAgfVxuICByZXR1cm4gY29sdW1uc0EuZXZlcnkoY29sdW1uQSA9PiB7XG4gICAgcmV0dXJuIGNvbHVtbnNCLmZpbmQoY29sdW1uID0+IGNvbHVtbi5uYW1lID09PSBjb2x1bW5BLm5hbWUgJiYgY29sdW1uLmRhdGFUeXBlID09PSBjb2x1bW5BLmRhdGFUeXBlKTtcbiAgfSk7XG59XG4iXX0= \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.a8a62b989c7866e3ad5b24f3eb6228f8ca91ebff5f5c76f1da466f6c805c0585/cfn-response.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.a8a62b989c7866e3ad5b24f3eb6228f8ca91ebff5f5c76f1da466f6c805c0585/cfn-response.js deleted file mode 100644 index 1966567b21646..0000000000000 --- a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.a8a62b989c7866e3ad5b24f3eb6228f8ca91ebff5f5c76f1da466f6c805c0585/cfn-response.js +++ /dev/null @@ -1,87 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Retry = exports.safeHandler = exports.includeStackTraces = exports.submitResponse = exports.MISSING_PHYSICAL_ID_MARKER = exports.CREATE_FAILED_PHYSICAL_ID_MARKER = void 0; -/* eslint-disable max-len */ -/* eslint-disable no-console */ -const url = require("url"); -const outbound_1 = require("./outbound"); -const util_1 = require("./util"); -exports.CREATE_FAILED_PHYSICAL_ID_MARKER = 'AWSCDK::CustomResourceProviderFramework::CREATE_FAILED'; -exports.MISSING_PHYSICAL_ID_MARKER = 'AWSCDK::CustomResourceProviderFramework::MISSING_PHYSICAL_ID'; -async function submitResponse(status, event, options = {}) { - const json = { - Status: status, - Reason: options.reason || status, - StackId: event.StackId, - RequestId: event.RequestId, - PhysicalResourceId: event.PhysicalResourceId || exports.MISSING_PHYSICAL_ID_MARKER, - LogicalResourceId: event.LogicalResourceId, - NoEcho: options.noEcho, - Data: event.Data, - }; - util_1.log('submit response to cloudformation', json); - const responseBody = JSON.stringify(json); - const parsedUrl = url.parse(event.ResponseURL); - const retryOptions = { - attempts: 5, - sleep: 1000, - }; - await util_1.withRetries(retryOptions, outbound_1.httpRequest)({ - hostname: parsedUrl.hostname, - path: parsedUrl.path, - method: 'PUT', - headers: { - 'content-type': '', - 'content-length': responseBody.length, - }, - }, responseBody); -} -exports.submitResponse = submitResponse; -exports.includeStackTraces = true; // for unit tests -function safeHandler(block) { - return async (event) => { - // ignore DELETE event when the physical resource ID is the marker that - // indicates that this DELETE is a subsequent DELETE to a failed CREATE - // operation. - if (event.RequestType === 'Delete' && event.PhysicalResourceId === exports.CREATE_FAILED_PHYSICAL_ID_MARKER) { - util_1.log('ignoring DELETE event caused by a failed CREATE event'); - await submitResponse('SUCCESS', event); - return; - } - try { - await block(event); - } - catch (e) { - // tell waiter state machine to retry - if (e instanceof Retry) { - util_1.log('retry requested by handler'); - throw e; - } - if (!event.PhysicalResourceId) { - // special case: if CREATE fails, which usually implies, we usually don't - // have a physical resource id. in this case, the subsequent DELETE - // operation does not have any meaning, and will likely fail as well. to - // address this, we use a marker so the provider framework can simply - // ignore the subsequent DELETE. - if (event.RequestType === 'Create') { - util_1.log('CREATE failed, responding with a marker physical resource id so that the subsequent DELETE will be ignored'); - event.PhysicalResourceId = exports.CREATE_FAILED_PHYSICAL_ID_MARKER; - } - else { - // otherwise, if PhysicalResourceId is not specified, something is - // terribly wrong because all other events should have an ID. - util_1.log(`ERROR: Malformed event. "PhysicalResourceId" is required: ${JSON.stringify({ ...event, ResponseURL: '...' })}`); - } - } - // this is an actual error, fail the activity altogether and exist. - await submitResponse('FAILED', event, { - reason: exports.includeStackTraces ? e.stack : e.message, - }); - } - }; -} -exports.safeHandler = safeHandler; -class Retry extends Error { -} -exports.Retry = Retry; -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2ZuLXJlc3BvbnNlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiY2ZuLXJlc3BvbnNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLDRCQUE0QjtBQUM1QiwrQkFBK0I7QUFDL0IsMkJBQTJCO0FBQzNCLHlDQUF5QztBQUN6QyxpQ0FBMEM7QUFFN0IsUUFBQSxnQ0FBZ0MsR0FBRyx3REFBd0QsQ0FBQztBQUM1RixRQUFBLDBCQUEwQixHQUFHLDhEQUE4RCxDQUFDO0FBZ0JsRyxLQUFLLFVBQVUsY0FBYyxDQUFDLE1BQTRCLEVBQUUsS0FBaUMsRUFBRSxVQUF5QyxFQUFHO0lBQ2hKLE1BQU0sSUFBSSxHQUFtRDtRQUMzRCxNQUFNLEVBQUUsTUFBTTtRQUNkLE1BQU0sRUFBRSxPQUFPLENBQUMsTUFBTSxJQUFJLE1BQU07UUFDaEMsT0FBTyxFQUFFLEtBQUssQ0FBQyxPQUFPO1FBQ3RCLFNBQVMsRUFBRSxLQUFLLENBQUMsU0FBUztRQUMxQixrQkFBa0IsRUFBRSxLQUFLLENBQUMsa0JBQWtCLElBQUksa0NBQTBCO1FBQzFFLGlCQUFpQixFQUFFLEtBQUssQ0FBQyxpQkFBaUI7UUFDMUMsTUFBTSxFQUFFLE9BQU8sQ0FBQyxNQUFNO1FBQ3RCLElBQUksRUFBRSxLQUFLLENBQUMsSUFBSTtLQUNqQixDQUFDO0lBRUYsVUFBRyxDQUFDLG1DQUFtQyxFQUFFLElBQUksQ0FBQyxDQUFDO0lBRS9DLE1BQU0sWUFBWSxHQUFHLElBQUksQ0FBQyxTQUFTLENBQUMsSUFBSSxDQUFDLENBQUM7SU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ZW50cyBzaG91bGQgaGF2ZSBhbiBJRC5cbiAgICAgICAgICBsb2coYEVSUk9SOiBNYWxmb3JtZWQgZXZlbnQuIFwiUGh5c2ljYWxSZXNvdXJjZUlkXCIgaXMgcmVxdWlyZWQ6ICR7SlNPTi5zdHJpbmdpZnkoeyAuLi5ldmVudCwgUmVzcG9uc2VVUkw6ICcuLi4nIH0pfWApO1xuICAgICAgICB9XG4gICAgICB9XG5cbiAgICAgIC8vIHRoaXMgaXMgYW4gYWN0dWFsIGVycm9yLCBmYWlsIHRoZSBhY3Rpdml0eSBhbHRvZ2V0aGVyIGFuZCBleGlzdC5cbiAgICAgIGF3YWl0IHN1Ym1pdFJlc3BvbnNlKCdGQUlMRUQnLCBldmVudCwge1xuICAgICAgICByZWFzb246IGluY2x1ZGVTdGFja1RyYWNlcyA/IGUuc3RhY2sgOiBlLm1lc3NhZ2UsXG4gICAgICB9KTtcbiAgICB9XG4gIH07XG59XG5cbmV4cG9ydCBjbGFzcyBSZXRyeSBleHRlbmRzIEVycm9yIHsgfVxuIl19 \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.a8a62b989c7866e3ad5b24f3eb6228f8ca91ebff5f5c76f1da466f6c805c0585/framework.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.a8a62b989c7866e3ad5b24f3eb6228f8ca91ebff5f5c76f1da466f6c805c0585/framework.js deleted file mode 100644 index 3f8a03e88aae0..0000000000000 --- a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.a8a62b989c7866e3ad5b24f3eb6228f8ca91ebff5f5c76f1da466f6c805c0585/framework.js +++ /dev/null @@ -1,168 +0,0 @@ -"use strict"; -const cfnResponse = require("./cfn-response"); -const consts = require("./consts"); -const outbound_1 = require("./outbound"); -const util_1 = require("./util"); -/** - * The main runtime entrypoint of the async custom resource lambda function. - * - * Any lifecycle event changes to the custom resources will invoke this handler, which will, in turn, - * interact with the user-defined `onEvent` and `isComplete` handlers. - * - * This function will always succeed. If an error occurs - * - * @param cfnRequest The cloudformation custom resource event. - */ -async function onEvent(cfnRequest) { - const sanitizedRequest = { ...cfnRequest, ResponseURL: '...' }; - util_1.log('onEventHandler', sanitizedRequest); - cfnRequest.ResourceProperties = cfnRequest.ResourceProperties || {}; - const onEventResult = await invokeUserFunction(consts.USER_ON_EVENT_FUNCTION_ARN_ENV, sanitizedRequest, cfnRequest.ResponseURL); - util_1.log('onEvent returned:', onEventResult); - // merge the request and the result from onEvent to form the complete resource event - // this also performs validation. - const resourceEvent = createResponseEvent(cfnRequest, onEventResult); - util_1.log('event:', onEventResult); - // determine if this is an async provider based on whether we have an isComplete handler defined. - // if it is not defined, then we are basically ready to return a positive response. - if (!process.env[consts.USER_IS_COMPLETE_FUNCTION_ARN_ENV]) { - return cfnResponse.submitResponse('SUCCESS', resourceEvent, { noEcho: resourceEvent.NoEcho }); - } - // ok, we are not complete, so kick off the waiter workflow - const waiter = { - stateMachineArn: util_1.getEnv(consts.WAITER_STATE_MACHINE_ARN_ENV), - name: resourceEvent.RequestId, - input: JSON.stringify(resourceEvent), - }; - util_1.log('starting waiter', waiter); - // kick off waiter state machine - await outbound_1.startExecution(waiter); -} -// invoked a few times until `complete` is true or until it times out. -async function isComplete(event) { - const sanitizedRequest = { ...event, ResponseURL: '...' }; - util_1.log('isComplete', sanitizedRequest); - const isCompleteResult = await invokeUserFunction(consts.USER_IS_COMPLETE_FUNCTION_ARN_ENV, sanitizedRequest, event.ResponseURL); - util_1.log('user isComplete returned:', isCompleteResult); - // if we are not complete, return false, and don't send a response back. - if (!isCompleteResult.IsComplete) { - if (isCompleteResult.Data && Object.keys(isCompleteResult.Data).length > 0) { - throw new Error('"Data" is not allowed if "IsComplete" is "False"'); - } - // This must be the full event, it will be deserialized in `onTimeout` to send the response to CloudFormation - throw new cfnResponse.Retry(JSON.stringify(event)); - } - const response = { - ...event, - ...isCompleteResult, - Data: { - ...event.Data, - ...isCompleteResult.Data, - }, - }; - await cfnResponse.submitResponse('SUCCESS', response, { noEcho: event.NoEcho }); -} -// invoked when completion retries are exhaused. -async function onTimeout(timeoutEvent) { - util_1.log('timeoutHandler', timeoutEvent); - const isCompleteRequest = JSON.parse(JSON.parse(timeoutEvent.Cause).errorMessage); - await cfnResponse.submitResponse('FAILED', isCompleteRequest, { - reason: 'Operation timed out', - }); -} -async function invokeUserFunction(functionArnEnv, sanitizedPayload, responseUrl) { - const functionArn = util_1.getEnv(functionArnEnv); - util_1.log(`executing user function ${functionArn} with payload`, sanitizedPayload); - // transient errors such as timeouts, throttling errors (429), and other - // errors that aren't caused by a bad request (500 series) are retried - // automatically by the JavaScript SDK. - const resp = await outbound_1.invokeFunction({ - FunctionName: functionArn, - // Cannot strip 'ResponseURL' here as this would be a breaking change even though the downstream CR doesn't need it - Payload: JSON.stringify({ ...sanitizedPayload, ResponseURL: responseUrl }), - }); - util_1.log('user function response:', resp, typeof (resp)); - const jsonPayload = parseJsonPayload(resp.Payload); - if (resp.FunctionError) { - util_1.log('user function threw an error:', resp.FunctionError); - const errorMessage = jsonPayload.errorMessage || 'error'; - // parse function name from arn - // arn:${Partition}:lambda:${Region}:${Account}:function:${FunctionName} - const arn = functionArn.split(':'); - const functionName = arn[arn.length - 1]; - // append a reference to the log group. - const message = [ - errorMessage, - '', - `Logs: /aws/lambda/${functionName}`, - '', - ].join('\n'); - const e = new Error(message); - // the output that goes to CFN is what's in `stack`, not the error message. - // if we have a remote trace, construct a nice message with log group information - if (jsonPayload.trace) { - // skip first trace line because it's the message - e.stack = [message, ...jsonPayload.trace.slice(1)].join('\n'); - } - throw e; - } - return jsonPayload; -} -function parseJsonPayload(payload) { - if (!payload) { - return {}; - } - const text = payload.toString(); - try { - return JSON.parse(text); - } - catch (e) { - throw new Error(`return values from user-handlers must be JSON objects. got: "${text}"`); - } -} -function createResponseEvent(cfnRequest, onEventResult) { - // - // validate that onEventResult always includes a PhysicalResourceId - onEventResult = onEventResult || {}; - // if physical ID is not returned, we have some defaults for you based - // on the request type. - const physicalResourceId = onEventResult.PhysicalResourceId || defaultPhysicalResourceId(cfnRequest); - // if we are in DELETE and physical ID was changed, it's an error. - if (cfnRequest.RequestType === 'Delete' && physicalResourceId !== cfnRequest.PhysicalResourceId) { - throw new Error(`DELETE: cannot change the physical resource ID from "${cfnRequest.PhysicalResourceId}" to "${onEventResult.PhysicalResourceId}" during deletion`); - } - // if we are in UPDATE and physical ID was changed, it's a replacement (just log) - if (cfnRequest.RequestType === 'Update' && physicalResourceId !== cfnRequest.PhysicalResourceId) { - util_1.log(`UPDATE: changing physical resource ID from "${cfnRequest.PhysicalResourceId}" to "${onEventResult.PhysicalResourceId}"`); - } - // merge request event and result event (result prevails). - return { - ...cfnRequest, - ...onEventResult, - PhysicalResourceId: physicalResourceId, - }; -} -/** - * Calculates the default physical resource ID based in case user handler did - * not return a PhysicalResourceId. - * - * For "CREATE", it uses the RequestId. - * For "UPDATE" and "DELETE" and returns the current PhysicalResourceId (the one provided in `event`). - */ -function defaultPhysicalResourceId(req) { - switch (req.RequestType) { - case 'Create': - return req.RequestId; - case 'Update': - case 'Delete': - return req.PhysicalResourceId; - default: - throw new Error(`Invalid "RequestType" in request "${JSON.stringify(req)}"`); - } -} -module.exports = { - [consts.FRAMEWORK_ON_EVENT_HANDLER_NAME]: cfnResponse.safeHandler(onEvent), - [consts.FRAMEWORK_IS_COMPLETE_HANDLER_NAME]: cfnResponse.safeHandler(isComplete), - [consts.FRAMEWORK_ON_TIMEOUT_HANDLER_NAME]: onTimeout, -}; -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZnJhbWV3b3JrLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiZnJhbWV3b3JrLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFHQSw4Q0FBOEM7QUFDOUMsbUNBQW1DO0FBQ25DLHlDQUE0RDtBQUM1RCxpQ0FBcUM7QU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XJuIHJlcS5QaHlzaWNhbFJlc291cmNlSWQ7XG5cbiAgICBkZWZhdWx0OlxuICAgICAgdGhyb3cgbmV3IEVycm9yKGBJbnZhbGlkIFwiUmVxdWVzdFR5cGVcIiBpbiByZXF1ZXN0IFwiJHtKU09OLnN0cmluZ2lmeShyZXEpfVwiYCk7XG4gIH1cbn1cbiJdfQ== \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.a8a62b989c7866e3ad5b24f3eb6228f8ca91ebff5f5c76f1da466f6c805c0585/outbound.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.a8a62b989c7866e3ad5b24f3eb6228f8ca91ebff5f5c76f1da466f6c805c0585/outbound.js deleted file mode 100644 index cc0667d42f0e8..0000000000000 --- a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.a8a62b989c7866e3ad5b24f3eb6228f8ca91ebff5f5c76f1da466f6c805c0585/outbound.js +++ /dev/null @@ -1,69 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.httpRequest = exports.invokeFunction = exports.startExecution = void 0; -/* istanbul ignore file */ -const https = require("https"); -// eslint-disable-next-line import/no-extraneous-dependencies -const AWS = require("aws-sdk"); -const FRAMEWORK_HANDLER_TIMEOUT = 900000; // 15 minutes -// In order to honor the overall maximum timeout set for the target process, -// the default 2 minutes from AWS SDK has to be overriden: -// https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#httpOptions-property -const awsSdkConfig = { - httpOptions: { timeout: FRAMEWORK_HANDLER_TIMEOUT }, -}; -async function defaultHttpRequest(options, responseBody) { - return new Promise((resolve, reject) => { - try { - const request = https.request(options, resolve); - request.on('error', reject); - request.write(responseBody); - request.end(); - } - catch (e) { - reject(e); - } - }); -} -let sfn; -let lambda; -async function defaultStartExecution(req) { - if (!sfn) { - sfn = new AWS.StepFunctions(awsSdkConfig); - } - return sfn.startExecution(req).promise(); -} -async function defaultInvokeFunction(req) { - if (!lambda) { - lambda = new AWS.Lambda(awsSdkConfig); - } - try { - /** - * Try an initial invoke. - * - * When you try to invoke a function that is inactive, the invocation fails and Lambda sets - * the function to pending state until the function resources are recreated. - * If Lambda fails to recreate the resources, the function is set to the inactive state. - * - * We're using invoke first because `waitFor` doesn't trigger an inactive function to do anything, - * it just runs `getFunction` and checks the state. - */ - return await lambda.invoke(req).promise(); - } - catch (error) { - /** - * The status of the Lambda function is checked every second for up to 300 seconds. - * Exits the loop on 'Active' state and throws an error on 'Inactive' or 'Failed'. - * - * And now we wait. - */ - await lambda.waitFor('functionActiveV2', { - FunctionName: req.FunctionName, - }).promise(); - return await lambda.invoke(req).promise(); - } -} -exports.startExecution = defaultStartExecution; -exports.invokeFunction = defaultInvokeFunction; -exports.httpRequest = defaultHttpRequest; -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3V0Ym91bmQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJvdXRib3VuZC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSwwQkFBMEI7QUFDMUIsK0JBQStCO0FBQy9CLDZEQUE2RDtBQUM3RCwrQkFBK0I7QUFJL0IsTUFBTSx5QkFBeUIsR0FBRyxNQUFNLENBQUMsQ0FBQyxhQUFhO0FBRXZELDRFQUE0RTtBQUM1RSwwREFBMEQ7QUFDMUQsMkZBQTJGO0FBQzNGLE1BQU0sWUFBWSxHQUF5QjtJQUN6QyxXQUFXLEVBQUUsRUFBRSxPQUFPLEVBQUUseUJBQXlCLEVBQUU7Q0FDcEQsQ0FBQztBQUVGLEtBQUssVUFBVSxrQkFBa0IsQ0FBQyxPQUE2QixFQUFFLFlBQW9CO0lBQ25GLE9BQU8sSUFBSSxPQUFPLENBQUMsQ0FBQyxPQUFPLEVBQUUsTUFBTSxFQUFFLEVBQUU7UUFDckMsSUFBSTtZQUNGLE1BQU0sT0FBTyx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ICogVGhlIHN0YXR1cyBvZiB0aGUgTGFtYmRhIGZ1bmN0aW9uIGlzIGNoZWNrZWQgZXZlcnkgc2Vjb25kIGZvciB1cCB0byAzMDAgc2Vjb25kcy5cbiAgICAgKiBFeGl0cyB0aGUgbG9vcCBvbiAnQWN0aXZlJyBzdGF0ZSBhbmQgdGhyb3dzIGFuIGVycm9yIG9uICdJbmFjdGl2ZScgb3IgJ0ZhaWxlZCcuXG4gICAgICpcbiAgICAgKiBBbmQgbm93IHdlIHdhaXQuXG4gICAgICovXG4gICAgYXdhaXQgbGFtYmRhLndhaXRGb3IoJ2Z1bmN0aW9uQWN0aXZlVjInLCB7XG4gICAgICBGdW5jdGlvbk5hbWU6IHJlcS5GdW5jdGlvbk5hbWUsXG4gICAgfSkucHJvbWlzZSgpO1xuICAgIHJldHVybiBhd2FpdCBsYW1iZGEuaW52b2tlKHJlcSkucHJvbWlzZSgpO1xuICB9XG59XG5cbmV4cG9ydCBsZXQgc3RhcnRFeGVjdXRpb24gPSBkZWZhdWx0U3RhcnRFeGVjdXRpb247XG5leHBvcnQgbGV0IGludm9rZUZ1bmN0aW9uID0gZGVmYXVsdEludm9rZUZ1bmN0aW9uO1xuZXhwb3J0IGxldCBodHRwUmVxdWVzdCA9IGRlZmF1bHRIdHRwUmVxdWVzdDtcbiJdfQ== \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/aws-cdk-redshift-cluster-database.assets.json b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/aws-cdk-redshift-cluster-database.assets.json index 8f6a58eea9612..02eaab1131605 100644 --- a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/aws-cdk-redshift-cluster-database.assets.json +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/aws-cdk-redshift-cluster-database.assets.json @@ -1,33 +1,33 @@ { "version": "31.0.0", "files": { - "df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a": { + "63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c": { "source": { - "path": "asset.df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a", + "path": "asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c", "packaging": "zip" }, "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a.zip", + "objectKey": "63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c.zip", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } }, - "a8a62b989c7866e3ad5b24f3eb6228f8ca91ebff5f5c76f1da466f6c805c0585": { + "1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746": { "source": { - "path": "asset.a8a62b989c7866e3ad5b24f3eb6228f8ca91ebff5f5c76f1da466f6c805c0585", + "path": "asset.1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746", "packaging": "zip" }, "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "a8a62b989c7866e3ad5b24f3eb6228f8ca91ebff5f5c76f1da466f6c805c0585.zip", + "objectKey": "1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746.zip", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } }, - "f2cf2a437f9007286a4d7bc2cb4d6008231236f7c800e4503142a26d808b75d7": { + "f50f34bacfa31c486d56f3494f8781027db43581eaf9eff8d6919bd5daedb37e": { "source": { "path": "aws-cdk-redshift-cluster-database.template.json", "packaging": "file" @@ -35,11 +35,11 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "f2cf2a437f9007286a4d7bc2cb4d6008231236f7c800e4503142a26d808b75d7.json", + "objectKey": "f50f34bacfa31c486d56f3494f8781027db43581eaf9eff8d6919bd5daedb37e.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } } }, "dockerImages": {} -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/aws-cdk-redshift-cluster-database.template.json b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/aws-cdk-redshift-cluster-database.template.json index 7194252169a65..308fa26ba3727 100644 --- a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/aws-cdk-redshift-cluster-database.template.json +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/aws-cdk-redshift-cluster-database.template.json @@ -715,7 +715,7 @@ "S3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "S3Key": "a8a62b989c7866e3ad5b24f3eb6228f8ca91ebff5f5c76f1da466f6c805c0585.zip" + "S3Key": "1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746.zip" }, "Role": { "Fn::GetAtt": [ @@ -854,7 +854,7 @@ "S3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "S3Key": "a8a62b989c7866e3ad5b24f3eb6228f8ca91ebff5f5c76f1da466f6c805c0585.zip" + "S3Key": "1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746.zip" }, "Role": { "Fn::GetAtt": [ @@ -909,6 +909,7 @@ }, "tablePrivileges": [ { + "tableId": "Table", "tableName": { "Ref": "Table7ABB320E" }, @@ -1004,7 +1005,7 @@ "S3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "S3Key": "1a159599b617b432864ddf9e4e9ec70b884de7656daa51073d4149a3080c5f79.zip" + "S3Key": "63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c.zip" }, "Role": { "Fn::GetAtt": [ @@ -1107,7 +1108,7 @@ "S3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "S3Key": "a8a62b989c7866e3ad5b24f3eb6228f8ca91ebff5f5c76f1da466f6c805c0585.zip" + "S3Key": "1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746.zip" }, "Role": { "Fn::GetAtt": [ diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/manifest.json b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/manifest.json index 19d4c739862c8..b5d8f2a0eafd8 100644 --- a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/manifest.json +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/manifest.json @@ -17,17 +17,21 @@ "validateOnSynth": false, "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/f2cf2a437f9007286a4d7bc2cb4d6008231236f7c800e4503142a26d808b75d7.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/f50f34bacfa31c486d56f3494f8781027db43581eaf9eff8d6919bd5daedb37e.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", - "additionalDependencies": ["aws-cdk-redshift-cluster-database.assets"], + "additionalDependencies": [ + "aws-cdk-redshift-cluster-database.assets" + ], "lookupRole": { "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", "requiresBootstrapStackVersion": 8, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" } }, - "dependencies": ["aws-cdk-redshift-cluster-database.assets"], + "dependencies": [ + "aws-cdk-redshift-cluster-database.assets" + ], "metadata": { "/aws-cdk-redshift-cluster-database/custom-kms-key/Resource": [ { @@ -380,4 +384,4 @@ } } } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/tree.json b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/tree.json index e958cd29d8527..5e4d3e0e682de 100644 --- a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/tree.json +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/tree.json @@ -49,13 +49,13 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-kms.CfnKey", + "fqn": "aws-cdk-lib.aws_kms.CfnKey", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-kms.Key", + "fqn": "aws-cdk-lib.aws_kms.Key", "version": "0.0.0" } }, @@ -82,7 +82,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnVPC", + "fqn": "aws-cdk-lib.aws_ec2.CfnVPC", "version": "0.0.0" } }, @@ -126,7 +126,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnSubnet", + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", "version": "0.0.0" } }, @@ -134,7 +134,7 @@ "id": "Acl", "path": "aws-cdk-redshift-cluster-database/Vpc/PublicSubnet1/Acl", "constructInfo": { - "fqn": "@aws-cdk/core.Resource", + "fqn": "aws-cdk-lib.Resource", "version": "0.0.0" } }, @@ -156,7 +156,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnRouteTable", + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", "version": "0.0.0" } }, @@ -175,7 +175,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnSubnetRouteTableAssociation", + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnetRouteTableAssociation", "version": "0.0.0" } }, @@ -195,7 +195,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnRoute", + "fqn": "aws-cdk-lib.aws_ec2.CfnRoute", "version": "0.0.0" } }, @@ -215,7 +215,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnEIP", + "fqn": "aws-cdk-lib.aws_ec2.CfnEIP", "version": "0.0.0" } }, @@ -243,13 +243,13 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnNatGateway", + "fqn": "aws-cdk-lib.aws_ec2.CfnNatGateway", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.PublicSubnet", + "fqn": "aws-cdk-lib.aws_ec2.PublicSubnet", "version": "0.0.0" } }, @@ -293,7 +293,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnSubnet", + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", "version": "0.0.0" } }, @@ -301,7 +301,7 @@ "id": "Acl", "path": "aws-cdk-redshift-cluster-database/Vpc/PublicSubnet2/Acl", "constructInfo": { - "fqn": "@aws-cdk/core.Resource", + "fqn": "aws-cdk-lib.Resource", "version": "0.0.0" } }, @@ -323,7 +323,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnRouteTable", + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", "version": "0.0.0" } }, @@ -342,7 +342,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnSubnetRouteTableAssociation", + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnetRouteTableAssociation", "version": "0.0.0" } }, @@ -362,7 +362,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnRoute", + "fqn": "aws-cdk-lib.aws_ec2.CfnRoute", "version": "0.0.0" } }, @@ -382,7 +382,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnEIP", + "fqn": "aws-cdk-lib.aws_ec2.CfnEIP", "version": "0.0.0" } }, @@ -410,13 +410,13 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnNatGateway", + "fqn": "aws-cdk-lib.aws_ec2.CfnNatGateway", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.PublicSubnet", + "fqn": "aws-cdk-lib.aws_ec2.PublicSubnet", "version": "0.0.0" } }, @@ -460,7 +460,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnSubnet", + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", "version": "0.0.0" } }, @@ -468,7 +468,7 @@ "id": "Acl", "path": "aws-cdk-redshift-cluster-database/Vpc/PrivateSubnet1/Acl", "constructInfo": { - "fqn": "@aws-cdk/core.Resource", + "fqn": "aws-cdk-lib.Resource", "version": "0.0.0" } }, @@ -490,7 +490,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnRouteTable", + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", "version": "0.0.0" } }, @@ -509,7 +509,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnSubnetRouteTableAssociation", + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnetRouteTableAssociation", "version": "0.0.0" } }, @@ -529,13 +529,13 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnRoute", + "fqn": "aws-cdk-lib.aws_ec2.CfnRoute", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.PrivateSubnet", + "fqn": "aws-cdk-lib.aws_ec2.PrivateSubnet", "version": "0.0.0" } }, @@ -579,7 +579,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnSubnet", + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", "version": "0.0.0" } }, @@ -587,7 +587,7 @@ "id": "Acl", "path": "aws-cdk-redshift-cluster-database/Vpc/PrivateSubnet2/Acl", "constructInfo": { - "fqn": "@aws-cdk/core.Resource", + "fqn": "aws-cdk-lib.Resource", "version": "0.0.0" } }, @@ -609,7 +609,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnRouteTable", + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", "version": "0.0.0" } }, @@ -628,7 +628,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnSubnetRouteTableAssociation", + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnetRouteTableAssociation", "version": "0.0.0" } }, @@ -648,13 +648,13 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnRoute", + "fqn": "aws-cdk-lib.aws_ec2.CfnRoute", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.PrivateSubnet", + "fqn": "aws-cdk-lib.aws_ec2.PrivateSubnet", "version": "0.0.0" } }, @@ -673,7 +673,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnInternetGateway", + "fqn": "aws-cdk-lib.aws_ec2.CfnInternetGateway", "version": "0.0.0" } }, @@ -692,13 +692,13 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnVPCGatewayAttachment", + "fqn": "aws-cdk-lib.aws_ec2.CfnVPCGatewayAttachment", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.Vpc", + "fqn": "aws-cdk-lib.aws_ec2.Vpc", "version": "0.0.0" } }, @@ -728,13 +728,13 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-redshift.CfnClusterSubnetGroup", + "fqn": "aws-cdk-lib.aws_redshift.CfnClusterSubnetGroup", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-redshift.ClusterSubnetGroup", + "fqn": "@aws-cdk/aws-redshift-alpha.ClusterSubnetGroup", "version": "0.0.0" } }, @@ -762,13 +762,13 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.CfnSecurityGroup", + "fqn": "aws-cdk-lib.aws_ec2.CfnSecurityGroup", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-ec2.SecurityGroup", + "fqn": "aws-cdk-lib.aws_ec2.SecurityGroup", "version": "0.0.0" } }, @@ -791,7 +791,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-secretsmanager.CfnSecret", + "fqn": "aws-cdk-lib.aws_secretsmanager.CfnSecret", "version": "0.0.0" } }, @@ -815,19 +815,19 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-secretsmanager.CfnSecretTargetAttachment", + "fqn": "aws-cdk-lib.aws_secretsmanager.CfnSecretTargetAttachment", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-secretsmanager.SecretTargetAttachment", + "fqn": "aws-cdk-lib.aws_secretsmanager.SecretTargetAttachment", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-redshift.DatabaseSecret", + "fqn": "@aws-cdk/aws-redshift-alpha.DatabaseSecret", "version": "0.0.0" } }, @@ -889,7 +889,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-redshift.CfnCluster", + "fqn": "aws-cdk-lib.aws_redshift.CfnCluster", "version": "0.0.0" } }, @@ -914,19 +914,19 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-redshift.CfnClusterParameterGroup", + "fqn": "aws-cdk-lib.aws_redshift.CfnClusterParameterGroup", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-redshift.ClusterParameterGroup", + "fqn": "@aws-cdk/aws-redshift-alpha.ClusterParameterGroup", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-redshift.Cluster", + "fqn": "@aws-cdk/aws-redshift-alpha.Cluster", "version": "0.0.0" } }, @@ -953,7 +953,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-secretsmanager.CfnSecret", + "fqn": "aws-cdk-lib.aws_secretsmanager.CfnSecret", "version": "0.0.0" } }, @@ -977,19 +977,19 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-secretsmanager.CfnSecretTargetAttachment", + "fqn": "aws-cdk-lib.aws_secretsmanager.CfnSecretTargetAttachment", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-secretsmanager.SecretTargetAttachment", + "fqn": "aws-cdk-lib.aws_secretsmanager.SecretTargetAttachment", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-redshift.DatabaseSecret", + "fqn": "@aws-cdk/aws-redshift-alpha.DatabaseSecret", "version": "0.0.0" } }, @@ -1001,7 +1001,7 @@ "id": "Handler", "path": "aws-cdk-redshift-cluster-database/User/Resource/Handler", "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.SingletonFunction", + "fqn": "aws-cdk-lib.aws_lambda.SingletonFunction", "version": "0.0.0" } }, @@ -1021,7 +1021,7 @@ "id": "ImportServiceRole", "path": "aws-cdk-redshift-cluster-database/User/Resource/Provider/framework-onEvent/ServiceRole/ImportServiceRole", "constructInfo": { - "fqn": "@aws-cdk/core.Resource", + "fqn": "aws-cdk-lib.Resource", "version": "0.0.0" } }, @@ -1060,7 +1060,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.CfnRole", + "fqn": "aws-cdk-lib.aws_iam.CfnRole", "version": "0.0.0" } }, @@ -1114,19 +1114,19 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.CfnPolicy", + "fqn": "aws-cdk-lib.aws_iam.CfnPolicy", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.Policy", + "fqn": "aws-cdk-lib.aws_iam.Policy", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.Role", + "fqn": "aws-cdk-lib.aws_iam.Role", "version": "0.0.0" } }, @@ -1138,7 +1138,7 @@ "id": "Stage", "path": "aws-cdk-redshift-cluster-database/User/Resource/Provider/framework-onEvent/Code/Stage", "constructInfo": { - "fqn": "@aws-cdk/core.AssetStaging", + "fqn": "aws-cdk-lib.AssetStaging", "version": "0.0.0" } }, @@ -1146,13 +1146,13 @@ "id": "AssetBucket", "path": "aws-cdk-redshift-cluster-database/User/Resource/Provider/framework-onEvent/Code/AssetBucket", "constructInfo": { - "fqn": "@aws-cdk/aws-s3.BucketBase", + "fqn": "aws-cdk-lib.aws_s3.BucketBase", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-s3-assets.Asset", + "fqn": "aws-cdk-lib.aws_s3_assets.Asset", "version": "0.0.0" } }, @@ -1166,7 +1166,7 @@ "s3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "s3Key": "a8a62b989c7866e3ad5b24f3eb6228f8ca91ebff5f5c76f1da466f6c805c0585.zip" + "s3Key": "1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746.zip" }, "role": { "Fn::GetAtt": [ @@ -1191,19 +1191,19 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.CfnFunction", + "fqn": "aws-cdk-lib.aws_lambda.CfnFunction", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.Function", + "fqn": "aws-cdk-lib.aws_lambda.Function", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/custom-resources.Provider", + "fqn": "aws-cdk-lib.custom_resources.Provider", "version": "0.0.0" } }, @@ -1215,20 +1215,20 @@ "id": "Default", "path": "aws-cdk-redshift-cluster-database/User/Resource/Resource/Default", "constructInfo": { - "fqn": "@aws-cdk/core.CfnResource", + "fqn": "aws-cdk-lib.CfnResource", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/core.CustomResource", + "fqn": "aws-cdk-lib.CustomResource", "version": "0.0.0" } } }, "constructInfo": { "fqn": "constructs.Construct", - "version": "10.1.264" + "version": "10.1.270" } }, "TablePrivileges": { @@ -1243,7 +1243,7 @@ "id": "Handler", "path": "aws-cdk-redshift-cluster-database/User/TablePrivileges/Resource/Handler", "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.SingletonFunction", + "fqn": "aws-cdk-lib.aws_lambda.SingletonFunction", "version": "0.0.0" } }, @@ -1263,7 +1263,7 @@ "id": "ImportServiceRole", "path": "aws-cdk-redshift-cluster-database/User/TablePrivileges/Resource/Provider/framework-onEvent/ServiceRole/ImportServiceRole", "constructInfo": { - "fqn": "@aws-cdk/core.Resource", + "fqn": "aws-cdk-lib.Resource", "version": "0.0.0" } }, @@ -1302,7 +1302,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.CfnRole", + "fqn": "aws-cdk-lib.aws_iam.CfnRole", "version": "0.0.0" } }, @@ -1356,19 +1356,19 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.CfnPolicy", + "fqn": "aws-cdk-lib.aws_iam.CfnPolicy", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.Policy", + "fqn": "aws-cdk-lib.aws_iam.Policy", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.Role", + "fqn": "aws-cdk-lib.aws_iam.Role", "version": "0.0.0" } }, @@ -1380,7 +1380,7 @@ "id": "Stage", "path": "aws-cdk-redshift-cluster-database/User/TablePrivileges/Resource/Provider/framework-onEvent/Code/Stage", "constructInfo": { - "fqn": "@aws-cdk/core.AssetStaging", + "fqn": "aws-cdk-lib.AssetStaging", "version": "0.0.0" } }, @@ -1388,13 +1388,13 @@ "id": "AssetBucket", "path": "aws-cdk-redshift-cluster-database/User/TablePrivileges/Resource/Provider/framework-onEvent/Code/AssetBucket", "constructInfo": { - "fqn": "@aws-cdk/aws-s3.BucketBase", + "fqn": "aws-cdk-lib.aws_s3.BucketBase", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-s3-assets.Asset", + "fqn": "aws-cdk-lib.aws_s3_assets.Asset", "version": "0.0.0" } }, @@ -1408,7 +1408,7 @@ "s3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "s3Key": "a8a62b989c7866e3ad5b24f3eb6228f8ca91ebff5f5c76f1da466f6c805c0585.zip" + "s3Key": "1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746.zip" }, "role": { "Fn::GetAtt": [ @@ -1433,19 +1433,19 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.CfnFunction", + "fqn": "aws-cdk-lib.aws_lambda.CfnFunction", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.Function", + "fqn": "aws-cdk-lib.aws_lambda.Function", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/custom-resources.Provider", + "fqn": "aws-cdk-lib.custom_resources.Provider", "version": "0.0.0" } }, @@ -1457,31 +1457,31 @@ "id": "Default", "path": "aws-cdk-redshift-cluster-database/User/TablePrivileges/Resource/Resource/Default", "constructInfo": { - "fqn": "@aws-cdk/core.CfnResource", + "fqn": "aws-cdk-lib.CfnResource", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/core.CustomResource", + "fqn": "aws-cdk-lib.CustomResource", "version": "0.0.0" } } }, "constructInfo": { "fqn": "constructs.Construct", - "version": "10.1.264" + "version": "10.1.270" } } }, "constructInfo": { "fqn": "constructs.Construct", - "version": "10.1.264" + "version": "10.1.270" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-redshift.User", + "fqn": "@aws-cdk/aws-redshift-alpha.User", "version": "0.0.0" } }, @@ -1497,7 +1497,7 @@ "id": "ImportServiceRole", "path": "aws-cdk-redshift-cluster-database/Query Redshift Database3de5bea727da479686625efb56431b5f/ServiceRole/ImportServiceRole", "constructInfo": { - "fqn": "@aws-cdk/core.Resource", + "fqn": "aws-cdk-lib.Resource", "version": "0.0.0" } }, @@ -1536,7 +1536,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.CfnRole", + "fqn": "aws-cdk-lib.aws_iam.CfnRole", "version": "0.0.0" } }, @@ -1587,19 +1587,19 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.CfnPolicy", + "fqn": "aws-cdk-lib.aws_iam.CfnPolicy", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.Policy", + "fqn": "aws-cdk-lib.aws_iam.Policy", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.Role", + "fqn": "aws-cdk-lib.aws_iam.Role", "version": "0.0.0" } }, @@ -1611,7 +1611,7 @@ "id": "Stage", "path": "aws-cdk-redshift-cluster-database/Query Redshift Database3de5bea727da479686625efb56431b5f/Code/Stage", "constructInfo": { - "fqn": "@aws-cdk/core.AssetStaging", + "fqn": "aws-cdk-lib.AssetStaging", "version": "0.0.0" } }, @@ -1619,13 +1619,13 @@ "id": "AssetBucket", "path": "aws-cdk-redshift-cluster-database/Query Redshift Database3de5bea727da479686625efb56431b5f/Code/AssetBucket", "constructInfo": { - "fqn": "@aws-cdk/aws-s3.BucketBase", + "fqn": "aws-cdk-lib.aws_s3.BucketBase", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-s3-assets.Asset", + "fqn": "aws-cdk-lib.aws_s3_assets.Asset", "version": "0.0.0" } }, @@ -1639,7 +1639,7 @@ "s3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "s3Key": "df6288031bcf4a15dbf0c0b582cce6153baa072c75c5e80b3d825e22a3bf104a.zip" + "s3Key": "63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c.zip" }, "role": { "Fn::GetAtt": [ @@ -1653,13 +1653,13 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.CfnFunction", + "fqn": "aws-cdk-lib.aws_lambda.CfnFunction", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.Function", + "fqn": "aws-cdk-lib.aws_lambda.Function", "version": "0.0.0" } }, @@ -1675,7 +1675,7 @@ "id": "Handler", "path": "aws-cdk-redshift-cluster-database/Table/Resource/Handler", "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.SingletonFunction", + "fqn": "aws-cdk-lib.aws_lambda.SingletonFunction", "version": "0.0.0" } }, @@ -1695,7 +1695,7 @@ "id": "ImportServiceRole", "path": "aws-cdk-redshift-cluster-database/Table/Resource/Provider/framework-onEvent/ServiceRole/ImportServiceRole", "constructInfo": { - "fqn": "@aws-cdk/core.Resource", + "fqn": "aws-cdk-lib.Resource", "version": "0.0.0" } }, @@ -1734,7 +1734,7 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.CfnRole", + "fqn": "aws-cdk-lib.aws_iam.CfnRole", "version": "0.0.0" } }, @@ -1788,19 +1788,19 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.CfnPolicy", + "fqn": "aws-cdk-lib.aws_iam.CfnPolicy", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.Policy", + "fqn": "aws-cdk-lib.aws_iam.Policy", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-iam.Role", + "fqn": "aws-cdk-lib.aws_iam.Role", "version": "0.0.0" } }, @@ -1812,7 +1812,7 @@ "id": "Stage", "path": "aws-cdk-redshift-cluster-database/Table/Resource/Provider/framework-onEvent/Code/Stage", "constructInfo": { - "fqn": "@aws-cdk/core.AssetStaging", + "fqn": "aws-cdk-lib.AssetStaging", "version": "0.0.0" } }, @@ -1820,13 +1820,13 @@ "id": "AssetBucket", "path": "aws-cdk-redshift-cluster-database/Table/Resource/Provider/framework-onEvent/Code/AssetBucket", "constructInfo": { - "fqn": "@aws-cdk/aws-s3.BucketBase", + "fqn": "aws-cdk-lib.aws_s3.BucketBase", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-s3-assets.Asset", + "fqn": "aws-cdk-lib.aws_s3_assets.Asset", "version": "0.0.0" } }, @@ -1840,7 +1840,7 @@ "s3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "s3Key": "a8a62b989c7866e3ad5b24f3eb6228f8ca91ebff5f5c76f1da466f6c805c0585.zip" + "s3Key": "1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746.zip" }, "role": { "Fn::GetAtt": [ @@ -1865,19 +1865,19 @@ } }, "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.CfnFunction", + "fqn": "aws-cdk-lib.aws_lambda.CfnFunction", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-lambda.Function", + "fqn": "aws-cdk-lib.aws_lambda.Function", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/custom-resources.Provider", + "fqn": "aws-cdk-lib.custom_resources.Provider", "version": "0.0.0" } }, @@ -1889,25 +1889,25 @@ "id": "Default", "path": "aws-cdk-redshift-cluster-database/Table/Resource/Resource/Default", "constructInfo": { - "fqn": "@aws-cdk/core.CfnResource", + "fqn": "aws-cdk-lib.CfnResource", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/core.CustomResource", + "fqn": "aws-cdk-lib.CustomResource", "version": "0.0.0" } } }, "constructInfo": { "fqn": "constructs.Construct", - "version": "10.1.264" + "version": "10.1.270" } } }, "constructInfo": { - "fqn": "@aws-cdk/aws-redshift.Table", + "fqn": "@aws-cdk/aws-redshift-alpha.Table", "version": "0.0.0" } }, @@ -1915,7 +1915,7 @@ "id": "BootstrapVersion", "path": "aws-cdk-redshift-cluster-database/BootstrapVersion", "constructInfo": { - "fqn": "@aws-cdk/core.CfnParameter", + "fqn": "aws-cdk-lib.CfnParameter", "version": "0.0.0" } }, @@ -1923,13 +1923,13 @@ "id": "CheckBootstrapVersion", "path": "aws-cdk-redshift-cluster-database/CheckBootstrapVersion", "constructInfo": { - "fqn": "@aws-cdk/core.CfnRule", + "fqn": "aws-cdk-lib.CfnRule", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/core.Stack", + "fqn": "aws-cdk-lib.Stack", "version": "0.0.0" } }, @@ -1946,7 +1946,7 @@ "path": "redshift-cluster-database-integ/DefaultTest/Default", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.1.264" + "version": "10.1.270" } }, "DeployAssert": { @@ -1957,7 +1957,7 @@ "id": "BootstrapVersion", "path": "redshift-cluster-database-integ/DefaultTest/DeployAssert/BootstrapVersion", "constructInfo": { - "fqn": "@aws-cdk/core.CfnParameter", + "fqn": "aws-cdk-lib.CfnParameter", "version": "0.0.0" } }, @@ -1965,25 +1965,25 @@ "id": "CheckBootstrapVersion", "path": "redshift-cluster-database-integ/DefaultTest/DeployAssert/CheckBootstrapVersion", "constructInfo": { - "fqn": "@aws-cdk/core.CfnRule", + "fqn": "aws-cdk-lib.CfnRule", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/core.Stack", + "fqn": "aws-cdk-lib.Stack", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/integ-tests.IntegTestCase", + "fqn": "@aws-cdk/integ-tests-alpha.IntegTestCase", "version": "0.0.0" } } }, "constructInfo": { - "fqn": "@aws-cdk/integ-tests.IntegTest", + "fqn": "@aws-cdk/integ-tests-alpha.IntegTest", "version": "0.0.0" } }, @@ -1992,13 +1992,13 @@ "path": "Tree", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.1.264" + "version": "10.1.270" } } }, "constructInfo": { - "fqn": "@aws-cdk/core.App", + "fqn": "aws-cdk-lib.App", "version": "0.0.0" } } -} +} \ No newline at end of file From ff98842088d09a1b1bed02e3430cd2a7a4f37cac Mon Sep 17 00:00:00 2001 From: Rizbir Khan Date: Wed, 26 Apr 2023 10:19:03 +0000 Subject: [PATCH 06/21] post merge --- .../aws-ecs-patterns/test/ec2/scheduled-ecs-task.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-ecs-patterns/test/ec2/scheduled-ecs-task.test.ts b/packages/aws-cdk-lib/aws-ecs-patterns/test/ec2/scheduled-ecs-task.test.ts index 56baf1a4d46b0..04f939a8696f5 100644 --- a/packages/aws-cdk-lib/aws-ecs-patterns/test/ec2/scheduled-ecs-task.test.ts +++ b/packages/aws-cdk-lib/aws-ecs-patterns/test/ec2/scheduled-ecs-task.test.ts @@ -432,7 +432,7 @@ test('Scheduled Ec2 Task - with list of tags', () => { autoScalingGroup: new AutoScalingGroup(stack, 'DefaultAutoScalingGroup', { vpc, instanceType: new ec2.InstanceType('t2.micro'), - machineImage: MachineImage.latestAmazonLinux2023(), + machineImage: MachineImage.latestAmazonLinux(), }), })); From 3f16d3502bacb05a0bfd3f2863cd39940d52a9e0 Mon Sep 17 00:00:00 2001 From: Rizbir Khan Date: Wed, 26 Apr 2023 15:01:20 +0000 Subject: [PATCH 07/21] issue was name of file --- ...hine-image.ts => generic-machine-image.ts} | 0 .../aws-ec2/lib/machine-image/index.ts | 7 ++-- .../aws-ec2/test/machine-image.test.ts | 36 ++++++++++--------- 3 files changed, 24 insertions(+), 19 deletions(-) rename packages/aws-cdk-lib/aws-ec2/lib/machine-image/{machine-image.ts => generic-machine-image.ts} (100%) diff --git a/packages/aws-cdk-lib/aws-ec2/lib/machine-image/machine-image.ts b/packages/aws-cdk-lib/aws-ec2/lib/machine-image/generic-machine-image.ts similarity index 100% rename from packages/aws-cdk-lib/aws-ec2/lib/machine-image/machine-image.ts rename to packages/aws-cdk-lib/aws-ec2/lib/machine-image/generic-machine-image.ts diff --git a/packages/aws-cdk-lib/aws-ec2/lib/machine-image/index.ts b/packages/aws-cdk-lib/aws-ec2/lib/machine-image/index.ts index ad5829128310e..8d083bcee3978 100644 --- a/packages/aws-cdk-lib/aws-ec2/lib/machine-image/index.ts +++ b/packages/aws-cdk-lib/aws-ec2/lib/machine-image/index.ts @@ -1,5 +1,6 @@ -export * from './common'; -export * from './amazon-linux2'; -export * from './machine-image'; export * from './amazon-linux-2022'; export * from './amazon-linux-2023'; +export * from './amazon-linux2'; +export * from './common'; +export * from './generic-machine-image'; + diff --git a/packages/aws-cdk-lib/aws-ec2/test/machine-image.test.ts b/packages/aws-cdk-lib/aws-ec2/test/machine-image.test.ts index f73b481525a76..3375f1736f9be 100644 --- a/packages/aws-cdk-lib/aws-ec2/test/machine-image.test.ts +++ b/packages/aws-cdk-lib/aws-ec2/test/machine-image.test.ts @@ -272,9 +272,7 @@ test('cached lookups of Amazon Linux 2022 with kernel 5.x', () => { describe('latest amazon linux', () => { test('latestAmazonLinux2', () => { // WHEN - ec2.MachineImage.latestAmazonLinux({ - generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2, - }).getImage(stack); + ec2.MachineImage.latestAmazonLinux2().getImage(stack); // THEN Template.fromStack(stack).hasParameter('*', { @@ -285,9 +283,13 @@ describe('latest amazon linux', () => { test('AmazonLinux2ImageSsmParameter', () => { // WHEN - const ami = ec2.AmazonLinuxImage.ssmParameterName({ - generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2, - }); + const ami = new ec2.AmazonLinux2ImageSsmParameter({ + cpuType: ec2.AmazonLinuxCpuType.ARM_64, + edition: ec2.AmazonLinuxEdition.MINIMAL, + virtualization: ec2.AmazonLinuxVirt.PV, + storage: ec2.AmazonLinuxStorage.EBS, + kernel: ec2.AmazonLinux2Kernel.DEFAULT, + }).getImage(stack).imageId; // THEN expect(ami).toEqual('dummy-value-for-/aws/service/ami-amazon-linux-latest/amzn2-ami-minimal-pv-arm64-ebs'); @@ -307,9 +309,7 @@ describe('latest amazon linux', () => { test('latestAmazonLinux2022', () => { // WHEN - ec2.MachineImage.latestAmazonLinux({ - generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2022, - }).getImage(stack); + ec2.MachineImage.latestAmazonLinux2022().getImage(stack); // THEN Template.fromStack(stack).hasParameter('*', { @@ -320,9 +320,11 @@ describe('latest amazon linux', () => { test('AmazonLinux2022ImageSsmParameter', () => { // WHEN - const ami = ec2.AmazonLinuxImage.ssmParameterName({ - generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2022, - }); + const ami = new ec2.AmazonLinux2022ImageSsmParameter({ + cpuType: ec2.AmazonLinuxCpuType.ARM_64, + edition: ec2.AmazonLinuxEdition.MINIMAL, + kernel: ec2.AmazonLinux2022Kernel.DEFAULT, + }).getImage(stack).imageId; // THEN expect(ami).toEqual('dummy-value-for-/aws/service/ami-amazon-linux-latest/al2022-ami-minimal-kernel-default-arm64'); @@ -342,7 +344,7 @@ describe('latest amazon linux', () => { test('latestAmazonLinux2023', () => { // WHEN - ec2.MachineImage.latestAmazonLinux().getImage(stack); + ec2.MachineImage.latestAmazonLinux2023().getImage(stack); // THEN Template.fromStack(stack).hasParameter('*', { @@ -353,9 +355,11 @@ describe('latest amazon linux', () => { test('AmazonLinux2023ImageSsmParameter', () => { // WHEN - const ami = ec2.AmazonLinuxImage.ssmParameterName({ - generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX, - }); + const ami = new ec2.AmazonLinux2023ImageSsmParameter({ + cpuType: ec2.AmazonLinuxCpuType.ARM_64, + edition: ec2.AmazonLinuxEdition.MINIMAL, + kernel: ec2.AmazonLinux2023Kernel.DEFAULT, + }).getImage(stack).imageId; // THEN expect(ami).toEqual('dummy-value-for-/aws/service/ami-amazon-linux-latest/al2023-ami-minimal-kernel-default-arm64'); From e81d828e5dc1cece4be39a8ac54b4ea29d3e86e4 Mon Sep 17 00:00:00 2001 From: Rizbir Khan Date: Wed, 26 Apr 2023 15:04:10 +0000 Subject: [PATCH 08/21] revert --- .../aws-ecs-patterns/test/ec2/scheduled-ecs-task.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-ecs-patterns/test/ec2/scheduled-ecs-task.test.ts b/packages/aws-cdk-lib/aws-ecs-patterns/test/ec2/scheduled-ecs-task.test.ts index 04f939a8696f5..56baf1a4d46b0 100644 --- a/packages/aws-cdk-lib/aws-ecs-patterns/test/ec2/scheduled-ecs-task.test.ts +++ b/packages/aws-cdk-lib/aws-ecs-patterns/test/ec2/scheduled-ecs-task.test.ts @@ -432,7 +432,7 @@ test('Scheduled Ec2 Task - with list of tags', () => { autoScalingGroup: new AutoScalingGroup(stack, 'DefaultAutoScalingGroup', { vpc, instanceType: new ec2.InstanceType('t2.micro'), - machineImage: MachineImage.latestAmazonLinux(), + machineImage: MachineImage.latestAmazonLinux2023(), }), })); From a783f38103149daf5c016302df57a358a2143d10 Mon Sep 17 00:00:00 2001 From: Rizbir Khan Date: Fri, 28 Jul 2023 16:13:29 +0000 Subject: [PATCH 09/21] removing unecessary table id, used node.id instead --- .../lib/private/privileges.ts | 104 ------------------ .../@aws-cdk/aws-redshift-alpha/lib/table.ts | 7 -- 2 files changed, 111 deletions(-) delete mode 100644 packages/@aws-cdk/aws-redshift-alpha/lib/private/privileges.ts diff --git a/packages/@aws-cdk/aws-redshift-alpha/lib/private/privileges.ts b/packages/@aws-cdk/aws-redshift-alpha/lib/private/privileges.ts deleted file mode 100644 index 54376d467b0a4..0000000000000 --- a/packages/@aws-cdk/aws-redshift-alpha/lib/private/privileges.ts +++ /dev/null @@ -1,104 +0,0 @@ -import * as cdk from 'aws-cdk-lib/core'; -import { Construct } from 'constructs'; -import { DatabaseQuery } from './database-query'; -import { HandlerName } from './database-query-provider/handler-name'; -import { TablePrivilege as SerializedTablePrivilege, UserTablePrivilegesHandlerProps } from './handler-props'; -import { DatabaseOptions } from '../database-options'; -import { ITable, TableAction } from '../table'; -import { IUser } from '../user'; - -/** - * The Redshift table and action that make up a privilege that can be granted to a Redshift user. - */ -export interface TablePrivilege { - /** - * The table on which privileges will be granted. - */ - readonly table: ITable; - - /** - * The actions that will be granted. - */ - readonly actions: TableAction[]; -} - -/** - * Properties for specifying privileges granted to a Redshift user on Redshift tables. - */ -export interface UserTablePrivilegesProps extends DatabaseOptions { - /** - * The user to which privileges will be granted. - */ - readonly user: IUser; - - /** - * The privileges to be granted. - * - * @default [] - use `addPrivileges` to grant privileges after construction - */ - readonly privileges?: TablePrivilege[]; -} - -/** - * Privileges granted to a Redshift user on Redshift tables. - * - * This construct is located in the `private` directory to ensure that it is not exported for direct public use. This - * means that user privileges must be managed through the `Table.grant` method or the `User.addTablePrivileges` - * method. Thus, each `User` will have at most one `UserTablePrivileges` construct to manage its privileges. For details - * on why this is a Good Thing, see the README, under "Granting Privileges". - */ -export class UserTablePrivileges extends Construct { - private privileges: TablePrivilege[]; - - constructor(scope: Construct, id: string, props: UserTablePrivilegesProps) { - super(scope, id); - - this.privileges = props.privileges ?? []; - - new DatabaseQuery(this, 'Resource', { - ...props, - handler: HandlerName.UserTablePrivileges, - properties: { - username: props.user.username, - tablePrivileges: cdk.Lazy.any({ - produce: () => { - const reducedPrivileges = this.privileges.reduce((privileges, { table, actions }) => { - const tableId = table.id; - if (!(tableId in privileges)) { - privileges[tableId] = { - tableName: table.tableName, - actions: [], - }; - } - actions = actions.concat(privileges[tableId].actions); - if (actions.includes(TableAction.ALL)) { - actions = [TableAction.ALL]; - } - if (actions.includes(TableAction.UPDATE) || actions.includes(TableAction.DELETE)) { - actions.push(TableAction.SELECT); - } - privileges[tableId] = { - tableName: table.tableName, - actions: Array.from(new Set(actions)), - }; - return privileges; - }, {} as { [key: string]: { tableName: string, actions: TableAction[] } }); - const serializedPrivileges: SerializedTablePrivilege[] = Object.entries(reducedPrivileges).map(([tableId, config]) => ({ - tableId, - tableName: config.tableName, - actions: config.actions.map(action => TableAction[action]), - })); - return serializedPrivileges; - }, - }) as any, - }, - }); - } - - /** - * Grant this user additional privileges. - */ - addPrivileges(table: ITable, ...actions: TableAction[]): void { - this.privileges.push({ table, actions }); - } -} diff --git a/packages/@aws-cdk/aws-redshift-alpha/lib/table.ts b/packages/@aws-cdk/aws-redshift-alpha/lib/table.ts index a93620f3a22c4..0ccd5736b3f3b 100644 --- a/packages/@aws-cdk/aws-redshift-alpha/lib/table.ts +++ b/packages/@aws-cdk/aws-redshift-alpha/lib/table.ts @@ -155,11 +155,6 @@ export interface TableProps extends DatabaseOptions { * Represents a table in a Redshift database. */ export interface ITable extends IConstruct { - /** - * Idenfifier of the table construct. - */ - readonly id: string; - /** * Name of the table. */ @@ -216,7 +211,6 @@ abstract class TableBase extends Construct implements ITable { abstract readonly tableColumns: Column[]; abstract readonly cluster: ICluster; abstract readonly databaseName: string; - abstract readonly id: string; grant(user: IUser, ...actions: TableAction[]) { user.addTablePrivileges(this, ...actions); } @@ -235,7 +229,6 @@ export class Table extends TableBase { readonly tableColumns = attrs.tableColumns; readonly cluster = attrs.cluster; readonly databaseName = attrs.databaseName; - readonly id = id; }(scope, id); } From 97d24674609e40e3a4d7864983ff905049732efd Mon Sep 17 00:00:00 2001 From: Rizbir Khan Date: Mon, 31 Jul 2023 10:52:24 +0000 Subject: [PATCH 10/21] adding back in privileges.ts --- .../lib/private/privileges.ts | 104 ++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 packages/@aws-cdk/aws-redshift-alpha/lib/private/privileges.ts diff --git a/packages/@aws-cdk/aws-redshift-alpha/lib/private/privileges.ts b/packages/@aws-cdk/aws-redshift-alpha/lib/private/privileges.ts new file mode 100644 index 0000000000000..33e60ba6eaeae --- /dev/null +++ b/packages/@aws-cdk/aws-redshift-alpha/lib/private/privileges.ts @@ -0,0 +1,104 @@ +import * as cdk from 'aws-cdk-lib'; +import { Construct } from 'constructs'; +import { DatabaseOptions } from '../database-options'; +import { ITable, TableAction } from '../table'; +import { IUser } from '../user'; +import { DatabaseQuery } from './database-query'; +import { HandlerName } from './database-query-provider/handler-name'; +import { TablePrivilege as SerializedTablePrivilege, UserTablePrivilegesHandlerProps } from './handler-props'; + +/** + * The Redshift table and action that make up a privilege that can be granted to a Redshift user. + */ +export interface TablePrivilege { + /** + * The table on which privileges will be granted. + */ + readonly table: ITable; + + /** + * The actions that will be granted. + */ + readonly actions: TableAction[]; +} + +/** + * Properties for specifying privileges granted to a Redshift user on Redshift tables. + */ +export interface UserTablePrivilegesProps extends DatabaseOptions { + /** + * The user to which privileges will be granted. + */ + readonly user: IUser; + + /** + * The privileges to be granted. + * + * @default [] - use `addPrivileges` to grant privileges after construction + */ + readonly privileges?: TablePrivilege[]; +} + +/** + * Privileges granted to a Redshift user on Redshift tables. + * + * This construct is located in the `private` directory to ensure that it is not exported for direct public use. This + * means that user privileges must be managed through the `Table.grant` method or the `User.addTablePrivileges` + * method. Thus, each `User` will have at most one `UserTablePrivileges` construct to manage its privileges. For details + * on why this is a Good Thing, see the README, under "Granting Privileges". + */ +export class UserTablePrivileges extends Construct { + private privileges: TablePrivilege[]; + + constructor(scope: Construct, id: string, props: UserTablePrivilegesProps) { + super(scope, id); + + this.privileges = props.privileges ?? []; + + new DatabaseQuery(this, 'Resource', { + ...props, + handler: HandlerName.UserTablePrivileges, + properties: { + username: props.user.username, + tablePrivileges: cdk.Lazy.any({ + produce: () => { + const reducedPrivileges = this.privileges.reduce((privileges, { table, actions }) => { + const tableId = table.node.id; + if (!(tableId in privileges)) { + privileges[tableId] = { + tableName: table.tableName, + actions: [], + }; + } + actions = actions.concat(privileges[tableId].actions); + if (actions.includes(TableAction.ALL)) { + actions = [TableAction.ALL]; + } + if (actions.includes(TableAction.UPDATE) || actions.includes(TableAction.DELETE)) { + actions.push(TableAction.SELECT); + } + privileges[tableId] = { + tableName: table.tableName, + actions: Array.from(new Set(actions)), + }; + return privileges; + }, {} as { [key: string]: { tableName: string, actions: TableAction[] } }); + const serializedPrivileges: SerializedTablePrivilege[] = Object.entries(reducedPrivileges).map(([tableId, config]) => ({ + tableId, + tableName: config.tableName, + actions: config.actions.map(action => TableAction[action]), + })); + return serializedPrivileges; + }, + }) as any, + }, + }); + } + + /** + * Grant this user additional privileges. + */ + addPrivileges(table: ITable, ...actions: TableAction[]): void { + this.privileges.push({ table, actions }); + } +} \ No newline at end of file From 8986bb8b289c2b63ba91654202ec113b2ff847a6 Mon Sep 17 00:00:00 2001 From: Rizbir Khan Date: Mon, 31 Jul 2023 11:06:51 +0000 Subject: [PATCH 11/21] reversing unecessary changes --- .../@aws-cdk/aws-redshift-alpha/lib/private/privileges.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/@aws-cdk/aws-redshift-alpha/lib/private/privileges.ts b/packages/@aws-cdk/aws-redshift-alpha/lib/private/privileges.ts index 33e60ba6eaeae..32b5c05fa224d 100644 --- a/packages/@aws-cdk/aws-redshift-alpha/lib/private/privileges.ts +++ b/packages/@aws-cdk/aws-redshift-alpha/lib/private/privileges.ts @@ -1,4 +1,4 @@ -import * as cdk from 'aws-cdk-lib'; +import * as cdk from 'aws-cdk-lib/core'; import { Construct } from 'constructs'; import { DatabaseOptions } from '../database-options'; import { ITable, TableAction } from '../table'; @@ -101,4 +101,4 @@ export class UserTablePrivileges extends Construct { addPrivileges(table: ITable, ...actions: TableAction[]): void { this.privileges.push({ table, actions }); } -} \ No newline at end of file +} From f4fcb15dcb6b2f9df457be520174fe743946c242 Mon Sep 17 00:00:00 2001 From: Rizbir Khan Date: Mon, 31 Jul 2023 11:52:41 +0000 Subject: [PATCH 12/21] removing id --- packages/@aws-cdk/aws-redshift-alpha/lib/table.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/@aws-cdk/aws-redshift-alpha/lib/table.ts b/packages/@aws-cdk/aws-redshift-alpha/lib/table.ts index 0ccd5736b3f3b..1e432936ef4e3 100644 --- a/packages/@aws-cdk/aws-redshift-alpha/lib/table.ts +++ b/packages/@aws-cdk/aws-redshift-alpha/lib/table.ts @@ -236,7 +236,6 @@ export class Table extends TableBase { readonly tableColumns: Column[]; readonly cluster: ICluster; readonly databaseName: string; - readonly id: string; private resource: DatabaseQuery; @@ -254,7 +253,6 @@ export class Table extends TableBase { this.tableColumns = this.configureTableColumns(props.tableColumns); this.cluster = props.cluster; this.databaseName = props.databaseName; - this.id = id; const useColumnIds = !!cdk.FeatureFlags.of(this).isEnabled(REDSHIFT_COLUMN_ID); From d9283efa9a25cac5ef218f168c774b651ca8c60c Mon Sep 17 00:00:00 2001 From: Rizbir Khan Date: Mon, 31 Jul 2023 11:52:53 +0000 Subject: [PATCH 13/21] integ test --- .../privileges.js | 58 ------ .../types.js | 24 --- .../cfn-response.js | 87 --------- .../consts.js | 10 - .../framework.js | 170 ----------------- .../outbound.js | 69 ------- .../util.js | 39 ---- .../handler-name.js | 10 - .../index.js | 21 --- .../redshift-data.js | 37 ---- .../table.js | 171 ------------------ .../types.js | 24 --- .../user.js | 70 ------- .../util.js | 34 ---- .../handler-name.js | 4 +- .../index.js | 0 .../privileges.js | 0 .../redshift-data.js | 0 .../table.js | 0 .../types.js | 24 +++ .../user.js | 0 .../util.js | 0 ...-cdk-redshift-cluster-database.assets.json | 14 +- ...dk-redshift-cluster-database.template.json | 2 +- .../test/integ.database.js.snapshot/cdk.out | 2 +- .../integ.database.js.snapshot/integ.json | 2 +- .../integ.database.js.snapshot/manifest.json | 4 +- ...efaultTestDeployAssert4339FB48.assets.json | 2 +- .../test/integ.database.js.snapshot/tree.json | 14 +- 29 files changed, 46 insertions(+), 846 deletions(-) delete mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.135d36da5a9e712a2792be4734f4cf4b34b551d49646eef9dec0c185fc869c12/privileges.js delete mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.135d36da5a9e712a2792be4734f4cf4b34b551d49646eef9dec0c185fc869c12/types.js delete mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746/cfn-response.js delete mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746/consts.js delete mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746/framework.js delete mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746/outbound.js delete mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746/util.js delete mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/handler-name.js delete mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/index.js delete mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/redshift-data.js delete mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/table.js delete mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/types.js delete mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/user.js delete mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/util.js rename packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/{asset.135d36da5a9e712a2792be4734f4cf4b34b551d49646eef9dec0c185fc869c12 => asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322}/handler-name.js (66%) rename packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/{asset.135d36da5a9e712a2792be4734f4cf4b34b551d49646eef9dec0c185fc869c12 => asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322}/index.js (100%) rename packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/{asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c => asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322}/privileges.js (100%) rename packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/{asset.135d36da5a9e712a2792be4734f4cf4b34b551d49646eef9dec0c185fc869c12 => asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322}/redshift-data.js (100%) rename packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/{asset.135d36da5a9e712a2792be4734f4cf4b34b551d49646eef9dec0c185fc869c12 => asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322}/table.js (100%) create mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322/types.js rename packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/{asset.135d36da5a9e712a2792be4734f4cf4b34b551d49646eef9dec0c185fc869c12 => asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322}/user.js (100%) rename packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/{asset.135d36da5a9e712a2792be4734f4cf4b34b551d49646eef9dec0c185fc869c12 => asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322}/util.js (100%) diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.135d36da5a9e712a2792be4734f4cf4b34b551d49646eef9dec0c185fc869c12/privileges.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.135d36da5a9e712a2792be4734f4cf4b34b551d49646eef9dec0c185fc869c12/privileges.js deleted file mode 100644 index 933b0fa5ac57a..0000000000000 --- a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.135d36da5a9e712a2792be4734f4cf4b34b551d49646eef9dec0c185fc869c12/privileges.js +++ /dev/null @@ -1,58 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.handler = void 0; -const redshift_data_1 = require("./redshift-data"); -const util_1 = require("./util"); -async function handler(props, event) { - const username = props.username; - const tablePrivileges = props.tablePrivileges; - const clusterProps = props; - if (event.RequestType === 'Create') { - await grantPrivileges(username, tablePrivileges, clusterProps); - return { PhysicalResourceId: (0, util_1.makePhysicalId)(username, clusterProps, event.RequestId) }; - } - else if (event.RequestType === 'Delete') { - await revokePrivileges(username, tablePrivileges, clusterProps); - return; - } - else if (event.RequestType === 'Update') { - const { replace } = await updatePrivileges(username, tablePrivileges, clusterProps, event.OldResourceProperties); - const physicalId = replace ? (0, util_1.makePhysicalId)(username, clusterProps, event.RequestId) : event.PhysicalResourceId; - return { PhysicalResourceId: physicalId }; - } - else { - /* eslint-disable-next-line dot-notation */ - throw new Error(`Unrecognized event type: ${event['RequestType']}`); - } -} -exports.handler = handler; -async function revokePrivileges(username, tablePrivileges, clusterProps) { - await Promise.all(tablePrivileges.map(({ tableName, actions }) => { - return (0, redshift_data_1.executeStatement)(`REVOKE ${actions.join(', ')} ON ${tableName} FROM ${username}`, clusterProps); - })); -} -async function grantPrivileges(username, tablePrivileges, clusterProps) { - await Promise.all(tablePrivileges.map(({ tableName, actions }) => { - return (0, redshift_data_1.executeStatement)(`GRANT ${actions.join(', ')} ON ${tableName} TO ${username}`, clusterProps); - })); -} -async function updatePrivileges(username, tablePrivileges, clusterProps, oldResourceProperties) { - const oldClusterProps = oldResourceProperties; - if (clusterProps.clusterName !== oldClusterProps.clusterName || clusterProps.databaseName !== oldClusterProps.databaseName) { - await grantPrivileges(username, tablePrivileges, clusterProps); - return { replace: true }; - } - const oldUsername = oldResourceProperties.username; - if (oldUsername !== username) { - await grantPrivileges(username, tablePrivileges, clusterProps); - return { replace: true }; - } - const oldTablePrivileges = oldResourceProperties.tablePrivileges; - if (oldTablePrivileges !== tablePrivileges) { - await revokePrivileges(username, oldTablePrivileges, clusterProps); - await grantPrivileges(username, tablePrivileges, clusterProps); - return { replace: false }; - } - return { replace: false }; -} -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJpdmlsZWdlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInByaXZpbGVnZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBRUEsbURBQW1EO0FBRW5ELGlDQUF3QztBQUdqQyxLQUFLLFVBQVUsT0FBTyxDQUFDLEtBQXFELEVBQUUsS0FBa0Q7SUFDckksTUFBTSxRQUFRLEdBQUcsS0FBSyxDQUFDLFFBQVEsQ0FBQztJQUNoQyxNQUFNLGVBQWUsR0FBRyxLQUFLLENBQUMsZUFBZSxDQUFDO0lBQzlDLE1BQU0sWUFBWSxHQUFHLEtBQUssQ0FBQztJQUUzQixJQUFJLEtBQUssQ0FBQyxXQUFXLEtBQUssUUFBUSxFQUFFO1FBQ2xDLE1BQU0sZUFBZSxDQUFDLFFBQVEsRUFBRSxlQUFlLEVBQUUsWUFBWSxDQUFDLENBQUM7UUFDL0QsT0FBTyxFQUFFLGtCQUFrQixFQUF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lcGxhY2U6IHRydWUgfTtcbiAgfVxuXG4gIGNvbnN0IG9sZFRhYmxlUHJpdmlsZWdlcyA9IG9sZFJlc291cmNlUHJvcGVydGllcy50YWJsZVByaXZpbGVnZXM7XG4gIGlmIChvbGRUYWJsZVByaXZpbGVnZXMgIT09IHRhYmxlUHJpdmlsZWdlcykge1xuICAgIGF3YWl0IHJldm9rZVByaXZpbGVnZXModXNlcm5hbWUsIG9sZFRhYmxlUHJpdmlsZWdlcywgY2x1c3RlclByb3BzKTtcbiAgICBhd2FpdCBncmFudFByaXZpbGVnZXModXNlcm5hbWUsIHRhYmxlUHJpdmlsZWdlcywgY2x1c3RlclByb3BzKTtcbiAgICByZXR1cm4geyByZXBsYWNlOiBmYWxzZSB9O1xuICB9XG5cbiAgcmV0dXJuIHsgcmVwbGFjZTogZmFsc2UgfTtcbn1cbiJdfQ== \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.135d36da5a9e712a2792be4734f4cf4b34b551d49646eef9dec0c185fc869c12/types.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.135d36da5a9e712a2792be4734f4cf4b34b551d49646eef9dec0c185fc869c12/types.js deleted file mode 100644 index 070bb11c1600e..0000000000000 --- a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.135d36da5a9e712a2792be4734f4cf4b34b551d49646eef9dec0c185fc869c12/types.js +++ /dev/null @@ -1,24 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.TableSortStyle = void 0; -/** - * The sort style of a table. - * This has been duplicated here to exporting private types. - */ -var TableSortStyle; -(function (TableSortStyle) { - /** - * Amazon Redshift assigns an optimal sort key based on the table data. - */ - TableSortStyle["AUTO"] = "AUTO"; - /** - * Specifies that the data is sorted using a compound key made up of all of the listed columns, - * in the order they are listed. - */ - TableSortStyle["COMPOUND"] = "COMPOUND"; - /** - * Specifies that the data is sorted using an interleaved sort key. - */ - TableSortStyle["INTERLEAVED"] = "INTERLEAVED"; -})(TableSortStyle = exports.TableSortStyle || (exports.TableSortStyle = {})); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJ0eXBlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFLQTs7O0dBR0c7QUFDSCxJQUFZLGNBZ0JYO0FBaEJELFdBQVksY0FBYztJQUN4Qjs7T0FFRztJQUNILCtCQUFhLENBQUE7SUFFYjs7O09BR0c7SUFDSCx1Q0FBcUIsQ0FBQTtJQUVyQjs7T0FFRztJQUNILDZDQUEyQixDQUFBO0FBQzdCLENBQUMsRUFoQlcsY0FBYyxHQUFkLHNCQUFjLEtBQWQsc0JBQWMsUUFnQnpCIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgRGF0YWJhc2VRdWVyeUhhbmRsZXJQcm9wcywgVGFibGVIYW5kbGVyUHJvcHMgfSBmcm9tICcuLi9oYW5kbGVyLXByb3BzJztcblxuZXhwb3J0IHR5cGUgQ2x1c3RlclByb3BzID0gT21pdDxEYXRhYmFzZVF1ZXJ5SGFuZGxlclByb3BzLCAnaGFuZGxlcic+O1xuZXhwb3J0IHR5cGUgVGFibGVBbmRDbHVzdGVyUHJvcHMgPSBUYWJsZUhhbmRsZXJQcm9wcyAmIENsdXN0ZXJQcm9wcztcblxuLyoqXG4gKiBUaGUgc29ydCBzdHlsZSBvZiBhIHRhYmxlLlxuICogVGhpcyBoYXMgYmVlbiBkdXBsaWNhdGVkIGhlcmUgdG8gZXhwb3J0aW5nIHByaXZhdGUgdHlwZXMuXG4gKi9cbmV4cG9ydCBlbnVtIFRhYmxlU29ydFN0eWxlIHtcbiAgLyoqXG4gICAqIEFtYXpvbiBSZWRzaGlmdCBhc3NpZ25zIGFuIG9wdGltYWwgc29ydCBrZXkgYmFzZWQgb24gdGhlIHRhYmxlIGRhdGEuXG4gICAqL1xuICBBVVRPID0gJ0FVVE8nLFxuXG4gIC8qKlxuICAgKiBTcGVjaWZpZXMgdGhhdCB0aGUgZGF0YSBpcyBzb3J0ZWQgdXNpbmcgYSBjb21wb3VuZCBrZXkgbWFkZSB1cCBvZiBhbGwgb2YgdGhlIGxpc3RlZCBjb2x1bW5zLFxuICAgKiBpbiB0aGUgb3JkZXIgdGhleSBhcmUgbGlzdGVkLlxuICAgKi9cbiAgQ09NUE9VTkQgPSAnQ09NUE9VTkQnLFxuXG4gIC8qKlxuICAgKiBTcGVjaWZpZXMgdGhhdCB0aGUgZGF0YSBpcyBzb3J0ZWQgdXNpbmcgYW4gaW50ZXJsZWF2ZWQgc29ydCBrZXkuXG4gICAqL1xuICBJTlRFUkxFQVZFRCA9ICdJTlRFUkxFQVZFRCcsXG59XG4iXX0= \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746/cfn-response.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746/cfn-response.js deleted file mode 100644 index 18467aae70501..0000000000000 --- a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746/cfn-response.js +++ /dev/null @@ -1,87 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Retry = exports.safeHandler = exports.includeStackTraces = exports.submitResponse = exports.MISSING_PHYSICAL_ID_MARKER = exports.CREATE_FAILED_PHYSICAL_ID_MARKER = void 0; -/* eslint-disable max-len */ -/* eslint-disable no-console */ -const url = require("url"); -const outbound_1 = require("./outbound"); -const util_1 = require("./util"); -exports.CREATE_FAILED_PHYSICAL_ID_MARKER = 'AWSCDK::CustomResourceProviderFramework::CREATE_FAILED'; -exports.MISSING_PHYSICAL_ID_MARKER = 'AWSCDK::CustomResourceProviderFramework::MISSING_PHYSICAL_ID'; -async function submitResponse(status, event, options = {}) { - const json = { - Status: status, - Reason: options.reason || status, - StackId: event.StackId, - RequestId: event.RequestId, - PhysicalResourceId: event.PhysicalResourceId || exports.MISSING_PHYSICAL_ID_MARKER, - LogicalResourceId: event.LogicalResourceId, - NoEcho: options.noEcho, - Data: event.Data, - }; - (0, util_1.log)('submit response to cloudformation', json); - const responseBody = JSON.stringify(json); - const parsedUrl = url.parse(event.ResponseURL); - const retryOptions = { - attempts: 5, - sleep: 1000, - }; - await (0, util_1.withRetries)(retryOptions, outbound_1.httpRequest)({ - hostname: parsedUrl.hostname, - path: parsedUrl.path, - method: 'PUT', - headers: { - 'content-type': '', - 'content-length': Buffer.byteLength(responseBody, 'utf8'), - }, - }, responseBody); -} -exports.submitResponse = submitResponse; -exports.includeStackTraces = true; // for unit tests -function safeHandler(block) { - return async (event) => { - // ignore DELETE event when the physical resource ID is the marker that - // indicates that this DELETE is a subsequent DELETE to a failed CREATE - // operation. - if (event.RequestType === 'Delete' && event.PhysicalResourceId === exports.CREATE_FAILED_PHYSICAL_ID_MARKER) { - (0, util_1.log)('ignoring DELETE event caused by a failed CREATE event'); - await submitResponse('SUCCESS', event); - return; - } - try { - await block(event); - } - catch (e) { - // tell waiter state machine to retry - if (e instanceof Retry) { - (0, util_1.log)('retry requested by handler'); - throw e; - } - if (!event.PhysicalResourceId) { - // special case: if CREATE fails, which usually implies, we usually don't - // have a physical resource id. in this case, the subsequent DELETE - // operation does not have any meaning, and will likely fail as well. to - // address this, we use a marker so the provider framework can simply - // ignore the subsequent DELETE. - if (event.RequestType === 'Create') { - (0, util_1.log)('CREATE failed, responding with a marker physical resource id so that the subsequent DELETE will be ignored'); - event.PhysicalResourceId = exports.CREATE_FAILED_PHYSICAL_ID_MARKER; - } - else { - // otherwise, if PhysicalResourceId is not specified, something is - // terribly wrong because all other events should have an ID. - (0, util_1.log)(`ERROR: Malformed event. "PhysicalResourceId" is required: ${JSON.stringify({ ...event, ResponseURL: '...' })}`); - } - } - // this is an actual error, fail the activity altogether and exist. - await submitResponse('FAILED', event, { - reason: exports.includeStackTraces ? e.stack : e.message, - }); - } - }; -} -exports.safeHandler = safeHandler; -class Retry extends Error { -} -exports.Retry = Retry; -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2ZuLXJlc3BvbnNlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiY2ZuLXJlc3BvbnNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLDRCQUE0QjtBQUM1QiwrQkFBK0I7QUFDL0IsMkJBQTJCO0FBQzNCLHlDQUF5QztBQUN6QyxpQ0FBMEM7QUFFN0IsUUFBQSxnQ0FBZ0MsR0FBRyx3REFBd0QsQ0FBQztBQUM1RixRQUFBLDBCQUEwQixHQUFHLDhEQUE4RCxDQUFDO0FBZ0JsRyxLQUFLLFVBQVUsY0FBYyxDQUFDLE1BQTRCLEVBQUUsS0FBaUMsRUFBRSxVQUF5QyxFQUFHO0lBQ2hKLE1BQU0sSUFBSSxHQUFtRDtRQUMzRCxNQUFNLEVBQUUsTUFBTTtRQUNkLE1BQU0sRUFBRSxPQUFPLENBQUMsTUFBTSxJQUFJLE1BQU07UUFDaEMsT0FBTyxFQUFFLEtBQUssQ0FBQyxPQUFPO1FBQ3RCLFNBQVMsRUFBRSxLQUFLLENBQUMsU0FBUztRQUMxQixrQkFBa0IsRUFBRSxLQUFLLENBQUMsa0JBQWtCLElBQUksa0NBQTBCO1FBQzFFLGlCQUFpQixFQUFFLEtBQUssQ0FBQyxpQkFBaUI7UUFDMUMsTUFBTSxFQUFFLE9BQU8sQ0FBQyxNQUFNO1FBQ3RCLElBQUksRUFBRSxLQUFLLENBQUMsSUFBSTtLQUNqQixDQUFDO0lBRUYsSUFBQSxVQUFHLEVBQUMsbUNBQW1DLEV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FlTSUNBTF9JRF9NQVJLRVI7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgLy8gb3RoZXJ3aXNlLCBpZiBQaHlzaWNhbFJlc291cmNlSWQgaXMgbm90IHNwZWNpZmllZCwgc29tZXRoaW5nIGlzXG4gICAgICAgICAgLy8gdGVycmlibHkgd3JvbmcgYmVjYXVzZSBhbGwgb3RoZXIgZXZlbnRzIHNob3VsZCBoYXZlIGFuIElELlxuICAgICAgICAgIGxvZyhgRVJST1I6IE1hbGZvcm1lZCBldmVudC4gXCJQaHlzaWNhbFJlc291cmNlSWRcIiBpcyByZXF1aXJlZDogJHtKU09OLnN0cmluZ2lmeSh7IC4uLmV2ZW50LCBSZXNwb25zZVVSTDogJy4uLicgfSl9YCk7XG4gICAgICAgIH1cbiAgICAgIH1cblxuICAgICAgLy8gdGhpcyBpcyBhbiBhY3R1YWwgZXJyb3IsIGZhaWwgdGhlIGFjdGl2aXR5IGFsdG9nZXRoZXIgYW5kIGV4aXN0LlxuICAgICAgYXdhaXQgc3VibWl0UmVzcG9uc2UoJ0ZBSUxFRCcsIGV2ZW50LCB7XG4gICAgICAgIHJlYXNvbjogaW5jbHVkZVN0YWNrVHJhY2VzID8gZS5zdGFjayA6IGUubWVzc2FnZSxcbiAgICAgIH0pO1xuICAgIH1cbiAgfTtcbn1cblxuZXhwb3J0IGNsYXNzIFJldHJ5IGV4dGVuZHMgRXJyb3IgeyB9XG4iXX0= \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746/consts.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746/consts.js deleted file mode 100644 index 31faa077ae313..0000000000000 --- a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746/consts.js +++ /dev/null @@ -1,10 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.FRAMEWORK_ON_TIMEOUT_HANDLER_NAME = exports.FRAMEWORK_IS_COMPLETE_HANDLER_NAME = exports.FRAMEWORK_ON_EVENT_HANDLER_NAME = exports.WAITER_STATE_MACHINE_ARN_ENV = exports.USER_IS_COMPLETE_FUNCTION_ARN_ENV = exports.USER_ON_EVENT_FUNCTION_ARN_ENV = void 0; -exports.USER_ON_EVENT_FUNCTION_ARN_ENV = 'USER_ON_EVENT_FUNCTION_ARN'; -exports.USER_IS_COMPLETE_FUNCTION_ARN_ENV = 'USER_IS_COMPLETE_FUNCTION_ARN'; -exports.WAITER_STATE_MACHINE_ARN_ENV = 'WAITER_STATE_MACHINE_ARN'; -exports.FRAMEWORK_ON_EVENT_HANDLER_NAME = 'onEvent'; -exports.FRAMEWORK_IS_COMPLETE_HANDLER_NAME = 'isComplete'; -exports.FRAMEWORK_ON_TIMEOUT_HANDLER_NAME = 'onTimeout'; -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uc3RzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiY29uc3RzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFhLFFBQUEsOEJBQThCLEdBQUcsNEJBQTRCLENBQUM7QUFDOUQsUUFBQSxpQ0FBaUMsR0FBRywrQkFBK0IsQ0FBQztBQUNwRSxRQUFBLDRCQUE0QixHQUFHLDBCQUEwQixDQUFDO0FBRTFELFFBQUEsK0JBQStCLEdBQUcsU0FBUyxDQUFDO0FBQzVDLFFBQUEsa0NBQWtDLEdBQUcsWUFBWSxDQUFDO0FBQ2xELFFBQUEsaUNBQWlDLEdBQUcsV0FBVyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IGNvbnN0IFVTRVJfT05fRVZFTlRfRlVOQ1RJT05fQVJOX0VOViA9ICdVU0VSX09OX0VWRU5UX0ZVTkNUSU9OX0FSTic7XG5leHBvcnQgY29uc3QgVVNFUl9JU19DT01QTEVURV9GVU5DVElPTl9BUk5fRU5WID0gJ1VTRVJfSVNfQ09NUExFVEVfRlVOQ1RJT05fQVJOJztcbmV4cG9ydCBjb25zdCBXQUlURVJfU1RBVEVfTUFDSElORV9BUk5fRU5WID0gJ1dBSVRFUl9TVEFURV9NQUNISU5FX0FSTic7XG5cbmV4cG9ydCBjb25zdCBGUkFNRVdPUktfT05fRVZFTlRfSEFORExFUl9OQU1FID0gJ29uRXZlbnQnO1xuZXhwb3J0IGNvbnN0IEZSQU1FV09SS19JU19DT01QTEVURV9IQU5ETEVSX05BTUUgPSAnaXNDb21wbGV0ZSc7XG5leHBvcnQgY29uc3QgRlJBTUVXT1JLX09OX1RJTUVPVVRfSEFORExFUl9OQU1FID0gJ29uVGltZW91dCc7XG4iXX0= \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746/framework.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746/framework.js deleted file mode 100644 index f844797756840..0000000000000 --- a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746/framework.js +++ /dev/null @@ -1,170 +0,0 @@ -"use strict"; -/* eslint-disable max-len */ -/* eslint-disable no-console */ -const cfnResponse = require("./cfn-response"); -const consts = require("./consts"); -const outbound_1 = require("./outbound"); -const util_1 = require("./util"); -/** - * The main runtime entrypoint of the async custom resource lambda function. - * - * Any lifecycle event changes to the custom resources will invoke this handler, which will, in turn, - * interact with the user-defined `onEvent` and `isComplete` handlers. - * - * This function will always succeed. If an error occurs - * - * @param cfnRequest The cloudformation custom resource event. - */ -async function onEvent(cfnRequest) { - const sanitizedRequest = { ...cfnRequest, ResponseURL: '...' }; - (0, util_1.log)('onEventHandler', sanitizedRequest); - cfnRequest.ResourceProperties = cfnRequest.ResourceProperties || {}; - const onEventResult = await invokeUserFunction(consts.USER_ON_EVENT_FUNCTION_ARN_ENV, sanitizedRequest, cfnRequest.ResponseURL); - (0, util_1.log)('onEvent returned:', onEventResult); - // merge the request and the result from onEvent to form the complete resource event - // this also performs validation. - const resourceEvent = createResponseEvent(cfnRequest, onEventResult); - (0, util_1.log)('event:', onEventResult); - // determine if this is an async provider based on whether we have an isComplete handler defined. - // if it is not defined, then we are basically ready to return a positive response. - if (!process.env[consts.USER_IS_COMPLETE_FUNCTION_ARN_ENV]) { - return cfnResponse.submitResponse('SUCCESS', resourceEvent, { noEcho: resourceEvent.NoEcho }); - } - // ok, we are not complete, so kick off the waiter workflow - const waiter = { - stateMachineArn: (0, util_1.getEnv)(consts.WAITER_STATE_MACHINE_ARN_ENV), - name: resourceEvent.RequestId, - input: JSON.stringify(resourceEvent), - }; - (0, util_1.log)('starting waiter', waiter); - // kick off waiter state machine - await (0, outbound_1.startExecution)(waiter); -} -// invoked a few times until `complete` is true or until it times out. -async function isComplete(event) { - const sanitizedRequest = { ...event, ResponseURL: '...' }; - (0, util_1.log)('isComplete', sanitizedRequest); - const isCompleteResult = await invokeUserFunction(consts.USER_IS_COMPLETE_FUNCTION_ARN_ENV, sanitizedRequest, event.ResponseURL); - (0, util_1.log)('user isComplete returned:', isCompleteResult); - // if we are not complete, return false, and don't send a response back. - if (!isCompleteResult.IsComplete) { - if (isCompleteResult.Data && Object.keys(isCompleteResult.Data).length > 0) { - throw new Error('"Data" is not allowed if "IsComplete" is "False"'); - } - // This must be the full event, it will be deserialized in `onTimeout` to send the response to CloudFormation - throw new cfnResponse.Retry(JSON.stringify(event)); - } - const response = { - ...event, - ...isCompleteResult, - Data: { - ...event.Data, - ...isCompleteResult.Data, - }, - }; - await cfnResponse.submitResponse('SUCCESS', response, { noEcho: event.NoEcho }); -} -// invoked when completion retries are exhaused. -async function onTimeout(timeoutEvent) { - (0, util_1.log)('timeoutHandler', timeoutEvent); - const isCompleteRequest = JSON.parse(JSON.parse(timeoutEvent.Cause).errorMessage); - await cfnResponse.submitResponse('FAILED', isCompleteRequest, { - reason: 'Operation timed out', - }); -} -async function invokeUserFunction(functionArnEnv, sanitizedPayload, responseUrl) { - const functionArn = (0, util_1.getEnv)(functionArnEnv); - (0, util_1.log)(`executing user function ${functionArn} with payload`, sanitizedPayload); - // transient errors such as timeouts, throttling errors (429), and other - // errors that aren't caused by a bad request (500 series) are retried - // automatically by the JavaScript SDK. - const resp = await (0, outbound_1.invokeFunction)({ - FunctionName: functionArn, - // Cannot strip 'ResponseURL' here as this would be a breaking change even though the downstream CR doesn't need it - Payload: JSON.stringify({ ...sanitizedPayload, ResponseURL: responseUrl }), - }); - (0, util_1.log)('user function response:', resp, typeof (resp)); - const jsonPayload = parseJsonPayload(resp.Payload); - if (resp.FunctionError) { - (0, util_1.log)('user function threw an error:', resp.FunctionError); - const errorMessage = jsonPayload.errorMessage || 'error'; - // parse function name from arn - // arn:${Partition}:lambda:${Region}:${Account}:function:${FunctionName} - const arn = functionArn.split(':'); - const functionName = arn[arn.length - 1]; - // append a reference to the log group. - const message = [ - errorMessage, - '', - `Logs: /aws/lambda/${functionName}`, - '', - ].join('\n'); - const e = new Error(message); - // the output that goes to CFN is what's in `stack`, not the error message. - // if we have a remote trace, construct a nice message with log group information - if (jsonPayload.trace) { - // skip first trace line because it's the message - e.stack = [message, ...jsonPayload.trace.slice(1)].join('\n'); - } - throw e; - } - return jsonPayload; -} -function parseJsonPayload(payload) { - if (!payload) { - return {}; - } - const text = payload.toString(); - try { - return JSON.parse(text); - } - catch { - throw new Error(`return values from user-handlers must be JSON objects. got: "${text}"`); - } -} -function createResponseEvent(cfnRequest, onEventResult) { - // - // validate that onEventResult always includes a PhysicalResourceId - onEventResult = onEventResult || {}; - // if physical ID is not returned, we have some defaults for you based - // on the request type. - const physicalResourceId = onEventResult.PhysicalResourceId || defaultPhysicalResourceId(cfnRequest); - // if we are in DELETE and physical ID was changed, it's an error. - if (cfnRequest.RequestType === 'Delete' && physicalResourceId !== cfnRequest.PhysicalResourceId) { - throw new Error(`DELETE: cannot change the physical resource ID from "${cfnRequest.PhysicalResourceId}" to "${onEventResult.PhysicalResourceId}" during deletion`); - } - // if we are in UPDATE and physical ID was changed, it's a replacement (just log) - if (cfnRequest.RequestType === 'Update' && physicalResourceId !== cfnRequest.PhysicalResourceId) { - (0, util_1.log)(`UPDATE: changing physical resource ID from "${cfnRequest.PhysicalResourceId}" to "${onEventResult.PhysicalResourceId}"`); - } - // merge request event and result event (result prevails). - return { - ...cfnRequest, - ...onEventResult, - PhysicalResourceId: physicalResourceId, - }; -} -/** - * Calculates the default physical resource ID based in case user handler did - * not return a PhysicalResourceId. - * - * For "CREATE", it uses the RequestId. - * For "UPDATE" and "DELETE" and returns the current PhysicalResourceId (the one provided in `event`). - */ -function defaultPhysicalResourceId(req) { - switch (req.RequestType) { - case 'Create': - return req.RequestId; - case 'Update': - case 'Delete': - return req.PhysicalResourceId; - default: - throw new Error(`Invalid "RequestType" in request "${JSON.stringify(req)}"`); - } -} -module.exports = { - [consts.FRAMEWORK_ON_EVENT_HANDLER_NAME]: cfnResponse.safeHandler(onEvent), - [consts.FRAMEWORK_IS_COMPLETE_HANDLER_NAME]: cfnResponse.safeHandler(isComplete), - [consts.FRAMEWORK_ON_TIMEOUT_HANDLER_NAME]: onTimeout, -}; -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZnJhbWV3b3JrLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiZnJhbWV3b3JrLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSw0QkFBNEI7QUFDNUIsK0JBQStCO0FBQy9CLDhDQUE4QztBQUM5QyxtQ0FBbUM7QUFDbkMseUNBQT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lJzpcbiAgICAgIHJldHVybiByZXEuUmVxdWVzdElkO1xuXG4gICAgY2FzZSAnVXBkYXRlJzpcbiAgICBjYXNlICdEZWxldGUnOlxuICAgICAgcmV0dXJuIHJlcS5QaHlzaWNhbFJlc291cmNlSWQ7XG5cbiAgICBkZWZhdWx0OlxuICAgICAgdGhyb3cgbmV3IEVycm9yKGBJbnZhbGlkIFwiUmVxdWVzdFR5cGVcIiBpbiByZXF1ZXN0IFwiJHtKU09OLnN0cmluZ2lmeShyZXEpfVwiYCk7XG4gIH1cbn1cbiJdfQ== \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746/outbound.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746/outbound.js deleted file mode 100644 index 633482cec2767..0000000000000 --- a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746/outbound.js +++ /dev/null @@ -1,69 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.httpRequest = exports.invokeFunction = exports.startExecution = void 0; -/* istanbul ignore file */ -const https = require("https"); -// eslint-disable-next-line import/no-extraneous-dependencies -const AWS = require("aws-sdk"); -const FRAMEWORK_HANDLER_TIMEOUT = 900000; // 15 minutes -// In order to honor the overall maximum timeout set for the target process, -// the default 2 minutes from AWS SDK has to be overriden: -// https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#httpOptions-property -const awsSdkConfig = { - httpOptions: { timeout: FRAMEWORK_HANDLER_TIMEOUT }, -}; -async function defaultHttpRequest(options, responseBody) { - return new Promise((resolve, reject) => { - try { - const request = https.request(options, resolve); - request.on('error', reject); - request.write(responseBody); - request.end(); - } - catch (e) { - reject(e); - } - }); -} -let sfn; -let lambda; -async function defaultStartExecution(req) { - if (!sfn) { - sfn = new AWS.StepFunctions(awsSdkConfig); - } - return sfn.startExecution(req).promise(); -} -async function defaultInvokeFunction(req) { - if (!lambda) { - lambda = new AWS.Lambda(awsSdkConfig); - } - try { - /** - * Try an initial invoke. - * - * When you try to invoke a function that is inactive, the invocation fails and Lambda sets - * the function to pending state until the function resources are recreated. - * If Lambda fails to recreate the resources, the function is set to the inactive state. - * - * We're using invoke first because `waitFor` doesn't trigger an inactive function to do anything, - * it just runs `getFunction` and checks the state. - */ - return await lambda.invoke(req).promise(); - } - catch { - /** - * The status of the Lambda function is checked every second for up to 300 seconds. - * Exits the loop on 'Active' state and throws an error on 'Inactive' or 'Failed'. - * - * And now we wait. - */ - await lambda.waitFor('functionActiveV2', { - FunctionName: req.FunctionName, - }).promise(); - return await lambda.invoke(req).promise(); - } -} -exports.startExecution = defaultStartExecution; -exports.invokeFunction = defaultInvokeFunction; -exports.httpRequest = defaultHttpRequest; -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3V0Ym91bmQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJvdXRib3VuZC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSwwQkFBMEI7QUFDMUIsK0JBQStCO0FBQy9CLDZEQUE2RDtBQUM3RCwrQkFBK0I7QUFJL0IsTUFBTSx5QkFBeUIsR0FBRyxNQUFNLENBQUMsQ0FBQyxhQUFhO0FBRXZELDRFQUE0RTtBQUM1RSwwREFBMEQ7QUFDMUQsMkZBQTJGO0FBQzNGLE1BQU0sWUFBWSxHQUF5QjtJQUN6QyxXQUFXLEVBQUUsRUFBRSxPQUFPLEVBQUUseUJBQXlCLEVBQUU7Q0FDcEQsQ0FBQztBQUVGLEtBQUssVUFBVSxrQkFBa0IsQ0FBQyxPQUE2QixFQUFFLFlBQW9CO0lBQ25GLE9BQU8sSUFBSSxPQUFPLENBQUMsQ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F0Y2gge1xuXG4gICAgLyoqXG4gICAgICogVGhlIHN0YXR1cyBvZiB0aGUgTGFtYmRhIGZ1bmN0aW9uIGlzIGNoZWNrZWQgZXZlcnkgc2Vjb25kIGZvciB1cCB0byAzMDAgc2Vjb25kcy5cbiAgICAgKiBFeGl0cyB0aGUgbG9vcCBvbiAnQWN0aXZlJyBzdGF0ZSBhbmQgdGhyb3dzIGFuIGVycm9yIG9uICdJbmFjdGl2ZScgb3IgJ0ZhaWxlZCcuXG4gICAgICpcbiAgICAgKiBBbmQgbm93IHdlIHdhaXQuXG4gICAgICovXG4gICAgYXdhaXQgbGFtYmRhLndhaXRGb3IoJ2Z1bmN0aW9uQWN0aXZlVjInLCB7XG4gICAgICBGdW5jdGlvbk5hbWU6IHJlcS5GdW5jdGlvbk5hbWUsXG4gICAgfSkucHJvbWlzZSgpO1xuICAgIHJldHVybiBhd2FpdCBsYW1iZGEuaW52b2tlKHJlcSkucHJvbWlzZSgpO1xuICB9XG59XG5cbmV4cG9ydCBsZXQgc3RhcnRFeGVjdXRpb24gPSBkZWZhdWx0U3RhcnRFeGVjdXRpb247XG5leHBvcnQgbGV0IGludm9rZUZ1bmN0aW9uID0gZGVmYXVsdEludm9rZUZ1bmN0aW9uO1xuZXhwb3J0IGxldCBodHRwUmVxdWVzdCA9IGRlZmF1bHRIdHRwUmVxdWVzdDtcbiJdfQ== \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746/util.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746/util.js deleted file mode 100644 index f09276d40ac91..0000000000000 --- a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.1eabd374284db340b74179e3429008132f5b6b0b7b28d472d852807d7f5f9746/util.js +++ /dev/null @@ -1,39 +0,0 @@ -"use strict"; -/* eslint-disable no-console */ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.withRetries = exports.log = exports.getEnv = void 0; -function getEnv(name) { - const value = process.env[name]; - if (!value) { - throw new Error(`The environment variable "${name}" is not defined`); - } - return value; -} -exports.getEnv = getEnv; -function log(title, ...args) { - console.log('[provider-framework]', title, ...args.map(x => typeof (x) === 'object' ? JSON.stringify(x, undefined, 2) : x)); -} -exports.log = log; -function withRetries(options, fn) { - return async (...xs) => { - let attempts = options.attempts; - let ms = options.sleep; - while (true) { - try { - return await fn(...xs); - } - catch (e) { - if (attempts-- <= 0) { - throw e; - } - await sleep(Math.floor(Math.random() * ms)); - ms *= 2; - } - } - }; -} -exports.withRetries = withRetries; -async function sleep(ms) { - return new Promise((ok) => setTimeout(ok, ms)); -} -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInV0aWwudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLCtCQUErQjs7O0FBRS9CLFNBQWdCLE1BQU0sQ0FBQyxJQUFZO0lBQ2pDLE1BQU0sS0FBSyxHQUFHLE9BQU8sQ0FBQyxHQUFHLENBQUMsSUFBSSxDQUFDLENBQUM7SUFDaEMsSUFBSSxDQUFDLEtBQUssRUFBRTtRQUNWLE1BQU0sSUFBSSxLQUFLLENBQUMsNkJBQTZCLElBQUksa0JBQWtCLENBQUMsQ0FBQztLQUN0RTtJQUNELE9BQU8sS0FBSyxDQUFDO0FBQ2YsQ0FBQztBQU5ELHdCQU1DO0FBRUQsU0FBZ0IsR0FBRyxDQUFDLEtBQVUsRUFBRSxHQUFHLElBQVc7SUFDNUMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxzQkFBc0IsRUFBRSxLQUFLLEVBQUUsR0FBRyxJQUFJLENBQUMsR0FBRyxDQUFDLENBQUMsQ0FBQyxFQUFFLENBQUMsT0FBTS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ucy5hdHRlbXB0cztcbiAgICBsZXQgbXMgPSBvcHRpb25zLnNsZWVwO1xuICAgIHdoaWxlICh0cnVlKSB7XG4gICAgICB0cnkge1xuICAgICAgICByZXR1cm4gYXdhaXQgZm4oLi4ueHMpO1xuICAgICAgfSBjYXRjaCAoZSkge1xuICAgICAgICBpZiAoYXR0ZW1wdHMtLSA8PSAwKSB7XG4gICAgICAgICAgdGhyb3cgZTtcbiAgICAgICAgfVxuICAgICAgICBhd2FpdCBzbGVlcChNYXRoLmZsb29yKE1hdGgucmFuZG9tKCkgKiBtcykpO1xuICAgICAgICBtcyAqPSAyO1xuICAgICAgfVxuICAgIH1cbiAgfTtcbn1cblxuYXN5bmMgZnVuY3Rpb24gc2xlZXAobXM6IG51bWJlcik6IFByb21pc2U8dm9pZD4ge1xuICByZXR1cm4gbmV3IFByb21pc2UoKG9rKSA9PiBzZXRUaW1lb3V0KG9rLCBtcykpO1xufSJdfQ== \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/handler-name.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/handler-name.js deleted file mode 100644 index 4983115a93834..0000000000000 --- a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/handler-name.js +++ /dev/null @@ -1,10 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.HandlerName = void 0; -var HandlerName; -(function (HandlerName) { - HandlerName["User"] = "user"; - HandlerName["Table"] = "table"; - HandlerName["UserTablePrivileges"] = "user-table-privileges"; -})(HandlerName = exports.HandlerName || (exports.HandlerName = {})); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGFuZGxlci1uYW1lLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiaGFuZGxlci1uYW1lLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLElBQVksV0FJWDtBQUpELFdBQVksV0FBVztJQUNyQiw0QkFBYSxDQUFBO0lBQ2IsOEJBQWUsQ0FBQTtJQUNmLDREQUE2QyxDQUFBO0FBQy9DLENBQUMsRUFKVyxXQUFXLEdBQVgsbUJBQVcsS0FBWCxtQkFBVyxRQUl0QiIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBlbnVtIEhhbmRsZXJOYW1lIHtcbiAgVXNlciA9ICd1c2VyJyxcbiAgVGFibGUgPSAndGFibGUnLFxuICBVc2VyVGFibGVQcml2aWxlZ2VzID0gJ3VzZXItdGFibGUtcHJpdmlsZWdlcycsXG59XG4iXX0= \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/index.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/index.js deleted file mode 100644 index d7a8b52f2944c..0000000000000 --- a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/index.js +++ /dev/null @@ -1,21 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.handler = void 0; -const handler_name_1 = require("./handler-name"); -const privileges_1 = require("./privileges"); -const table_1 = require("./table"); -const user_1 = require("./user"); -const HANDLERS = { - [handler_name_1.HandlerName.Table]: table_1.handler, - [handler_name_1.HandlerName.User]: user_1.handler, - [handler_name_1.HandlerName.UserTablePrivileges]: privileges_1.handler, -}; -async function handler(event) { - const subHandler = HANDLERS[event.ResourceProperties.handler]; - if (!subHandler) { - throw new Error(`Requested handler ${event.ResourceProperties.handler} is not in supported set: ${JSON.stringify(Object.keys(HANDLERS))}`); - } - return subHandler(event.ResourceProperties, event); -} -exports.handler = handler; -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJpbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFFQSxpREFBNkM7QUFDN0MsNkNBQTJEO0FBQzNELG1DQUFpRDtBQUNqRCxpQ0FBK0M7QUFFL0MsTUFBTSxRQUFRLEdBQWlIO0lBQzdILENBQUMsMEJBQVcsQ0FBQyxLQUFLLENBQUMsRUFBRSxlQUFXO0lBQ2hDLENBQUMsMEJBQVcsQ0FBQyxJQUFJLENBQUMsRUFBRSxjQUFVO0lBQzlCLENBQUMsMEJBQVcsQ0FBQyxtQkFBbUIsQ0FBQyxFQUFFLG9CQUFnQjtDQUNwRCxDQUFDO0FBRUssS0FBSyxVQUFVLE9BQU8sQ0FBQyxLQUFrRDtJQUM5RSxNQUFNLFVBQVUsR0FBRyxRQUFRLENBQUMsS0FBSyxDQUFDLGtCQUFrQixDQUFDLE9BQXNCLENBQUMsQ0FBQztJQUM3RSxJQUFJLENBQUMsVUFBVSxFQUFFO1FBQ2YsTUFBTSxJQUFJLEtBQUssQ0FBQyxxQkFBcUIsS0FBSyxDQUFDLGtCQUFrQixDQUFDLE9BQU8sNkJBQTZCLElBQUksQ0FBQyxTQUFTLENBQUMsTUFBTSxDQUFDLElBQUksQ0FBQyxRQUFRLENBQUMsQ0FBQyxFQUFFLENBQUMsQ0FBQztLQUM1STtJQUNELE9BQU8sVUFBVSxDQUFDLEtBQUssQ0FBQyxrQkFBa0IsRUFBRSxLQUFLLENBQUMsQ0FBQztBQUNyRCxDQUFDO0FBTkQsMEJBTUMiLCJzb3VyY2VzQ29udGVudCI6WyIvKiBlc2xpbnQtZGlzYWJsZS1uZXh0LWx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uZGxlcn0gaXMgbm90IGluIHN1cHBvcnRlZCBzZXQ6ICR7SlNPTi5zdHJpbmdpZnkoT2JqZWN0LmtleXMoSEFORExFUlMpKX1gKTtcbiAgfVxuICByZXR1cm4gc3ViSGFuZGxlcihldmVudC5SZXNvdXJjZVByb3BlcnRpZXMsIGV2ZW50KTtcbn1cbiJdfQ== \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/redshift-data.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/redshift-data.js deleted file mode 100644 index e65374f4ab7e0..0000000000000 --- a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/redshift-data.js +++ /dev/null @@ -1,37 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.executeStatement = void 0; -/* eslint-disable-next-line import/no-extraneous-dependencies */ -const RedshiftData = require("aws-sdk/clients/redshiftdata"); -const redshiftData = new RedshiftData(); -async function executeStatement(statement, clusterProps) { - const executeStatementProps = { - ClusterIdentifier: clusterProps.clusterName, - Database: clusterProps.databaseName, - SecretArn: clusterProps.adminUserArn, - Sql: statement, - }; - const executedStatement = await redshiftData.executeStatement(executeStatementProps).promise(); - if (!executedStatement.Id) { - throw new Error('Service error: Statement execution did not return a statement ID'); - } - await waitForStatementComplete(executedStatement.Id); -} -exports.executeStatement = executeStatement; -const waitTimeout = 100; -async function waitForStatementComplete(statementId) { - await new Promise((resolve) => { - setTimeout(() => resolve(), waitTimeout); - }); - const statement = await redshiftData.describeStatement({ Id: statementId }).promise(); - if (statement.Status !== 'FINISHED' && statement.Status !== 'FAILED' && statement.Status !== 'ABORTED') { - return waitForStatementComplete(statementId); - } - else if (statement.Status === 'FINISHED') { - return; - } - else { - throw new Error(`Statement status was ${statement.Status}: ${statement.Error}`); - } -} -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVkc2hpZnQtZGF0YS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInJlZHNoaWZ0LWRhdGEudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsZ0VBQWdFO0FBQ2hFLDZEQUE2RDtBQUc3RCxNQUFNLFlBQVksR0FBRyxJQUFJLFlBQVksRUFBRSxDQUFDO0FBRWpDLEtBQUssVUFBVSxnQkFBZ0IsQ0FBQyxTQUFpQixFQUFFLFlBQTBCO0lBQ2xGLE1BQU0scUJBQXFCLEdBQUc7UUFDNUIsaUJBQWlCLEVBQUUsWUFBWSxDQUFDLFdBQVc7UUFDM0MsUUFBUSxFQUFFLFlBQVksQ0FBQyxZQUFZO1FBQ25DLFNBQVMsRUFBRSxZQUFZLENBQUMsWUFBWTtRQUNwQyxHQUFHLEVBQUUsU0FBUztLQUNmLENBQUM7SUFDRixNQUFNLGlCQUFpQixHQUFHLE1BQU0sWUFBWSxDQUFDLGdCQUFnQixDQUFDLHFCQUFxQixDQUFDLENBQUMsT0FBTyxFQUFFLENBQUM7SUFDL0YsSUFBSSxDQUFDLGlCQUFpQixDQUFDLEVBQUUsRUFBRTtRQUN6QixNQUFNLElBQUksS0FBSyxDQUFDLGtFQUFrRSxDQUFDLENBQUM7S0FDckY7SUFDRCxNQUFNLHdCQUF3QixDQUFDLGlCQUFpQixDQUFDLEVBQUUsQ0FBQyxDQUFDO0FBQ3ZELENBQUM7QUFaRCw0Q0FZQztBQUVELE1BQU0sV0FBVyxHQUFHLEdBQUcsQ0FBQztBQUN4QixLQUFLLFVBQVUsd0JBQXdCLENBQUMsV0FBbUI7SUFDekQsTUFBTSxJQUFJLE9BQU8sQ0FBQyxDQUFDLE9BQThCLEVBQUUsRUFBRTtRQUNuRCxV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YXRlbWVudElkIH0pLnByb21pc2UoKTtcbiAgaWYgKHN0YXRlbWVudC5TdGF0dXMgIT09ICdGSU5JU0hFRCcgJiYgc3RhdGVtZW50LlN0YXR1cyAhPT0gJ0ZBSUxFRCcgJiYgc3RhdGVtZW50LlN0YXR1cyAhPT0gJ0FCT1JURUQnKSB7XG4gICAgcmV0dXJuIHdhaXRGb3JTdGF0ZW1lbnRDb21wbGV0ZShzdGF0ZW1lbnRJZCk7XG4gIH0gZWxzZSBpZiAoc3RhdGVtZW50LlN0YXR1cyA9PT0gJ0ZJTklTSEVEJykge1xuICAgIHJldHVybjtcbiAgfSBlbHNlIHtcbiAgICB0aHJvdyBuZXcgRXJyb3IoYFN0YXRlbWVudCBzdGF0dXMgd2FzICR7c3RhdGVtZW50LlN0YXR1c306ICR7c3RhdGVtZW50LkVycm9yfWApO1xuICB9XG59XG4iXX0= \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/table.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/table.js deleted file mode 100644 index b1d964720f151..0000000000000 --- a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/table.js +++ /dev/null @@ -1,171 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.handler = void 0; -const redshift_data_1 = require("./redshift-data"); -const types_1 = require("./types"); -const util_1 = require("./util"); -async function handler(props, event) { - const tableNamePrefix = props.tableName.prefix; - const tableNameSuffix = props.tableName.generateSuffix === 'true' ? `${event.RequestId.substring(0, 8)}` : ''; - const tableColumns = props.tableColumns; - const tableAndClusterProps = props; - const useColumnIds = props.useColumnIds; - if (event.RequestType === 'Create') { - const tableName = await createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps); - return { PhysicalResourceId: tableName }; - } - else if (event.RequestType === 'Delete') { - await dropTable(event.PhysicalResourceId, tableAndClusterProps); - return; - } - else if (event.RequestType === 'Update') { - const tableName = await updateTable(event.PhysicalResourceId, tableNamePrefix, tableNameSuffix, tableColumns, useColumnIds, tableAndClusterProps, event.OldResourceProperties); - return { PhysicalResourceId: tableName }; - } - else { - /* eslint-disable-next-line dot-notation */ - throw new Error(`Unrecognized event type: ${event['RequestType']}`); - } -} -exports.handler = handler; -async function createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps) { - const tableName = tableNamePrefix + tableNameSuffix; - const tableColumnsString = tableColumns.map(column => `${column.name} ${column.dataType}${getEncodingColumnString(column)}`).join(); - let statement = `CREATE TABLE ${tableName} (${tableColumnsString})`; - if (tableAndClusterProps.distStyle) { - statement += ` DISTSTYLE ${tableAndClusterProps.distStyle}`; - } - const distKeyColumn = (0, util_1.getDistKeyColumn)(tableColumns); - if (distKeyColumn) { - statement += ` DISTKEY(${distKeyColumn.name})`; - } - const sortKeyColumns = (0, util_1.getSortKeyColumns)(tableColumns); - if (sortKeyColumns.length > 0) { - const sortKeyColumnsString = getSortKeyColumnsString(sortKeyColumns); - statement += ` ${tableAndClusterProps.sortStyle} SORTKEY(${sortKeyColumnsString})`; - } - await (0, redshift_data_1.executeStatement)(statement, tableAndClusterProps); - for (const column of tableColumns) { - if (column.comment) { - await (0, redshift_data_1.executeStatement)(`COMMENT ON COLUMN ${tableName}.${column.name} IS '${column.comment}'`, tableAndClusterProps); - } - } - if (tableAndClusterProps.tableComment) { - await (0, redshift_data_1.executeStatement)(`COMMENT ON TABLE ${tableName} IS '${tableAndClusterProps.tableComment}'`, tableAndClusterProps); - } - return tableName; -} -async function dropTable(tableName, clusterProps) { - await (0, redshift_data_1.executeStatement)(`DROP TABLE ${tableName}`, clusterProps); -} -async function updateTable(tableName, tableNamePrefix, tableNameSuffix, tableColumns, useColumnIds, tableAndClusterProps, oldResourceProperties) { - const alterationStatements = []; - const oldClusterProps = oldResourceProperties; - if (tableAndClusterProps.clusterName !== oldClusterProps.clusterName || tableAndClusterProps.databaseName !== oldClusterProps.databaseName) { - return createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps); - } - const oldTableNamePrefix = oldResourceProperties.tableName.prefix; - if (tableNamePrefix !== oldTableNamePrefix) { - return createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps); - } - const oldTableColumns = oldResourceProperties.tableColumns; - const columnDeletions = oldTableColumns.filter(oldColumn => (tableColumns.every(column => { - if (useColumnIds) { - return oldColumn.id ? oldColumn.id !== column.id : oldColumn.name !== column.name; - } - return oldColumn.name !== column.name; - }))); - if (columnDeletions.length > 0) { - alterationStatements.push(...columnDeletions.map(column => `ALTER TABLE ${tableName} DROP COLUMN ${column.name}`)); - } - const columnAdditions = tableColumns.filter(column => { - return !oldTableColumns.some(oldColumn => { - if (useColumnIds) { - return oldColumn.id ? oldColumn.id === column.id : oldColumn.name === column.name; - } - return oldColumn.name === column.name; - }); - }).map(column => `ADD ${column.name} ${column.dataType}`); - if (columnAdditions.length > 0) { - alterationStatements.push(...columnAdditions.map(addition => `ALTER TABLE ${tableName} ${addition}`)); - } - const columnEncoding = tableColumns.filter(column => { - return oldTableColumns.some(oldColumn => column.name === oldColumn.name && column.encoding !== oldColumn.encoding); - }).map(column => `ALTER COLUMN ${column.name} ENCODE ${column.encoding || 'AUTO'}`); - if (columnEncoding.length > 0) { - alterationStatements.push(`ALTER TABLE ${tableName} ${columnEncoding.join(', ')}`); - } - const columnComments = tableColumns.filter(column => { - return oldTableColumns.some(oldColumn => column.name === oldColumn.name && column.comment !== oldColumn.comment); - }).map(column => `COMMENT ON COLUMN ${tableName}.${column.name} IS ${column.comment ? `'${column.comment}'` : 'NULL'}`); - if (columnComments.length > 0) { - alterationStatements.push(...columnComments); - } - if (useColumnIds) { - const columnNameUpdates = tableColumns.reduce((updates, column) => { - const oldColumn = oldTableColumns.find(oldCol => oldCol.id && oldCol.id === column.id); - if (oldColumn && oldColumn.name !== column.name) { - updates[oldColumn.name] = column.name; - } - return updates; - }, {}); - if (Object.keys(columnNameUpdates).length > 0) { - alterationStatements.push(...Object.entries(columnNameUpdates).map(([oldName, newName]) => (`ALTER TABLE ${tableName} RENAME COLUMN ${oldName} TO ${newName}`))); - } - } - const oldDistStyle = oldResourceProperties.distStyle; - if ((!oldDistStyle && tableAndClusterProps.distStyle) || - (oldDistStyle && !tableAndClusterProps.distStyle)) { - return createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps); - } - else if (oldDistStyle !== tableAndClusterProps.distStyle) { - alterationStatements.push(`ALTER TABLE ${tableName} ALTER DISTSTYLE ${tableAndClusterProps.distStyle}`); - } - const oldDistKey = (0, util_1.getDistKeyColumn)(oldTableColumns)?.name; - const newDistKey = (0, util_1.getDistKeyColumn)(tableColumns)?.name; - if ((!oldDistKey && newDistKey) || (oldDistKey && !newDistKey)) { - return createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps); - } - else if (oldDistKey !== newDistKey) { - alterationStatements.push(`ALTER TABLE ${tableName} ALTER DISTKEY ${newDistKey}`); - } - const oldSortKeyColumns = (0, util_1.getSortKeyColumns)(oldTableColumns); - const newSortKeyColumns = (0, util_1.getSortKeyColumns)(tableColumns); - const oldSortStyle = oldResourceProperties.sortStyle; - const newSortStyle = tableAndClusterProps.sortStyle; - if ((oldSortStyle === newSortStyle && !(0, util_1.areColumnsEqual)(oldSortKeyColumns, newSortKeyColumns)) - || (oldSortStyle !== newSortStyle)) { - switch (newSortStyle) { - case types_1.TableSortStyle.INTERLEAVED: - // INTERLEAVED sort key addition requires replacement. - // https://docs.aws.amazon.com/redshift/latest/dg/r_ALTER_TABLE.html - return createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps); - case types_1.TableSortStyle.COMPOUND: { - const sortKeyColumnsString = getSortKeyColumnsString(newSortKeyColumns); - alterationStatements.push(`ALTER TABLE ${tableName} ALTER ${newSortStyle} SORTKEY(${sortKeyColumnsString})`); - break; - } - case types_1.TableSortStyle.AUTO: { - alterationStatements.push(`ALTER TABLE ${tableName} ALTER SORTKEY ${newSortStyle}`); - break; - } - } - } - const oldComment = oldResourceProperties.tableComment; - const newComment = tableAndClusterProps.tableComment; - if (oldComment !== newComment) { - alterationStatements.push(`COMMENT ON TABLE ${tableName} IS ${newComment ? `'${newComment}'` : 'NULL'}`); - } - await Promise.all(alterationStatements.map(statement => (0, redshift_data_1.executeStatement)(statement, tableAndClusterProps))); - return tableName; -} -function getSortKeyColumnsString(sortKeyColumns) { - return sortKeyColumns.map(column => column.name).join(); -} -function getEncodingColumnString(column) { - if (column.encoding) { - return ` ENCODE ${column.encoding}`; - } - return ''; -} -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFibGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJ0YWJsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFFQSxtREFBbUQ7QUFDbkQsbUNBQTZFO0FBQzdFLGlDQUE4RTtBQUd2RSxLQUFLLFVBQVUsT0FBTyxDQUFDLEtBQTJCLEVBQUUsS0FBa0Q7SUFDM0csTUFBTSxlQUFlLEdBQUcsS0FBSyxDQUFDLFNBQVMsQ0FBQyxNQUFNLENBQUM7SUFDL0MsTUFBTSxlQUFlLEdBQUcsS0FBSyxDQUFDLFNBQVMsQ0FBQyxjQUFjLEtBQUssTUFBTSxDQUFDLENBQUMsQ0FBQyxHQUFHLEtBQUssQ0FBQyxTQUFTLENBQUMsU0FBUyxDQUFDLENBQUMsRUFBRSxDQUFDLENBQUMsRUFBRSxDQUFDLENBQUMsQ0FBQyxFQUFFLENBQUM7SUFDOUcsTUFBTSxZQUFZLEdBQUcsS0FBSyxDQUFDLFlBQVksQ0FBQztJQUN4QyxNQUFNLG9CQUFvQixHQUFHL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AgaWYgKG9sZENvbW1lbnQgIT09IG5ld0NvbW1lbnQpIHtcbiAgICBhbHRlcmF0aW9uU3RhdGVtZW50cy5wdXNoKGBDT01NRU5UIE9OIFRBQkxFICR7dGFibGVOYW1lfSBJUyAke25ld0NvbW1lbnQgPyBgJyR7bmV3Q29tbWVudH0nYCA6ICdOVUxMJ31gKTtcbiAgfVxuXG4gIGF3YWl0IFByb21pc2UuYWxsKGFsdGVyYXRpb25TdGF0ZW1lbnRzLm1hcChzdGF0ZW1lbnQgPT4gZXhlY3V0ZVN0YXRlbWVudChzdGF0ZW1lbnQsIHRhYmxlQW5kQ2x1c3RlclByb3BzKSkpO1xuXG4gIHJldHVybiB0YWJsZU5hbWU7XG59XG5cbmZ1bmN0aW9uIGdldFNvcnRLZXlDb2x1bW5zU3RyaW5nKHNvcnRLZXlDb2x1bW5zOiBDb2x1bW5bXSkge1xuICByZXR1cm4gc29ydEtleUNvbHVtbnMubWFwKGNvbHVtbiA9PiBjb2x1bW4ubmFtZSkuam9pbigpO1xufVxuXG5mdW5jdGlvbiBnZXRFbmNvZGluZ0NvbHVtblN0cmluZyhjb2x1bW46IENvbHVtbik6IHN0cmluZyB7XG4gIGlmIChjb2x1bW4uZW5jb2RpbmcpIHtcbiAgICByZXR1cm4gYCBFTkNPREUgJHtjb2x1bW4uZW5jb2Rpbmd9YDtcbiAgfVxuICByZXR1cm4gJyc7XG59XG4iXX0= \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/types.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/types.js deleted file mode 100644 index 070bb11c1600e..0000000000000 --- a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/types.js +++ /dev/null @@ -1,24 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.TableSortStyle = void 0; -/** - * The sort style of a table. - * This has been duplicated here to exporting private types. - */ -var TableSortStyle; -(function (TableSortStyle) { - /** - * Amazon Redshift assigns an optimal sort key based on the table data. - */ - TableSortStyle["AUTO"] = "AUTO"; - /** - * Specifies that the data is sorted using a compound key made up of all of the listed columns, - * in the order they are listed. - */ - TableSortStyle["COMPOUND"] = "COMPOUND"; - /** - * Specifies that the data is sorted using an interleaved sort key. - */ - TableSortStyle["INTERLEAVED"] = "INTERLEAVED"; -})(TableSortStyle = exports.TableSortStyle || (exports.TableSortStyle = {})); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJ0eXBlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFLQTs7O0dBR0c7QUFDSCxJQUFZLGNBZ0JYO0FBaEJELFdBQVksY0FBYztJQUN4Qjs7T0FFRztJQUNILCtCQUFhLENBQUE7SUFFYjs7O09BR0c7SUFDSCx1Q0FBcUIsQ0FBQTtJQUVyQjs7T0FFRztJQUNILDZDQUEyQixDQUFBO0FBQzdCLENBQUMsRUFoQlcsY0FBYyxHQUFkLHNCQUFjLEtBQWQsc0JBQWMsUUFnQnpCIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgRGF0YWJhc2VRdWVyeUhhbmRsZXJQcm9wcywgVGFibGVIYW5kbGVyUHJvcHMgfSBmcm9tICcuLi9oYW5kbGVyLXByb3BzJztcblxuZXhwb3J0IHR5cGUgQ2x1c3RlclByb3BzID0gT21pdDxEYXRhYmFzZVF1ZXJ5SGFuZGxlclByb3BzLCAnaGFuZGxlcic+O1xuZXhwb3J0IHR5cGUgVGFibGVBbmRDbHVzdGVyUHJvcHMgPSBUYWJsZUhhbmRsZXJQcm9wcyAmIENsdXN0ZXJQcm9wcztcblxuLyoqXG4gKiBUaGUgc29ydCBzdHlsZSBvZiBhIHRhYmxlLlxuICogVGhpcyBoYXMgYmVlbiBkdXBsaWNhdGVkIGhlcmUgdG8gZXhwb3J0aW5nIHByaXZhdGUgdHlwZXMuXG4gKi9cbmV4cG9ydCBlbnVtIFRhYmxlU29ydFN0eWxlIHtcbiAgLyoqXG4gICAqIEFtYXpvbiBSZWRzaGlmdCBhc3NpZ25zIGFuIG9wdGltYWwgc29ydCBrZXkgYmFzZWQgb24gdGhlIHRhYmxlIGRhdGEuXG4gICAqL1xuICBBVVRPID0gJ0FVVE8nLFxuXG4gIC8qKlxuICAgKiBTcGVjaWZpZXMgdGhhdCB0aGUgZGF0YSBpcyBzb3J0ZWQgdXNpbmcgYSBjb21wb3VuZCBrZXkgbWFkZSB1cCBvZiBhbGwgb2YgdGhlIGxpc3RlZCBjb2x1bW5zLFxuICAgKiBpbiB0aGUgb3JkZXIgdGhleSBhcmUgbGlzdGVkLlxuICAgKi9cbiAgQ09NUE9VTkQgPSAnQ09NUE9VTkQnLFxuXG4gIC8qKlxuICAgKiBTcGVjaWZpZXMgdGhhdCB0aGUgZGF0YSBpcyBzb3J0ZWQgdXNpbmcgYW4gaW50ZXJsZWF2ZWQgc29ydCBrZXkuXG4gICAqL1xuICBJTlRFUkxFQVZFRCA9ICdJTlRFUkxFQVZFRCcsXG59XG4iXX0= \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/user.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/user.js deleted file mode 100644 index 5dd198f92a512..0000000000000 --- a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/user.js +++ /dev/null @@ -1,70 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.handler = void 0; -/* eslint-disable-next-line import/no-extraneous-dependencies */ -const SecretsManager = require("aws-sdk/clients/secretsmanager"); -const redshift_data_1 = require("./redshift-data"); -const util_1 = require("./util"); -const secretsManager = new SecretsManager(); -async function handler(props, event) { - const username = props.username; - const passwordSecretArn = props.passwordSecretArn; - const clusterProps = props; - if (event.RequestType === 'Create') { - await createUser(username, passwordSecretArn, clusterProps); - return { PhysicalResourceId: (0, util_1.makePhysicalId)(username, clusterProps, event.RequestId), Data: { username: username } }; - } - else if (event.RequestType === 'Delete') { - await dropUser(username, clusterProps); - return; - } - else if (event.RequestType === 'Update') { - const { replace } = await updateUser(username, passwordSecretArn, clusterProps, event.OldResourceProperties); - const physicalId = replace ? (0, util_1.makePhysicalId)(username, clusterProps, event.RequestId) : event.PhysicalResourceId; - return { PhysicalResourceId: physicalId, Data: { username: username } }; - } - else { - /* eslint-disable-next-line dot-notation */ - throw new Error(`Unrecognized event type: ${event['RequestType']}`); - } -} -exports.handler = handler; -async function dropUser(username, clusterProps) { - await (0, redshift_data_1.executeStatement)(`DROP USER ${username}`, clusterProps); -} -async function createUser(username, passwordSecretArn, clusterProps) { - const password = await getPasswordFromSecret(passwordSecretArn); - await (0, redshift_data_1.executeStatement)(`CREATE USER ${username} PASSWORD '${password}'`, clusterProps); -} -async function updateUser(username, passwordSecretArn, clusterProps, oldResourceProperties) { - const oldClusterProps = oldResourceProperties; - if (clusterProps.clusterName !== oldClusterProps.clusterName || clusterProps.databaseName !== oldClusterProps.databaseName) { - await createUser(username, passwordSecretArn, clusterProps); - return { replace: true }; - } - const oldUsername = oldResourceProperties.username; - const oldPasswordSecretArn = oldResourceProperties.passwordSecretArn; - const oldPassword = await getPasswordFromSecret(oldPasswordSecretArn); - const password = await getPasswordFromSecret(passwordSecretArn); - if (username !== oldUsername) { - await createUser(username, passwordSecretArn, clusterProps); - return { replace: true }; - } - if (password !== oldPassword) { - await (0, redshift_data_1.executeStatement)(`ALTER USER ${username} PASSWORD '${password}'`, clusterProps); - return { replace: false }; - } - return { replace: false }; -} -async function getPasswordFromSecret(passwordSecretArn) { - const secretValue = await secretsManager.getSecretValue({ - SecretId: passwordSecretArn, - }).promise(); - const secretString = secretValue.SecretString; - if (!secretString) { - throw new Error(`Secret string for ${passwordSecretArn} was empty`); - } - const { password } = JSON.parse(secretString); - return password; -} -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXNlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInVzZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBRUEsZ0VBQWdFO0FBQ2hFLGlFQUFpRTtBQUNqRSxtREFBbUQ7QUFFbkQsaUNBQXdDO0FBR3hDLE1BQU0sY0FBYyxHQUFHLElBQUksY0FBYyxFQUFFLENBQUM7QUFFckMsS0FBSyxVQUFVLE9BQU8sQ0FBQyxLQUFzQyxFQUFFLEtBQWtEO0lBQ3RILE1BQU0sUUFBUSxHQUFHLEtBQUssQ0FBQyxRQUFRLENBQUM7SUFDaEMsTUFBTSxpQkFBaUIsR0FBRyxLQUFLLENBQUMsaUJBQWlCLENBQUM7SUFDbEQsTUFBTSxZQUFZLEdBQUcsS0FBSyxDQUFDO0lBRTNCLElBQUksS0FBSyxDQUFDLFdBQVcsS0FBSyxRQUFRLEVBQUU7UUFDbEMsTUFBTSxVQUFVLENBQUMsUUFBUSxFQUFFLGlCQUFpQixFQUFFLFlBQVksQ0FBQyxDQUFDO1FBQzVELE9BQU8sRUFBRSxrQkFBa0IsRUFBRSxJQUFBLHFCQUFjLEVBQUMsUUFBUSxFQUFFLFlBQVksRUFBRSxLQUFLLENBQUMsU0FBUyxDQUFDLEVBQUUsSUFBSSxFQUFFLEVBQUUsUUFBUSxFQUFFLFFBQVEsRUFBRSxFQUFFLENBQUM7S0FDdEg7U0FBTSxJ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gcGFzc3dvcmQgfSA9IEpTT04ucGFyc2Uoc2VjcmV0U3RyaW5nKTtcblxuICByZXR1cm4gcGFzc3dvcmQ7XG59XG4iXX0= \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/util.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/util.js deleted file mode 100644 index d8dc8cad799c9..0000000000000 --- a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/util.js +++ /dev/null @@ -1,34 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.areColumnsEqual = exports.getSortKeyColumns = exports.getDistKeyColumn = exports.makePhysicalId = void 0; -function makePhysicalId(resourceName, clusterProps, requestId) { - return `${clusterProps.clusterName}:${clusterProps.databaseName}:${resourceName}:${requestId}`; -} -exports.makePhysicalId = makePhysicalId; -function getDistKeyColumn(columns) { - // string comparison is required for custom resource since everything is passed as string - const distKeyColumns = columns.filter(column => column.distKey === true || column.distKey === 'true'); - if (distKeyColumns.length === 0) { - return undefined; - } - else if (distKeyColumns.length > 1) { - throw new Error('Multiple dist key columns found'); - } - return distKeyColumns[0]; -} -exports.getDistKeyColumn = getDistKeyColumn; -function getSortKeyColumns(columns) { - // string comparison is required for custom resource since everything is passed as string - return columns.filter(column => column.sortKey === true || column.sortKey === 'true'); -} -exports.getSortKeyColumns = getSortKeyColumns; -function areColumnsEqual(columnsA, columnsB) { - if (columnsA.length !== columnsB.length) { - return false; - } - return columnsA.every(columnA => { - return columnsB.find(column => column.name === columnA.name && column.dataType === columnA.dataType); - }); -} -exports.areColumnsEqual = areColumnsEqual; -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJ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gfVxuICByZXR1cm4gY29sdW1uc0EuZXZlcnkoY29sdW1uQSA9PiB7XG4gICAgcmV0dXJuIGNvbHVtbnNCLmZpbmQoY29sdW1uID0+IGNvbHVtbi5uYW1lID09PSBjb2x1bW5BLm5hbWUgJiYgY29sdW1uLmRhdGFUeXBlID09PSBjb2x1bW5BLmRhdGFUeXBlKTtcbiAgfSk7XG59XG4iXX0= \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.135d36da5a9e712a2792be4734f4cf4b34b551d49646eef9dec0c185fc869c12/handler-name.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322/handler-name.js similarity index 66% rename from packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.135d36da5a9e712a2792be4734f4cf4b34b551d49646eef9dec0c185fc869c12/handler-name.js rename to packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322/handler-name.js index 4983115a93834..a8e809f76444f 100644 --- a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.135d36da5a9e712a2792be4734f4cf4b34b551d49646eef9dec0c185fc869c12/handler-name.js +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322/handler-name.js @@ -6,5 +6,5 @@ var HandlerName; HandlerName["User"] = "user"; HandlerName["Table"] = "table"; HandlerName["UserTablePrivileges"] = "user-table-privileges"; -})(HandlerName = exports.HandlerName || (exports.HandlerName = {})); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGFuZGxlci1uYW1lLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiaGFuZGxlci1uYW1lLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLElBQVksV0FJWDtBQUpELFdBQVksV0FBVztJQUNyQiw0QkFBYSxDQUFBO0lBQ2IsOEJBQWUsQ0FBQTtJQUNmLDREQUE2QyxDQUFBO0FBQy9DLENBQUMsRUFKVyxXQUFXLEdBQVgsbUJBQVcsS0FBWCxtQkFBVyxRQUl0QiIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBlbnVtIEhhbmRsZXJOYW1lIHtcbiAgVXNlciA9ICd1c2VyJyxcbiAgVGFibGUgPSAndGFibGUnLFxuICBVc2VyVGFibGVQcml2aWxlZ2VzID0gJ3VzZXItdGFibGUtcHJpdmlsZWdlcycsXG59XG4iXX0= \ No newline at end of file +})(HandlerName || (exports.HandlerName = HandlerName = {})); +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGFuZGxlci1uYW1lLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiaGFuZGxlci1uYW1lLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLElBQVksV0FJWDtBQUpELFdBQVksV0FBVztJQUNyQiw0QkFBYSxDQUFBO0lBQ2IsOEJBQWUsQ0FBQTtJQUNmLDREQUE2QyxDQUFBO0FBQy9DLENBQUMsRUFKVyxXQUFXLDJCQUFYLFdBQVcsUUFJdEIiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgZW51bSBIYW5kbGVyTmFtZSB7XG4gIFVzZXIgPSAndXNlcicsXG4gIFRhYmxlID0gJ3RhYmxlJyxcbiAgVXNlclRhYmxlUHJpdmlsZWdlcyA9ICd1c2VyLXRhYmxlLXByaXZpbGVnZXMnLFxufVxuIl19 \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.135d36da5a9e712a2792be4734f4cf4b34b551d49646eef9dec0c185fc869c12/index.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322/index.js similarity index 100% rename from packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.135d36da5a9e712a2792be4734f4cf4b34b551d49646eef9dec0c185fc869c12/index.js rename to packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322/index.js diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/privileges.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322/privileges.js similarity index 100% rename from packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.63972716b2c60e94733b1c6d7c9174a641155db8f2f400d9881811d12a37dc8c/privileges.js rename to packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322/privileges.js diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.135d36da5a9e712a2792be4734f4cf4b34b551d49646eef9dec0c185fc869c12/redshift-data.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322/redshift-data.js similarity index 100% rename from packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.135d36da5a9e712a2792be4734f4cf4b34b551d49646eef9dec0c185fc869c12/redshift-data.js rename to packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322/redshift-data.js diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.135d36da5a9e712a2792be4734f4cf4b34b551d49646eef9dec0c185fc869c12/table.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322/table.js similarity index 100% rename from packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.135d36da5a9e712a2792be4734f4cf4b34b551d49646eef9dec0c185fc869c12/table.js rename to packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322/table.js diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322/types.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322/types.js new file mode 100644 index 0000000000000..bbb29ad542beb --- /dev/null +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322/types.js @@ -0,0 +1,24 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.TableSortStyle = void 0; +/** + * The sort style of a table. + * This has been duplicated here to exporting private types. + */ +var TableSortStyle; +(function (TableSortStyle) { + /** + * Amazon Redshift assigns an optimal sort key based on the table data. + */ + TableSortStyle["AUTO"] = "AUTO"; + /** + * Specifies that the data is sorted using a compound key made up of all of the listed columns, + * in the order they are listed. + */ + TableSortStyle["COMPOUND"] = "COMPOUND"; + /** + * Specifies that the data is sorted using an interleaved sort key. + */ + TableSortStyle["INTERLEAVED"] = "INTERLEAVED"; +})(TableSortStyle || (exports.TableSortStyle = TableSortStyle = {})); +//# sourceMappingURL=data:application/json;base64,ey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W5nIGEgY29tcG91bmQga2V5IG1hZGUgdXAgb2YgYWxsIG9mIHRoZSBsaXN0ZWQgY29sdW1ucyxcbiAgICogaW4gdGhlIG9yZGVyIHRoZXkgYXJlIGxpc3RlZC5cbiAgICovXG4gIENPTVBPVU5EID0gJ0NPTVBPVU5EJyxcblxuICAvKipcbiAgICogU3BlY2lmaWVzIHRoYXQgdGhlIGRhdGEgaXMgc29ydGVkIHVzaW5nIGFuIGludGVybGVhdmVkIHNvcnQga2V5LlxuICAgKi9cbiAgSU5URVJMRUFWRUQgPSAnSU5URVJMRUFWRUQnLFxufVxuIl19 \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.135d36da5a9e712a2792be4734f4cf4b34b551d49646eef9dec0c185fc869c12/user.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322/user.js similarity index 100% rename from packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.135d36da5a9e712a2792be4734f4cf4b34b551d49646eef9dec0c185fc869c12/user.js rename to packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322/user.js diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.135d36da5a9e712a2792be4734f4cf4b34b551d49646eef9dec0c185fc869c12/util.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322/util.js similarity index 100% rename from packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.135d36da5a9e712a2792be4734f4cf4b34b551d49646eef9dec0c185fc869c12/util.js rename to packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322/util.js diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/aws-cdk-redshift-cluster-database.assets.json b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/aws-cdk-redshift-cluster-database.assets.json index 68b50ba498454..d5a82d3341b39 100644 --- a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/aws-cdk-redshift-cluster-database.assets.json +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/aws-cdk-redshift-cluster-database.assets.json @@ -1,15 +1,15 @@ { - "version": "32.0.0", + "version": "33.0.0", "files": { - "135d36da5a9e712a2792be4734f4cf4b34b551d49646eef9dec0c185fc869c12": { + "9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322": { "source": { - "path": "asset.135d36da5a9e712a2792be4734f4cf4b34b551d49646eef9dec0c185fc869c12", + "path": "asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322", "packaging": "zip" }, "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "135d36da5a9e712a2792be4734f4cf4b34b551d49646eef9dec0c185fc869c12.zip", + "objectKey": "9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322.zip", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } @@ -27,7 +27,7 @@ } } }, - "e649af73551b4319a2a0e21caf62d7713f1cc03dcdcdfcd30a166662ac296044": { + "6fae0ba8b4b765af354f41f73909322034258496718c660bad8e5336344a6d56": { "source": { "path": "aws-cdk-redshift-cluster-database.template.json", "packaging": "file" @@ -35,11 +35,11 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "e649af73551b4319a2a0e21caf62d7713f1cc03dcdcdfcd30a166662ac296044.json", + "objectKey": "6fae0ba8b4b765af354f41f73909322034258496718c660bad8e5336344a6d56.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } } }, "dockerImages": {} -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/aws-cdk-redshift-cluster-database.template.json b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/aws-cdk-redshift-cluster-database.template.json index 0c320c7301de9..bc775401b82bd 100644 --- a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/aws-cdk-redshift-cluster-database.template.json +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/aws-cdk-redshift-cluster-database.template.json @@ -1005,7 +1005,7 @@ "S3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "S3Key": "135d36da5a9e712a2792be4734f4cf4b34b551d49646eef9dec0c185fc869c12.zip" + "S3Key": "9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322.zip" }, "Handler": "index.handler", "Role": { diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/cdk.out b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/cdk.out index f0b901e7c06e5..560dae10d018f 100644 --- a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/cdk.out +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/cdk.out @@ -1 +1 @@ -{"version":"32.0.0"} \ No newline at end of file +{"version":"33.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/integ.json b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/integ.json index ce11f63584021..d49d391c62762 100644 --- a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/integ.json +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/integ.json @@ -1,5 +1,5 @@ { - "version": "32.0.0", + "version": "33.0.0", "testCases": { "redshift-cluster-database-integ/DefaultTest": { "stacks": [ diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/manifest.json b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/manifest.json index 025be3904e4e9..a5c900cb614dc 100644 --- a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/manifest.json +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/manifest.json @@ -1,5 +1,5 @@ { - "version": "32.0.0", + "version": "33.0.0", "artifacts": { "aws-cdk-redshift-cluster-database.assets": { "type": "cdk:asset-manifest", @@ -17,7 +17,7 @@ "validateOnSynth": false, "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/e649af73551b4319a2a0e21caf62d7713f1cc03dcdcdfcd30a166662ac296044.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/6fae0ba8b4b765af354f41f73909322034258496718c660bad8e5336344a6d56.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/redshiftclusterdatabaseintegDefaultTestDeployAssert4339FB48.assets.json b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/redshiftclusterdatabaseintegDefaultTestDeployAssert4339FB48.assets.json index 9104ab5ff793a..d39b55454659f 100644 --- a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/redshiftclusterdatabaseintegDefaultTestDeployAssert4339FB48.assets.json +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/redshiftclusterdatabaseintegDefaultTestDeployAssert4339FB48.assets.json @@ -1,5 +1,5 @@ { - "version": "32.0.0", + "version": "33.0.0", "files": { "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { "source": { diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/tree.json b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/tree.json index d940bcbe5840a..e16c7fc3f7f65 100644 --- a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/tree.json +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/tree.json @@ -1228,7 +1228,7 @@ }, "constructInfo": { "fqn": "constructs.Construct", - "version": "10.2.55" + "version": "10.2.69" } }, "TablePrivileges": { @@ -1470,13 +1470,13 @@ }, "constructInfo": { "fqn": "constructs.Construct", - "version": "10.2.55" + "version": "10.2.69" } } }, "constructInfo": { "fqn": "constructs.Construct", - "version": "10.2.55" + "version": "10.2.69" } } }, @@ -1639,7 +1639,7 @@ "s3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "s3Key": "135d36da5a9e712a2792be4734f4cf4b34b551d49646eef9dec0c185fc869c12.zip" + "s3Key": "9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322.zip" }, "handler": "index.handler", "role": { @@ -1902,7 +1902,7 @@ }, "constructInfo": { "fqn": "constructs.Construct", - "version": "10.2.55" + "version": "10.2.69" } } }, @@ -1946,7 +1946,7 @@ "path": "redshift-cluster-database-integ/DefaultTest/Default", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.2.55" + "version": "10.2.69" } }, "DeployAssert": { @@ -1992,7 +1992,7 @@ "path": "Tree", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.2.55" + "version": "10.2.69" } } }, From 61ae00b31710c3ccd83214b172cddc3a4348b652 Mon Sep 17 00:00:00 2001 From: Rizbir Khan Date: Wed, 2 Aug 2023 14:18:48 +0000 Subject: [PATCH 14/21] reverting machine-image --- packages/aws-cdk-lib/aws-ec2/lib/machine-image/index.ts | 7 +++---- .../{generic-machine-image.ts => machine-image.ts} | 0 2 files changed, 3 insertions(+), 4 deletions(-) rename packages/aws-cdk-lib/aws-ec2/lib/machine-image/{generic-machine-image.ts => machine-image.ts} (100%) diff --git a/packages/aws-cdk-lib/aws-ec2/lib/machine-image/index.ts b/packages/aws-cdk-lib/aws-ec2/lib/machine-image/index.ts index 8d083bcee3978..ad5829128310e 100644 --- a/packages/aws-cdk-lib/aws-ec2/lib/machine-image/index.ts +++ b/packages/aws-cdk-lib/aws-ec2/lib/machine-image/index.ts @@ -1,6 +1,5 @@ +export * from './common'; +export * from './amazon-linux2'; +export * from './machine-image'; export * from './amazon-linux-2022'; export * from './amazon-linux-2023'; -export * from './amazon-linux2'; -export * from './common'; -export * from './generic-machine-image'; - diff --git a/packages/aws-cdk-lib/aws-ec2/lib/machine-image/generic-machine-image.ts b/packages/aws-cdk-lib/aws-ec2/lib/machine-image/machine-image.ts similarity index 100% rename from packages/aws-cdk-lib/aws-ec2/lib/machine-image/generic-machine-image.ts rename to packages/aws-cdk-lib/aws-ec2/lib/machine-image/machine-image.ts From fcd2be48ddf5c6d1d76b73539ada90fc21667771 Mon Sep 17 00:00:00 2001 From: Rizbir Khan Date: Wed, 2 Aug 2023 14:50:58 +0000 Subject: [PATCH 15/21] when table id is removed, that means table is deleted --- .../private/database-query-provider/privileges.ts | 12 +++++------- .../test/database-query-provider/privileges.test.ts | 7 +++++-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/packages/@aws-cdk/aws-redshift-alpha/lib/private/database-query-provider/privileges.ts b/packages/@aws-cdk/aws-redshift-alpha/lib/private/database-query-provider/privileges.ts index dfe3b8f283de6..6c6785331df01 100644 --- a/packages/@aws-cdk/aws-redshift-alpha/lib/private/database-query-provider/privileges.ts +++ b/packages/@aws-cdk/aws-redshift-alpha/lib/private/database-query-provider/privileges.ts @@ -1,9 +1,9 @@ /* eslint-disable-next-line import/no-unresolved */ import * as AWSLambda from 'aws-lambda'; +import { TablePrivilege, UserTablePrivilegesHandlerProps } from '../handler-props'; import { executeStatement } from './redshift-data'; import { ClusterProps } from './types'; import { makePhysicalId } from './util'; -import { TablePrivilege, UserTablePrivilegesHandlerProps } from '../handler-props'; export async function handler(props: UserTablePrivilegesHandlerProps & ClusterProps, event: AWSLambda.CloudFormationCustomResourceEvent) { const username = props.username; @@ -62,13 +62,11 @@ async function updatePrivileges( } const oldTablePrivileges = oldResourceProperties.tablePrivileges; - const tablesToRevoke = oldTablePrivileges.filter(({ tableId, actions }) => { - const tableRemoved = !tablePrivileges.find(({ tableId: otherTableId }) => tableId === otherTableId); - const actionsRemoved = tablePrivileges.find(({ tableId: otherTableId, actions: otherActions }) => ( + const tablesToRevoke = oldTablePrivileges.filter(({ tableId, actions }) => ( + tablePrivileges.find(({ tableId: otherTableId, actions: otherActions }) => ( tableId === otherTableId && actions.some(action => !otherActions.includes(action)) - )); - return tableRemoved || actionsRemoved; - }); + )) + )); if (tablesToRevoke.length > 0) { await revokePrivileges(username, tablesToRevoke, clusterProps); } diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/database-query-provider/privileges.test.ts b/packages/@aws-cdk/aws-redshift-alpha/test/database-query-provider/privileges.test.ts index af1035fcb9866..5b91c38728f4b 100644 --- a/packages/@aws-cdk/aws-redshift-alpha/test/database-query-provider/privileges.test.ts +++ b/packages/@aws-cdk/aws-redshift-alpha/test/database-query-provider/privileges.test.ts @@ -198,7 +198,10 @@ describe('update', () => { PhysicalResourceId: physicalResourceId, }); expect(mockExecuteStatement).not.toHaveBeenCalledWith(expect.objectContaining({ - Sql: `.+ ON ${tableName} FROM ${username}`, + Sql: expect.stringMatching(new RegExp(`REVOKE .+ ON ${tableName} FROM ${username}`)), + })); + expect(mockExecuteStatement).toHaveBeenCalledWith(expect.objectContaining({ + Sql: expect.stringMatching(new RegExp(`GRANT .+ ON ${tableName} TO ${username}`)), })); }); @@ -221,7 +224,7 @@ describe('update', () => { PhysicalResourceId: physicalResourceId, }); expect(mockExecuteStatement).not.toHaveBeenCalledWith(expect.objectContaining({ - Sql: `.+ ON ${tableName} FROM ${username}`, + Sql: expect.stringMatching(new RegExp(`.+ ON ${tableName} FROM ${username}`)), })); }); }); \ No newline at end of file From bd8a0625085f38b1f58d3b12994fa422ca96547d Mon Sep 17 00:00:00 2001 From: Rizbir Khan Date: Wed, 23 Aug 2023 15:36:27 +0000 Subject: [PATCH 16/21] bump From ab35e58a72fcbe98eada7d2cce5a380d4b58635f Mon Sep 17 00:00:00 2001 From: Rizbir Khan Date: Mon, 4 Sep 2023 15:08:13 +0000 Subject: [PATCH 17/21] pkglint --- packages/@aws-cdk/integ-runner/THIRD_PARTY_LICENSES | 2 +- packages/aws-cdk/THIRD_PARTY_LICENSES | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/@aws-cdk/integ-runner/THIRD_PARTY_LICENSES b/packages/@aws-cdk/integ-runner/THIRD_PARTY_LICENSES index 1989809f7a5d6..8deff0fddc9f1 100644 --- a/packages/@aws-cdk/integ-runner/THIRD_PARTY_LICENSES +++ b/packages/@aws-cdk/integ-runner/THIRD_PARTY_LICENSES @@ -176,7 +176,7 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH RE ---------------- -** aws-sdk@2.1447.0 - https://www.npmjs.com/package/aws-sdk/v/2.1447.0 | Apache-2.0 +** aws-sdk@2.1442.0 - https://www.npmjs.com/package/aws-sdk/v/2.1442.0 | Apache-2.0 AWS SDK for JavaScript Copyright 2012-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. diff --git a/packages/aws-cdk/THIRD_PARTY_LICENSES b/packages/aws-cdk/THIRD_PARTY_LICENSES index 31d5e760f8a91..3427a083d433d 100644 --- a/packages/aws-cdk/THIRD_PARTY_LICENSES +++ b/packages/aws-cdk/THIRD_PARTY_LICENSES @@ -1,6 +1,6 @@ The aws-cdk package includes the following third-party software/licensing: -** @jsii/check-node@1.88.0 - https://www.npmjs.com/package/@jsii/check-node/v/1.88.0 | Apache-2.0 +** @jsii/check-node@1.87.0 - https://www.npmjs.com/package/@jsii/check-node/v/1.87.0 | Apache-2.0 jsii Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. @@ -238,7 +238,7 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH RE ---------------- -** aws-sdk@2.1447.0 - https://www.npmjs.com/package/aws-sdk/v/2.1447.0 | Apache-2.0 +** aws-sdk@2.1442.0 - https://www.npmjs.com/package/aws-sdk/v/2.1442.0 | Apache-2.0 AWS SDK for JavaScript Copyright 2012-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. From 5c0b036d79a1044a0f764e331d99c0e4fccd3fb8 Mon Sep 17 00:00:00 2001 From: Rizbir Khan Date: Tue, 5 Sep 2023 11:09:10 +0000 Subject: [PATCH 18/21] reverting pkglint --- packages/@aws-cdk/integ-runner/THIRD_PARTY_LICENSES | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@aws-cdk/integ-runner/THIRD_PARTY_LICENSES b/packages/@aws-cdk/integ-runner/THIRD_PARTY_LICENSES index 8deff0fddc9f1..1989809f7a5d6 100644 --- a/packages/@aws-cdk/integ-runner/THIRD_PARTY_LICENSES +++ b/packages/@aws-cdk/integ-runner/THIRD_PARTY_LICENSES @@ -176,7 +176,7 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH RE ---------------- -** aws-sdk@2.1442.0 - https://www.npmjs.com/package/aws-sdk/v/2.1442.0 | Apache-2.0 +** aws-sdk@2.1447.0 - https://www.npmjs.com/package/aws-sdk/v/2.1447.0 | Apache-2.0 AWS SDK for JavaScript Copyright 2012-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. From dc313037fd1b43ea796c0e359978f6ca95b15926 Mon Sep 17 00:00:00 2001 From: Rizbir Khan Date: Tue, 5 Sep 2023 11:09:56 +0000 Subject: [PATCH 19/21] reverting pkglint --- packages/aws-cdk/THIRD_PARTY_LICENSES | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/aws-cdk/THIRD_PARTY_LICENSES b/packages/aws-cdk/THIRD_PARTY_LICENSES index 3427a083d433d..31d5e760f8a91 100644 --- a/packages/aws-cdk/THIRD_PARTY_LICENSES +++ b/packages/aws-cdk/THIRD_PARTY_LICENSES @@ -1,6 +1,6 @@ The aws-cdk package includes the following third-party software/licensing: -** @jsii/check-node@1.87.0 - https://www.npmjs.com/package/@jsii/check-node/v/1.87.0 | Apache-2.0 +** @jsii/check-node@1.88.0 - https://www.npmjs.com/package/@jsii/check-node/v/1.88.0 | Apache-2.0 jsii Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. @@ -238,7 +238,7 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH RE ---------------- -** aws-sdk@2.1442.0 - https://www.npmjs.com/package/aws-sdk/v/2.1442.0 | Apache-2.0 +** aws-sdk@2.1447.0 - https://www.npmjs.com/package/aws-sdk/v/2.1447.0 | Apache-2.0 AWS SDK for JavaScript Copyright 2012-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. From 3ea07015c71330cda89e2e2522526b745c3d0f3a Mon Sep 17 00:00:00 2001 From: Rizbir Khan Date: Mon, 11 Sep 2023 16:23:53 +0000 Subject: [PATCH 20/21] integ test --- .../framework.js | 172 ------------------ .../outbound.js | 79 -------- .../util.js | 39 ---- .../privileges.js | 69 ------- .../cfn-response.js | 0 .../consts.js | 0 .../framework.js | 161 ++++++++++++++++ .../outbound.js | 75 ++++++++ .../util.js | 54 ++++++ .../handler-name.js | 0 .../index.js | 0 .../privileges.js | 65 +++++++ .../redshift-data.js | 0 .../table.js | 12 +- .../types.js | 0 .../user.js | 0 .../util.js | 0 ...-cdk-redshift-cluster-database.assets.json | 18 +- ...dk-redshift-cluster-database.template.json | 12 +- .../test/integ.database.js.snapshot/cdk.out | 2 +- .../integ.database.js.snapshot/integ.json | 2 +- .../integ.database.js.snapshot/manifest.json | 4 +- ...efaultTestDeployAssert4339FB48.assets.json | 2 +- .../test/integ.database.js.snapshot/tree.json | 20 +- .../aws-redshift-alpha/test/integ.database.ts | 5 +- 25 files changed, 397 insertions(+), 394 deletions(-) delete mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.73b60c2cf141bf58c33cfaa33858f5c84103a0232ba7192d696536488f7731c4/framework.js delete mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.73b60c2cf141bf58c33cfaa33858f5c84103a0232ba7192d696536488f7731c4/outbound.js delete mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.73b60c2cf141bf58c33cfaa33858f5c84103a0232ba7192d696536488f7731c4/util.js delete mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322/privileges.js rename packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/{asset.73b60c2cf141bf58c33cfaa33858f5c84103a0232ba7192d696536488f7731c4 => asset.d002370061965c69bc4caf15dddb5eccc9df318933ade6e4fa57cddb81c5abef}/cfn-response.js (100%) rename packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/{asset.73b60c2cf141bf58c33cfaa33858f5c84103a0232ba7192d696536488f7731c4 => asset.d002370061965c69bc4caf15dddb5eccc9df318933ade6e4fa57cddb81c5abef}/consts.js (100%) create mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.d002370061965c69bc4caf15dddb5eccc9df318933ade6e4fa57cddb81c5abef/framework.js create mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.d002370061965c69bc4caf15dddb5eccc9df318933ade6e4fa57cddb81c5abef/outbound.js create mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.d002370061965c69bc4caf15dddb5eccc9df318933ade6e4fa57cddb81c5abef/util.js rename packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/{asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322 => asset.e275fde8d2a03c793e28878ff6a48e84af45d2655f0c79418b5b86f2add826f7}/handler-name.js (100%) rename packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/{asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322 => asset.e275fde8d2a03c793e28878ff6a48e84af45d2655f0c79418b5b86f2add826f7}/index.js (100%) create mode 100644 packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.e275fde8d2a03c793e28878ff6a48e84af45d2655f0c79418b5b86f2add826f7/privileges.js rename packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/{asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322 => asset.e275fde8d2a03c793e28878ff6a48e84af45d2655f0c79418b5b86f2add826f7}/redshift-data.js (100%) rename packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/{asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322 => asset.e275fde8d2a03c793e28878ff6a48e84af45d2655f0c79418b5b86f2add826f7}/table.js (52%) rename packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/{asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322 => asset.e275fde8d2a03c793e28878ff6a48e84af45d2655f0c79418b5b86f2add826f7}/types.js (100%) rename packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/{asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322 => asset.e275fde8d2a03c793e28878ff6a48e84af45d2655f0c79418b5b86f2add826f7}/user.js (100%) rename packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/{asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322 => asset.e275fde8d2a03c793e28878ff6a48e84af45d2655f0c79418b5b86f2add826f7}/util.js (100%) diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.73b60c2cf141bf58c33cfaa33858f5c84103a0232ba7192d696536488f7731c4/framework.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.73b60c2cf141bf58c33cfaa33858f5c84103a0232ba7192d696536488f7731c4/framework.js deleted file mode 100644 index b92c20b34ad9d..0000000000000 --- a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.73b60c2cf141bf58c33cfaa33858f5c84103a0232ba7192d696536488f7731c4/framework.js +++ /dev/null @@ -1,172 +0,0 @@ -"use strict"; -/* eslint-disable max-len */ -/* eslint-disable no-console */ -const cfnResponse = require("./cfn-response"); -const consts = require("./consts"); -const outbound_1 = require("./outbound"); -const util_1 = require("./util"); -/** - * The main runtime entrypoint of the async custom resource lambda function. - * - * Any lifecycle event changes to the custom resources will invoke this handler, which will, in turn, - * interact with the user-defined `onEvent` and `isComplete` handlers. - * - * This function will always succeed. If an error occurs - * - * @param cfnRequest The cloudformation custom resource event. - */ -async function onEvent(cfnRequest) { - const sanitizedRequest = { ...cfnRequest, ResponseURL: '...' }; - (0, util_1.log)('onEventHandler', sanitizedRequest); - cfnRequest.ResourceProperties = cfnRequest.ResourceProperties || {}; - const onEventResult = await invokeUserFunction(consts.USER_ON_EVENT_FUNCTION_ARN_ENV, sanitizedRequest, cfnRequest.ResponseURL); - (0, util_1.log)('onEvent returned:', onEventResult); - // merge the request and the result from onEvent to form the complete resource event - // this also performs validation. - const resourceEvent = createResponseEvent(cfnRequest, onEventResult); - (0, util_1.log)('event:', onEventResult); - // determine if this is an async provider based on whether we have an isComplete handler defined. - // if it is not defined, then we are basically ready to return a positive response. - if (!process.env[consts.USER_IS_COMPLETE_FUNCTION_ARN_ENV]) { - return cfnResponse.submitResponse('SUCCESS', resourceEvent, { noEcho: resourceEvent.NoEcho }); - } - // ok, we are not complete, so kick off the waiter workflow - const waiter = { - stateMachineArn: (0, util_1.getEnv)(consts.WAITER_STATE_MACHINE_ARN_ENV), - name: resourceEvent.RequestId, - input: JSON.stringify(resourceEvent), - }; - (0, util_1.log)('starting waiter', waiter); - // kick off waiter state machine - await (0, outbound_1.startExecution)(waiter); -} -// invoked a few times until `complete` is true or until it times out. -async function isComplete(event) { - const sanitizedRequest = { ...event, ResponseURL: '...' }; - (0, util_1.log)('isComplete', sanitizedRequest); - const isCompleteResult = await invokeUserFunction(consts.USER_IS_COMPLETE_FUNCTION_ARN_ENV, sanitizedRequest, event.ResponseURL); - (0, util_1.log)('user isComplete returned:', isCompleteResult); - // if we are not complete, return false, and don't send a response back. - if (!isCompleteResult.IsComplete) { - if (isCompleteResult.Data && Object.keys(isCompleteResult.Data).length > 0) { - throw new Error('"Data" is not allowed if "IsComplete" is "False"'); - } - // This must be the full event, it will be deserialized in `onTimeout` to send the response to CloudFormation - throw new cfnResponse.Retry(JSON.stringify(event)); - } - const response = { - ...event, - ...isCompleteResult, - Data: { - ...event.Data, - ...isCompleteResult.Data, - }, - }; - await cfnResponse.submitResponse('SUCCESS', response, { noEcho: event.NoEcho }); -} -// invoked when completion retries are exhaused. -async function onTimeout(timeoutEvent) { - (0, util_1.log)('timeoutHandler', timeoutEvent); - const isCompleteRequest = JSON.parse(JSON.parse(timeoutEvent.Cause).errorMessage); - await cfnResponse.submitResponse('FAILED', isCompleteRequest, { - reason: 'Operation timed out', - }); -} -async function invokeUserFunction(functionArnEnv, sanitizedPayload, responseUrl) { - const functionArn = (0, util_1.getEnv)(functionArnEnv); - (0, util_1.log)(`executing user function ${functionArn} with payload`, sanitizedPayload); - // transient errors such as timeouts, throttling errors (429), and other - // errors that aren't caused by a bad request (500 series) are retried - // automatically by the JavaScript SDK. - const resp = await (0, outbound_1.invokeFunction)({ - FunctionName: functionArn, - // Cannot strip 'ResponseURL' here as this would be a breaking change even though the downstream CR doesn't need it - Payload: JSON.stringify({ ...sanitizedPayload, ResponseURL: responseUrl }), - }); - (0, util_1.log)('user function response:', resp, typeof (resp)); - const jsonPayload = parseJsonPayload(resp.Payload); - if (resp.FunctionError) { - (0, util_1.log)('user function threw an error:', resp.FunctionError); - const errorMessage = jsonPayload.errorMessage || 'error'; - // parse function name from arn - // arn:${Partition}:lambda:${Region}:${Account}:function:${FunctionName} - const arn = functionArn.split(':'); - const functionName = arn[arn.length - 1]; - // append a reference to the log group. - const message = [ - errorMessage, - '', - `Logs: /aws/lambda/${functionName}`, - '', - ].join('\n'); - const e = new Error(message); - // the output that goes to CFN is what's in `stack`, not the error message. - // if we have a remote trace, construct a nice message with log group information - if (jsonPayload.trace) { - // skip first trace line because it's the message - e.stack = [message, ...jsonPayload.trace.slice(1)].join('\n'); - } - throw e; - } - return jsonPayload; -} -function parseJsonPayload(payload) { - if (!payload) { - return {}; - } - // sdk v3 returns payloads in Uint8Array, either it or a string or Buffer - // can be cast into a buffer and then decoded. - let text = new TextDecoder().decode(Buffer.from(payload)); - try { - return JSON.parse(text); - } - catch { - throw new Error(`return values from user-handlers must be JSON objects. got: "${text}"`); - } -} -function createResponseEvent(cfnRequest, onEventResult) { - // - // validate that onEventResult always includes a PhysicalResourceId - onEventResult = onEventResult || {}; - // if physical ID is not returned, we have some defaults for you based - // on the request type. - const physicalResourceId = onEventResult.PhysicalResourceId || defaultPhysicalResourceId(cfnRequest); - // if we are in DELETE and physical ID was changed, it's an error. - if (cfnRequest.RequestType === 'Delete' && physicalResourceId !== cfnRequest.PhysicalResourceId) { - throw new Error(`DELETE: cannot change the physical resource ID from "${cfnRequest.PhysicalResourceId}" to "${onEventResult.PhysicalResourceId}" during deletion`); - } - // if we are in UPDATE and physical ID was changed, it's a replacement (just log) - if (cfnRequest.RequestType === 'Update' && physicalResourceId !== cfnRequest.PhysicalResourceId) { - (0, util_1.log)(`UPDATE: changing physical resource ID from "${cfnRequest.PhysicalResourceId}" to "${onEventResult.PhysicalResourceId}"`); - } - // merge request event and result event (result prevails). - return { - ...cfnRequest, - ...onEventResult, - PhysicalResourceId: physicalResourceId, - }; -} -/** - * Calculates the default physical resource ID based in case user handler did - * not return a PhysicalResourceId. - * - * For "CREATE", it uses the RequestId. - * For "UPDATE" and "DELETE" and returns the current PhysicalResourceId (the one provided in `event`). - */ -function defaultPhysicalResourceId(req) { - switch (req.RequestType) { - case 'Create': - return req.RequestId; - case 'Update': - case 'Delete': - return req.PhysicalResourceId; - default: - throw new Error(`Invalid "RequestType" in request "${JSON.stringify(req)}"`); - } -} -module.exports = { - [consts.FRAMEWORK_ON_EVENT_HANDLER_NAME]: cfnResponse.safeHandler(onEvent), - [consts.FRAMEWORK_IS_COMPLETE_HANDLER_NAME]: cfnResponse.safeHandler(isComplete), - [consts.FRAMEWORK_ON_TIMEOUT_HANDLER_NAME]: onTimeout, -}; -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZnJhbWV3b3JrLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiZnJhbWV3b3JrLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSw0QkFBNEI7QUFDNUIsK0JBQStCO0FBQy9CLDhDQUE4QztBQUM5QyxtQ0FBbUM7QUFDbkMseUNBQTREO0FBQzVELGlDQUFxQztBQVVy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JERUxFVEVcIiBhbmQgcmV0dXJucyB0aGUgY3VycmVudCBQaHlzaWNhbFJlc291cmNlSWQgKHRoZSBvbmUgcHJvdmlkZWQgaW4gYGV2ZW50YCkuXG4gKi9cbmZ1bmN0aW9uIGRlZmF1bHRQaHlzaWNhbFJlc291cmNlSWQocmVxOiBBV1NMYW1iZGEuQ2xvdWRGb3JtYXRpb25DdXN0b21SZXNvdXJjZUV2ZW50KTogc3RyaW5nIHtcbiAgc3dpdGNoIChyZXEuUmVxdWVzdFR5cGUpIHtcbiAgICBjYXNlICdDcmVhdGUnOlxuICAgICAgcmV0dXJuIHJlcS5SZXF1ZXN0SWQ7XG5cbiAgICBjYXNlICdVcGRhdGUnOlxuICAgIGNhc2UgJ0RlbGV0ZSc6XG4gICAgICByZXR1cm4gcmVxLlBoeXNpY2FsUmVzb3VyY2VJZDtcblxuICAgIGRlZmF1bHQ6XG4gICAgICB0aHJvdyBuZXcgRXJyb3IoYEludmFsaWQgXCJSZXF1ZXN0VHlwZVwiIGluIHJlcXVlc3QgXCIke0pTT04uc3RyaW5naWZ5KHJlcSl9XCJgKTtcbiAgfVxufVxuIl19 \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.73b60c2cf141bf58c33cfaa33858f5c84103a0232ba7192d696536488f7731c4/outbound.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.73b60c2cf141bf58c33cfaa33858f5c84103a0232ba7192d696536488f7731c4/outbound.js deleted file mode 100644 index 24158e35fffb2..0000000000000 --- a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.73b60c2cf141bf58c33cfaa33858f5c84103a0232ba7192d696536488f7731c4/outbound.js +++ /dev/null @@ -1,79 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.httpRequest = exports.invokeFunction = exports.startExecution = void 0; -/* istanbul ignore file */ -const https = require("https"); -// eslint-disable-next-line import/no-extraneous-dependencies -const client_lambda_1 = require("@aws-sdk/client-lambda"); -// eslint-disable-next-line import/no-extraneous-dependencies -const client_sfn_1 = require("@aws-sdk/client-sfn"); -// eslint-disable-next-line import/no-extraneous-dependencies -const FRAMEWORK_HANDLER_TIMEOUT = 900000; // 15 minutes -// In order to honor the overall maximum timeout set for the target process, -// the default 2 minutes from AWS SDK has to be overriden: -// https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#httpOptions-property -const awsSdkConfig = { - httpOptions: { timeout: FRAMEWORK_HANDLER_TIMEOUT }, -}; -async function defaultHttpRequest(options, responseBody) { - return new Promise((resolve, reject) => { - try { - const request = https.request(options, resolve); - request.on('error', reject); - request.write(responseBody); - request.end(); - } - catch (e) { - reject(e); - } - }); -} -let sfn; -let lambda; -async function defaultStartExecution(req) { - if (!sfn) { - sfn = new client_sfn_1.SFN(awsSdkConfig); - } - return sfn.startExecution(req); -} -async function defaultInvokeFunction(req) { - if (!lambda) { - lambda = new client_lambda_1.Lambda(awsSdkConfig); - } - try { - /** - * Try an initial invoke. - * - * When you try to invoke a function that is inactive, the invocation fails and Lambda sets - * the function to pending state until the function resources are recreated. - * If Lambda fails to recreate the resources, the function is set to the inactive state. - * - * We're using invoke first because `waitFor` doesn't trigger an inactive function to do anything, - * it just runs `getFunction` and checks the state. - */ - return await lambda.invoke(req); - } - catch { - /** - * The status of the Lambda function is checked every second for up to 300 seconds. - * Exits the loop on 'Active' state and throws an error on 'Inactive' or 'Failed'. - * - * And now we wait. - * - * Use functionActive instead of functionActiveV2, since functionActiveV2 is only - * available on SDK 2.1080.0 and up, Lambda installs 2.1055.0 by default, - * and we use the SDK version that Lambda includes by default. - */ - await (0, client_lambda_1.waitUntilFunctionActive)({ - client: lambda, - maxWaitTime: 60, - }, { - FunctionName: req.FunctionName, - }); - return await lambda.invoke(req); - } -} -exports.startExecution = defaultStartExecution; -exports.invokeFunction = defaultInvokeFunction; -exports.httpRequest = defaultHttpRequest; -//# sourceMappingURL=data:application/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mRhIGluc3RhbGxzIDIuMTA1NS4wIGJ5IGRlZmF1bHQsXG4gICAgICogYW5kIHdlIHVzZSB0aGUgU0RLIHZlcnNpb24gdGhhdCBMYW1iZGEgaW5jbHVkZXMgYnkgZGVmYXVsdC5cbiAgICAgKi9cbiAgICBhd2FpdCB3YWl0VW50aWxGdW5jdGlvbkFjdGl2ZSh7XG4gICAgICBjbGllbnQ6IGxhbWJkYSxcbiAgICAgIG1heFdhaXRUaW1lOiA2MCxcbiAgICB9LCB7XG4gICAgICBGdW5jdGlvbk5hbWU6IHJlcS5GdW5jdGlvbk5hbWUsXG4gICAgfSk7XG4gICAgcmV0dXJuIGF3YWl0IGxhbWJkYS5pbnZva2UocmVxKTtcbiAgfVxufVxuXG5leHBvcnQgbGV0IHN0YXJ0RXhlY3V0aW9uID0gZGVmYXVsdFN0YXJ0RXhlY3V0aW9uO1xuZXhwb3J0IGxldCBpbnZva2VGdW5jdGlvbiA9IGRlZmF1bHRJbnZva2VGdW5jdGlvbjtcbmV4cG9ydCBsZXQgaHR0cFJlcXVlc3QgPSBkZWZhdWx0SHR0cFJlcXVlc3Q7XG4iXX0= \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.73b60c2cf141bf58c33cfaa33858f5c84103a0232ba7192d696536488f7731c4/util.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.73b60c2cf141bf58c33cfaa33858f5c84103a0232ba7192d696536488f7731c4/util.js deleted file mode 100644 index f09276d40ac91..0000000000000 --- a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.73b60c2cf141bf58c33cfaa33858f5c84103a0232ba7192d696536488f7731c4/util.js +++ /dev/null @@ -1,39 +0,0 @@ -"use strict"; -/* eslint-disable no-console */ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.withRetries = exports.log = exports.getEnv = void 0; -function getEnv(name) { - const value = process.env[name]; - if (!value) { - throw new Error(`The environment variable "${name}" is not defined`); - } - return value; -} -exports.getEnv = getEnv; -function log(title, ...args) { - console.log('[provider-framework]', title, ...args.map(x => typeof (x) === 'object' ? JSON.stringify(x, undefined, 2) : x)); -} -exports.log = log; -function withRetries(options, fn) { - return async (...xs) => { - let attempts = options.attempts; - let ms = options.sleep; - while (true) { - try { - return await fn(...xs); - } - catch (e) { - if (attempts-- <= 0) { - throw e; - } - await sleep(Math.floor(Math.random() * ms)); - ms *= 2; - } - } - }; -} -exports.withRetries = withRetries; -async function sleep(ms) { - return new Promise((ok) => setTimeout(ok, ms)); -} -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInV0aWwudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLCtCQUErQjs7O0FBRS9CLFNBQWdCLE1BQU0sQ0FBQyxJQUFZO0lBQ2pDLE1BQU0sS0FBSyxHQUFHLE9BQU8sQ0FBQyxHQUFHLENBQUMsSUFBSSxDQUFDLENBQUM7SUFDaEMsSUFBSSxDQUFDLEtBQUssRUFBRTtRQUNWLE1BQU0sSUFBSSxLQUFLLENBQUMsNkJBQTZCLElBQUksa0JBQWtCLENBQUMsQ0FBQztLQUN0RTtJQUNELE9BQU8sS0FBSyxDQUFDO0FBQ2YsQ0FBQztBQU5ELHdCQU1DO0FBRUQsU0FBZ0IsR0FBRyxDQUFDLEtBQVUsRUFBRSxHQUFHLElBQVc7SUFDNUMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxzQkFBc0IsRUFBRSxLQUFLLEVBQUUsR0FBRyxJQUFJLENBQUMsR0FBRyxDQUFDLENBQUMsQ0FBQyxFQUFFLENBQUMsT0FBTSxDQUFDLENBQUMsQ0FBQyxLQUFLLFFBQVEsQ0FBQyxDQUFDLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxDQUFDLEVBQUUsU0FBUyxFQUFFLENBQUMsQ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gZm4oLi4ueHMpO1xuICAgICAgfSBjYXRjaCAoZSkge1xuICAgICAgICBpZiAoYXR0ZW1wdHMtLSA8PSAwKSB7XG4gICAgICAgICAgdGhyb3cgZTtcbiAgICAgICAgfVxuICAgICAgICBhd2FpdCBzbGVlcChNYXRoLmZsb29yKE1hdGgucmFuZG9tKCkgKiBtcykpO1xuICAgICAgICBtcyAqPSAyO1xuICAgICAgfVxuICAgIH1cbiAgfTtcbn1cblxuYXN5bmMgZnVuY3Rpb24gc2xlZXAobXM6IG51bWJlcik6IFByb21pc2U8dm9pZD4ge1xuICByZXR1cm4gbmV3IFByb21pc2UoKG9rKSA9PiBzZXRUaW1lb3V0KG9rLCBtcykpO1xufSJdfQ== \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322/privileges.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322/privileges.js deleted file mode 100644 index 22d622acfbd79..0000000000000 --- a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322/privileges.js +++ /dev/null @@ -1,69 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.handler = void 0; -const redshift_data_1 = require("./redshift-data"); -const util_1 = require("./util"); -async function handler(props, event) { - const username = props.username; - const tablePrivileges = props.tablePrivileges; - const clusterProps = props; - if (event.RequestType === 'Create') { - await grantPrivileges(username, tablePrivileges, clusterProps); - return { PhysicalResourceId: (0, util_1.makePhysicalId)(username, clusterProps, event.RequestId) }; - } - else if (event.RequestType === 'Delete') { - await revokePrivileges(username, tablePrivileges, clusterProps); - return; - } - else if (event.RequestType === 'Update') { - const { replace } = await updatePrivileges(username, tablePrivileges, clusterProps, event.OldResourceProperties); - const physicalId = replace ? (0, util_1.makePhysicalId)(username, clusterProps, event.RequestId) : event.PhysicalResourceId; - return { PhysicalResourceId: physicalId }; - } - else { - /* eslint-disable-next-line dot-notation */ - throw new Error(`Unrecognized event type: ${event['RequestType']}`); - } -} -exports.handler = handler; -async function revokePrivileges(username, tablePrivileges, clusterProps) { - await Promise.all(tablePrivileges.map(({ tableName, actions }) => { - return (0, redshift_data_1.executeStatement)(`REVOKE ${actions.join(', ')} ON ${tableName} FROM ${username}`, clusterProps); - })); -} -async function grantPrivileges(username, tablePrivileges, clusterProps) { - await Promise.all(tablePrivileges.map(({ tableName, actions }) => { - return (0, redshift_data_1.executeStatement)(`GRANT ${actions.join(', ')} ON ${tableName} TO ${username}`, clusterProps); - })); -} -async function updatePrivileges(username, tablePrivileges, clusterProps, oldResourceProperties) { - const oldClusterProps = oldResourceProperties; - if (clusterProps.clusterName !== oldClusterProps.clusterName || clusterProps.databaseName !== oldClusterProps.databaseName) { - await grantPrivileges(username, tablePrivileges, clusterProps); - return { replace: true }; - } - const oldUsername = oldResourceProperties.username; - if (oldUsername !== username) { - await grantPrivileges(username, tablePrivileges, clusterProps); - return { replace: true }; - } - const oldTablePrivileges = oldResourceProperties.tablePrivileges; - const tablesToRevoke = oldTablePrivileges.filter(({ tableId, actions }) => { - const tableRemoved = !tablePrivileges.find(({ tableId: otherTableId }) => tableId === otherTableId); - const actionsRemoved = tablePrivileges.find(({ tableId: otherTableId, actions: otherActions }) => (tableId === otherTableId && actions.some(action => !otherActions.includes(action)))); - return tableRemoved || actionsRemoved; - }); - if (tablesToRevoke.length > 0) { - await revokePrivileges(username, tablesToRevoke, clusterProps); - } - const tablesToGrant = tablePrivileges.filter(({ tableId, tableName, actions }) => { - const tableAdded = !oldTablePrivileges.find(({ tableId: otherTableId, tableName: otherTableName }) => (tableId === otherTableId && tableName === otherTableName)); - const actionsAdded = oldTablePrivileges.find(({ tableId: otherTableId, actions: otherActions }) => (tableId === otherTableId && otherActions.some(action => !actions.includes(action)))); - return tableAdded || actionsAdded; - }); - if (tablesToGrant.length > 0) { - await grantPrivileges(username, tablesToGrant, clusterProps); - } - return { replace: false }; -} -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJpdmlsZWdlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInByaXZpbGVnZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBRUEsbURBQW1EO0FBRW5ELGlDQUF3QztBQUdqQyxLQUFLLFVBQVUsT0FBTyxDQUFDLEtBQXFELEVBQUUsS0FBa0Q7SUFDckksTUFBTSxRQUFRLEdBQUcsS0FBSyxDQUFDLFFBQVEsQ0FBQztJQUNoQyxNQUFNLGVBQWUsR0FBRyxLQUFLLENBQUMsZUFBZSxDQUFDO0lBQzlDLE1BQU0sWUFBWSxHQUFHLEtBQUssQ0FBQztJQUUzQixJQUFJLEtBQUssQ0FBQyxXQUFXLEtBQUssUUFBUSxFQUFFO1FBQ2xDLE1BQU0sZUFBZSxDQUFDLFFBQVEsRUFBRSxlQUFlLEVBQUUsWUFBWSxDQUFDLENBQUM7UUFDL0QsT0FBTyxFQUFFLGtCQUFrQixFQUFFLElBQUEscUJBQWMsRUFBQyxRQUFRLEVBQUUsWUFBWSxFQUFFLEtBQUssQ0FBQyxTQUFTLENBQUMsRUFBRSxDQUFDO0tBQ3hGO1NBQU0sSUFBSSxLQUFLLENBQUMsV0FBVyxLQUFLLFFBQVEsRUFBRTtRQUN6QyxNQUFNLGdCQUFnQixDQUFDLFFBQVEsRUFBRSxlQUFlLEVBQUUsWUFBWSxDQUFDLENBQUM7UUFDaEUsT0FBTztLQUNSO1NBQU0sSUFBSSxLQUFLLENBQUMsV0FBVyxLQUFLLFFBQVEsRUFBRTtRQUN6QyxNQUFNLEVBQUUsT0FBTyxFQUFFLEdBQUcsTUFBTSxnQkFBZ0IsQ0FDeEMsUUFBUSxFQUNSLG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hbWUgfSkgPT4gKFxuICAgICAgdGFibGVJZCA9PT0gb3RoZXJUYWJsZUlkICYmIHRhYmxlTmFtZSA9PT0gb3RoZXJUYWJsZU5hbWVcbiAgICApKTtcbiAgICBjb25zdCBhY3Rpb25zQWRkZWQgPSBvbGRUYWJsZVByaXZpbGVnZXMuZmluZCgoeyB0YWJsZUlkOiBvdGhlclRhYmxlSWQsIGFjdGlvbnM6IG90aGVyQWN0aW9ucyB9KSA9PiAoXG4gICAgICB0YWJsZUlkID09PSBvdGhlclRhYmxlSWQgJiYgb3RoZXJBY3Rpb25zLnNvbWUoYWN0aW9uID0+ICFhY3Rpb25zLmluY2x1ZGVzKGFjdGlvbikpXG4gICAgKSk7XG4gICAgcmV0dXJuIHRhYmxlQWRkZWQgfHwgYWN0aW9uc0FkZGVkO1xuICB9KTtcbiAgaWYgKHRhYmxlc1RvR3JhbnQubGVuZ3RoID4gMCkge1xuICAgIGF3YWl0IGdyYW50UHJpdmlsZWdlcyh1c2VybmFtZSwgdGFibGVzVG9HcmFudCwgY2x1c3RlclByb3BzKTtcbiAgfVxuXG4gIHJldHVybiB7IHJlcGxhY2U6IGZhbHNlIH07XG59XG4iXX0= \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.73b60c2cf141bf58c33cfaa33858f5c84103a0232ba7192d696536488f7731c4/cfn-response.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.d002370061965c69bc4caf15dddb5eccc9df318933ade6e4fa57cddb81c5abef/cfn-response.js similarity index 100% rename from packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.73b60c2cf141bf58c33cfaa33858f5c84103a0232ba7192d696536488f7731c4/cfn-response.js rename to packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.d002370061965c69bc4caf15dddb5eccc9df318933ade6e4fa57cddb81c5abef/cfn-response.js diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.73b60c2cf141bf58c33cfaa33858f5c84103a0232ba7192d696536488f7731c4/consts.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.d002370061965c69bc4caf15dddb5eccc9df318933ade6e4fa57cddb81c5abef/consts.js similarity index 100% rename from packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.73b60c2cf141bf58c33cfaa33858f5c84103a0232ba7192d696536488f7731c4/consts.js rename to packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.d002370061965c69bc4caf15dddb5eccc9df318933ade6e4fa57cddb81c5abef/consts.js diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.d002370061965c69bc4caf15dddb5eccc9df318933ade6e4fa57cddb81c5abef/framework.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.d002370061965c69bc4caf15dddb5eccc9df318933ade6e4fa57cddb81c5abef/framework.js new file mode 100644 index 0000000000000..206ebc66fe0df --- /dev/null +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.d002370061965c69bc4caf15dddb5eccc9df318933ade6e4fa57cddb81c5abef/framework.js @@ -0,0 +1,161 @@ +"use strict"; +/* eslint-disable max-len */ +/* eslint-disable no-console */ +const cfnResponse = require("./cfn-response"); +const consts = require("./consts"); +const outbound_1 = require("./outbound"); +const util_1 = require("./util"); +/** + * The main runtime entrypoint of the async custom resource lambda function. + * + * Any lifecycle event changes to the custom resources will invoke this handler, which will, in turn, + * interact with the user-defined `onEvent` and `isComplete` handlers. + * + * This function will always succeed. If an error occurs + * + * @param cfnRequest The cloudformation custom resource event. + */ +async function onEvent(cfnRequest) { + const sanitizedRequest = { ...cfnRequest, ResponseURL: '...' }; + (0, util_1.log)('onEventHandler', sanitizedRequest); + cfnRequest.ResourceProperties = cfnRequest.ResourceProperties || {}; + const onEventResult = await invokeUserFunction(consts.USER_ON_EVENT_FUNCTION_ARN_ENV, sanitizedRequest, cfnRequest.ResponseURL); + (0, util_1.log)('onEvent returned:', onEventResult); + // merge the request and the result from onEvent to form the complete resource event + // this also performs validation. + const resourceEvent = createResponseEvent(cfnRequest, onEventResult); + (0, util_1.log)('event:', onEventResult); + // determine if this is an async provider based on whether we have an isComplete handler defined. + // if it is not defined, then we are basically ready to return a positive response. + if (!process.env[consts.USER_IS_COMPLETE_FUNCTION_ARN_ENV]) { + return cfnResponse.submitResponse('SUCCESS', resourceEvent, { noEcho: resourceEvent.NoEcho }); + } + // ok, we are not complete, so kick off the waiter workflow + const waiter = { + stateMachineArn: (0, util_1.getEnv)(consts.WAITER_STATE_MACHINE_ARN_ENV), + name: resourceEvent.RequestId, + input: JSON.stringify(resourceEvent), + }; + (0, util_1.log)('starting waiter', waiter); + // kick off waiter state machine + await (0, outbound_1.startExecution)(waiter); +} +// invoked a few times until `complete` is true or until it times out. +async function isComplete(event) { + const sanitizedRequest = { ...event, ResponseURL: '...' }; + (0, util_1.log)('isComplete', sanitizedRequest); + const isCompleteResult = await invokeUserFunction(consts.USER_IS_COMPLETE_FUNCTION_ARN_ENV, sanitizedRequest, event.ResponseURL); + (0, util_1.log)('user isComplete returned:', isCompleteResult); + // if we are not complete, return false, and don't send a response back. + if (!isCompleteResult.IsComplete) { + if (isCompleteResult.Data && Object.keys(isCompleteResult.Data).length > 0) { + throw new Error('"Data" is not allowed if "IsComplete" is "False"'); + } + // This must be the full event, it will be deserialized in `onTimeout` to send the response to CloudFormation + throw new cfnResponse.Retry(JSON.stringify(event)); + } + const response = { + ...event, + ...isCompleteResult, + Data: { + ...event.Data, + ...isCompleteResult.Data, + }, + }; + await cfnResponse.submitResponse('SUCCESS', response, { noEcho: event.NoEcho }); +} +// invoked when completion retries are exhaused. +async function onTimeout(timeoutEvent) { + (0, util_1.log)('timeoutHandler', timeoutEvent); + const isCompleteRequest = JSON.parse(JSON.parse(timeoutEvent.Cause).errorMessage); + await cfnResponse.submitResponse('FAILED', isCompleteRequest, { + reason: 'Operation timed out', + }); +} +async function invokeUserFunction(functionArnEnv, sanitizedPayload, responseUrl) { + const functionArn = (0, util_1.getEnv)(functionArnEnv); + (0, util_1.log)(`executing user function ${functionArn} with payload`, sanitizedPayload); + // transient errors such as timeouts, throttling errors (429), and other + // errors that aren't caused by a bad request (500 series) are retried + // automatically by the JavaScript SDK. + const resp = await (0, outbound_1.invokeFunction)({ + FunctionName: functionArn, + // Cannot strip 'ResponseURL' here as this would be a breaking change even though the downstream CR doesn't need it + Payload: JSON.stringify({ ...sanitizedPayload, ResponseURL: responseUrl }), + }); + (0, util_1.log)('user function response:', resp, typeof (resp)); + // ParseJsonPayload is very defensive. It should not be possible for `Payload` + // to be anything other than a JSON encoded string (or intarray). Something weird is + // going on if that happens. Still, we should do our best to survive it. + const jsonPayload = (0, util_1.parseJsonPayload)(resp.Payload); + if (resp.FunctionError) { + (0, util_1.log)('user function threw an error:', resp.FunctionError); + const errorMessage = jsonPayload.errorMessage || 'error'; + // parse function name from arn + // arn:${Partition}:lambda:${Region}:${Account}:function:${FunctionName} + const arn = functionArn.split(':'); + const functionName = arn[arn.length - 1]; + // append a reference to the log group. + const message = [ + errorMessage, + '', + `Logs: /aws/lambda/${functionName}`, + '', + ].join('\n'); + const e = new Error(message); + // the output that goes to CFN is what's in `stack`, not the error message. + // if we have a remote trace, construct a nice message with log group information + if (jsonPayload.trace) { + // skip first trace line because it's the message + e.stack = [message, ...jsonPayload.trace.slice(1)].join('\n'); + } + throw e; + } + return jsonPayload; +} +function createResponseEvent(cfnRequest, onEventResult) { + // + // validate that onEventResult always includes a PhysicalResourceId + onEventResult = onEventResult || {}; + // if physical ID is not returned, we have some defaults for you based + // on the request type. + const physicalResourceId = onEventResult.PhysicalResourceId || defaultPhysicalResourceId(cfnRequest); + // if we are in DELETE and physical ID was changed, it's an error. + if (cfnRequest.RequestType === 'Delete' && physicalResourceId !== cfnRequest.PhysicalResourceId) { + throw new Error(`DELETE: cannot change the physical resource ID from "${cfnRequest.PhysicalResourceId}" to "${onEventResult.PhysicalResourceId}" during deletion`); + } + // if we are in UPDATE and physical ID was changed, it's a replacement (just log) + if (cfnRequest.RequestType === 'Update' && physicalResourceId !== cfnRequest.PhysicalResourceId) { + (0, util_1.log)(`UPDATE: changing physical resource ID from "${cfnRequest.PhysicalResourceId}" to "${onEventResult.PhysicalResourceId}"`); + } + // merge request event and result event (result prevails). + return { + ...cfnRequest, + ...onEventResult, + PhysicalResourceId: physicalResourceId, + }; +} +/** + * Calculates the default physical resource ID based in case user handler did + * not return a PhysicalResourceId. + * + * For "CREATE", it uses the RequestId. + * For "UPDATE" and "DELETE" and returns the current PhysicalResourceId (the one provided in `event`). + */ +function defaultPhysicalResourceId(req) { + switch (req.RequestType) { + case 'Create': + return req.RequestId; + case 'Update': + case 'Delete': + return req.PhysicalResourceId; + default: + throw new Error(`Invalid "RequestType" in request "${JSON.stringify(req)}"`); + } +} +module.exports = { + [consts.FRAMEWORK_ON_EVENT_HANDLER_NAME]: cfnResponse.safeHandler(onEvent), + [consts.FRAMEWORK_IS_COMPLETE_HANDLER_NAME]: cfnResponse.safeHandler(isComplete), + [consts.FRAMEWORK_ON_TIMEOUT_HANDLER_NAME]: onTimeout, +}; +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZnJhbWV3b3JrLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiZnJhbWV3b3JrLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSw0QkFBNEI7QUFDNUIsK0JBQStCO0FBQy9CLDhDQUE4QztBQUM5QyxtQ0FBbUM7QUFDbkMseUNBQTREO0FBQzVELGlDQUF1RDtBQVV2RDs7Ozs7Ozs7O0dBU0c7QUFDSCxLQUFLLFVBQVUsT0FBTyxDQUFDLFVBQXVEO0lBQzVFLE1BQU0sZ0JBQWdCLEdBQUcsRUFBRSxHQUFHLFVBQVUsRUFBRSxXQUFXLEVBQUUsS0FBSyxFQUFXL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5c2ljYWxSZXNvdXJjZUlkLFxuICB9O1xufVxuXG4vKipcbiAqIENhbGN1bGF0ZXMgdGhlIGRlZmF1bHQgcGh5c2ljYWwgcmVzb3VyY2UgSUQgYmFzZWQgaW4gY2FzZSB1c2VyIGhhbmRsZXIgZGlkXG4gKiBub3QgcmV0dXJuIGEgUGh5c2ljYWxSZXNvdXJjZUlkLlxuICpcbiAqIEZvciBcIkNSRUFURVwiLCBpdCB1c2VzIHRoZSBSZXF1ZXN0SWQuXG4gKiBGb3IgXCJVUERBVEVcIiBhbmQgXCJERUxFVEVcIiBhbmQgcmV0dXJucyB0aGUgY3VycmVudCBQaHlzaWNhbFJlc291cmNlSWQgKHRoZSBvbmUgcHJvdmlkZWQgaW4gYGV2ZW50YCkuXG4gKi9cbmZ1bmN0aW9uIGRlZmF1bHRQaHlzaWNhbFJlc291cmNlSWQocmVxOiBBV1NMYW1iZGEuQ2xvdWRGb3JtYXRpb25DdXN0b21SZXNvdXJjZUV2ZW50KTogc3RyaW5nIHtcbiAgc3dpdGNoIChyZXEuUmVxdWVzdFR5cGUpIHtcbiAgICBjYXNlICdDcmVhdGUnOlxuICAgICAgcmV0dXJuIHJlcS5SZXF1ZXN0SWQ7XG5cbiAgICBjYXNlICdVcGRhdGUnOlxuICAgIGNhc2UgJ0RlbGV0ZSc6XG4gICAgICByZXR1cm4gcmVxLlBoeXNpY2FsUmVzb3VyY2VJZDtcblxuICAgIGRlZmF1bHQ6XG4gICAgICB0aHJvdyBuZXcgRXJyb3IoYEludmFsaWQgXCJSZXF1ZXN0VHlwZVwiIGluIHJlcXVlc3QgXCIke0pTT04uc3RyaW5naWZ5KHJlcSl9XCJgKTtcbiAgfVxufVxuIl19 \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.d002370061965c69bc4caf15dddb5eccc9df318933ade6e4fa57cddb81c5abef/outbound.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.d002370061965c69bc4caf15dddb5eccc9df318933ade6e4fa57cddb81c5abef/outbound.js new file mode 100644 index 0000000000000..8ade7c5c96c6e --- /dev/null +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.d002370061965c69bc4caf15dddb5eccc9df318933ade6e4fa57cddb81c5abef/outbound.js @@ -0,0 +1,75 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.httpRequest = exports.invokeFunction = exports.startExecution = void 0; +/* istanbul ignore file */ +const https = require("https"); +// eslint-disable-next-line import/no-extraneous-dependencies +const client_lambda_1 = require("@aws-sdk/client-lambda"); +// eslint-disable-next-line import/no-extraneous-dependencies +const client_sfn_1 = require("@aws-sdk/client-sfn"); +// eslint-disable-next-line import/no-extraneous-dependencies +const FRAMEWORK_HANDLER_TIMEOUT = 900000; // 15 minutes +// In order to honor the overall maximum timeout set for the target process, +// the default 2 minutes from AWS SDK has to be overriden: +// https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#httpOptions-property +const awsSdkConfig = { + httpOptions: { timeout: FRAMEWORK_HANDLER_TIMEOUT }, +}; +async function defaultHttpRequest(options, responseBody) { + return new Promise((resolve, reject) => { + try { + const request = https.request(options, resolve); + request.on('error', reject); + request.write(responseBody); + request.end(); + } + catch (e) { + reject(e); + } + }); +} +let sfn; +let lambda; +async function defaultStartExecution(req) { + if (!sfn) { + sfn = new client_sfn_1.SFN(awsSdkConfig); + } + return sfn.startExecution(req); +} +async function defaultInvokeFunction(req) { + if (!lambda) { + lambda = new client_lambda_1.Lambda(awsSdkConfig); + } + try { + /** + * Try an initial invoke. + * + * When you try to invoke a function that is inactive, the invocation fails and Lambda sets + * the function to pending state until the function resources are recreated. + * If Lambda fails to recreate the resources, the function is set to the inactive state. + * + * We're using invoke first because `waitFor` doesn't trigger an inactive function to do anything, + * it just runs `getFunction` and checks the state. + */ + return await lambda.invoke(req); + } + catch { + /** + * The status of the Lambda function is checked every second for up to 300 seconds. + * Exits the loop on 'Active' state and throws an error on 'Inactive' or 'Failed'. + * + * And now we wait. + */ + await (0, client_lambda_1.waitUntilFunctionActiveV2)({ + client: lambda, + maxWaitTime: 300, + }, { + FunctionName: req.FunctionName, + }); + return await lambda.invoke(req); + } +} +exports.startExecution = defaultStartExecution; +exports.invokeFunction = defaultInvokeFunction; +exports.httpRequest = defaultHttpRequest; +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3V0Ym91bmQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJvdXRib3VuZC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSwwQkFBMEI7QUFDMUIsK0JBQStCO0FBQy9CLDZEQUE2RDtBQUM3RCwwREFBbUg7QUFDbkgsNkRBQTZEO0FBQzdELG9EQUFxRjtBQUNyRiw2REFBNkQ7QUFFN0QsTUFBTSx5QkFBeUIsR0FBRyxNQUFNLENBQUMsQ0FBQyxhQUFhO0FBRXZELDRFQUE0RTtBQUM1RSwwREFBMEQ7QUFDMUQsMkZBQTJGO0FBQzNGLE1BQU0sWUFBWSxHQUFHO0lBQ25CLFdBQVcsRUFBRSxFQUFFLE9BQU8sRUFBRSx5QkFBeUIsRUFBRTtDQUNwRCxDQUFDO0FBRUYsS0FBSyxVQUFVLGtCQUFrQixDQUFDLE9BQTZCLEVBQUUsWUFBb0I7SUFDbkYsT0FBTyxJQUFJLE9BQU8sQ0FBQyxDQUFDLE9BQU8sRUFBRSxNQUFNLEVBQUUsRUFBRTtRQUNyQyxJQUFJO1lBQ0YsTUFBTSxPQUFPLEdBQUcsS0FBSyxDQUFDLE9BQU8sQ0FBQyxPQUFPLEVBQUUsT0FBTyxDQUFDLENBQUM7WUFDaEQsT0FBTyxDQUFDLEVBQUUsQ0FBQyxPQUFPLEVBQUUsTUFBTSxDQUFDLENBQUM7WUFDNUIsT0FBTyxDQUFDLEtBQUssQ0FBQyxZQUFZLENBQUMsQ0FBQztZQUM1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2Ugd2FpdC5cbiAgICAgKi9cbiAgICBhd2FpdCB3YWl0VW50aWxGdW5jdGlvbkFjdGl2ZVYyKHtcbiAgICAgIGNsaWVudDogbGFtYmRhLFxuICAgICAgbWF4V2FpdFRpbWU6IDMwMCxcbiAgICB9LCB7XG4gICAgICBGdW5jdGlvbk5hbWU6IHJlcS5GdW5jdGlvbk5hbWUsXG4gICAgfSk7XG4gICAgcmV0dXJuIGF3YWl0IGxhbWJkYS5pbnZva2UocmVxKTtcbiAgfVxufVxuXG5leHBvcnQgbGV0IHN0YXJ0RXhlY3V0aW9uID0gZGVmYXVsdFN0YXJ0RXhlY3V0aW9uO1xuZXhwb3J0IGxldCBpbnZva2VGdW5jdGlvbiA9IGRlZmF1bHRJbnZva2VGdW5jdGlvbjtcbmV4cG9ydCBsZXQgaHR0cFJlcXVlc3QgPSBkZWZhdWx0SHR0cFJlcXVlc3Q7XG4iXX0= \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.d002370061965c69bc4caf15dddb5eccc9df318933ade6e4fa57cddb81c5abef/util.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.d002370061965c69bc4caf15dddb5eccc9df318933ade6e4fa57cddb81c5abef/util.js new file mode 100644 index 0000000000000..71cfc7970bf79 --- /dev/null +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.d002370061965c69bc4caf15dddb5eccc9df318933ade6e4fa57cddb81c5abef/util.js @@ -0,0 +1,54 @@ +"use strict"; +/* eslint-disable no-console */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.parseJsonPayload = exports.withRetries = exports.log = exports.getEnv = void 0; +function getEnv(name) { + const value = process.env[name]; + if (!value) { + throw new Error(`The environment variable "${name}" is not defined`); + } + return value; +} +exports.getEnv = getEnv; +function log(title, ...args) { + console.log('[provider-framework]', title, ...args.map(x => typeof (x) === 'object' ? JSON.stringify(x, undefined, 2) : x)); +} +exports.log = log; +function withRetries(options, fn) { + return async (...xs) => { + let attempts = options.attempts; + let ms = options.sleep; + while (true) { + try { + return await fn(...xs); + } + catch (e) { + if (attempts-- <= 0) { + throw e; + } + await sleep(Math.floor(Math.random() * ms)); + ms *= 2; + } + } + }; +} +exports.withRetries = withRetries; +async function sleep(ms) { + return new Promise((ok) => setTimeout(ok, ms)); +} +function parseJsonPayload(payload) { + // sdk v3 returns payloads in Uint8Array, either it or a string or Buffer + // can be cast into a buffer and then decoded. + const text = new TextDecoder().decode(Buffer.from(payload ?? '')); + if (!text) { + return {}; + } + try { + return JSON.parse(text); + } + catch { + throw new Error(`return values from user-handlers must be JSON objects. got: "${text}"`); + } +} +exports.parseJsonPayload = parseJsonPayload; +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInV0aWwudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLCtCQUErQjs7O0FBRS9CLFNBQWdCLE1BQU0sQ0FBQyxJQUFZO0lBQ2pDLE1BQU0sS0FBSyxHQUFHLE9BQU8sQ0FBQyxHQUFHLENBQUMsSUFBSSxDQUFDLENBQUM7SUFDaEMsSUFBSSxDQUFDLEtBQUssRUFBRTtRQUNWLE1BQU0sSUFBSSxLQUFLLENBQUMsNkJBQTZCLElBQUksa0JBQWtCLENBQUMsQ0FBQztLQUN0RTtJQUNELE9BQU8sS0FBSyxDQUFDO0FBQ2YsQ0FBQztBQU5ELHdCQU1DO0FBRUQsU0FBZ0IsR0FBRyxDQUFDLEtBQVUsRUFBRSxHQUFHLElBQVc7SUFDNUMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxzQkFBc0IsRUFBRSxLQUFLLEVBQUUsR0FBRyxJQUFJLENBQUMsR0FBRyxDQUFDLENBQUMsQ0FBQyxFQUFFLENBQUMsT0FBTSxDQUFDLENBQUMsQ0FBQyxLQUFLLFFBQVEs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CB8IG51bGwpOiBhbnkge1xuICAvLyBzZGsgdjMgcmV0dXJucyBwYXlsb2FkcyBpbiBVaW50OEFycmF5LCBlaXRoZXIgaXQgb3IgYSBzdHJpbmcgb3IgQnVmZmVyXG4gIC8vIGNhbiBiZSBjYXN0IGludG8gYSBidWZmZXIgYW5kIHRoZW4gZGVjb2RlZC5cbiAgY29uc3QgdGV4dCA9IG5ldyBUZXh0RGVjb2RlcigpLmRlY29kZShCdWZmZXIuZnJvbShwYXlsb2FkID8/ICcnKSk7XG4gIGlmICghdGV4dCkgeyByZXR1cm4geyB9OyB9XG4gIHRyeSB7XG4gICAgcmV0dXJuIEpTT04ucGFyc2UodGV4dCk7XG4gIH0gY2F0Y2gge1xuICAgIHRocm93IG5ldyBFcnJvcihgcmV0dXJuIHZhbHVlcyBmcm9tIHVzZXItaGFuZGxlcnMgbXVzdCBiZSBKU09OIG9iamVjdHMuIGdvdDogXCIke3RleHR9XCJgKTtcbiAgfVxufVxuIl19 \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322/handler-name.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.e275fde8d2a03c793e28878ff6a48e84af45d2655f0c79418b5b86f2add826f7/handler-name.js similarity index 100% rename from packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322/handler-name.js rename to packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.e275fde8d2a03c793e28878ff6a48e84af45d2655f0c79418b5b86f2add826f7/handler-name.js diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322/index.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.e275fde8d2a03c793e28878ff6a48e84af45d2655f0c79418b5b86f2add826f7/index.js similarity index 100% rename from packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322/index.js rename to packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.e275fde8d2a03c793e28878ff6a48e84af45d2655f0c79418b5b86f2add826f7/index.js diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.e275fde8d2a03c793e28878ff6a48e84af45d2655f0c79418b5b86f2add826f7/privileges.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.e275fde8d2a03c793e28878ff6a48e84af45d2655f0c79418b5b86f2add826f7/privileges.js new file mode 100644 index 0000000000000..d31e8d047ed05 --- /dev/null +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.e275fde8d2a03c793e28878ff6a48e84af45d2655f0c79418b5b86f2add826f7/privileges.js @@ -0,0 +1,65 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.handler = void 0; +const redshift_data_1 = require("./redshift-data"); +const util_1 = require("./util"); +async function handler(props, event) { + const username = props.username; + const tablePrivileges = props.tablePrivileges; + const clusterProps = props; + if (event.RequestType === 'Create') { + await grantPrivileges(username, tablePrivileges, clusterProps); + return { PhysicalResourceId: (0, util_1.makePhysicalId)(username, clusterProps, event.RequestId) }; + } + else if (event.RequestType === 'Delete') { + await revokePrivileges(username, tablePrivileges, clusterProps); + return; + } + else if (event.RequestType === 'Update') { + const { replace } = await updatePrivileges(username, tablePrivileges, clusterProps, event.OldResourceProperties); + const physicalId = replace ? (0, util_1.makePhysicalId)(username, clusterProps, event.RequestId) : event.PhysicalResourceId; + return { PhysicalResourceId: physicalId }; + } + else { + /* eslint-disable-next-line dot-notation */ + throw new Error(`Unrecognized event type: ${event['RequestType']}`); + } +} +exports.handler = handler; +async function revokePrivileges(username, tablePrivileges, clusterProps) { + await Promise.all(tablePrivileges.map(({ tableName, actions }) => { + return (0, redshift_data_1.executeStatement)(`REVOKE ${actions.join(', ')} ON ${tableName} FROM ${username}`, clusterProps); + })); +} +async function grantPrivileges(username, tablePrivileges, clusterProps) { + await Promise.all(tablePrivileges.map(({ tableName, actions }) => { + return (0, redshift_data_1.executeStatement)(`GRANT ${actions.join(', ')} ON ${tableName} TO ${username}`, clusterProps); + })); +} +async function updatePrivileges(username, tablePrivileges, clusterProps, oldResourceProperties) { + const oldClusterProps = oldResourceProperties; + if (clusterProps.clusterName !== oldClusterProps.clusterName || clusterProps.databaseName !== oldClusterProps.databaseName) { + await grantPrivileges(username, tablePrivileges, clusterProps); + return { replace: true }; + } + const oldUsername = oldResourceProperties.username; + if (oldUsername !== username) { + await grantPrivileges(username, tablePrivileges, clusterProps); + return { replace: true }; + } + const oldTablePrivileges = oldResourceProperties.tablePrivileges; + const tablesToRevoke = oldTablePrivileges.filter(({ tableId, actions }) => (tablePrivileges.find(({ tableId: otherTableId, actions: otherActions }) => (tableId === otherTableId && actions.some(action => !otherActions.includes(action)))))); + if (tablesToRevoke.length > 0) { + await revokePrivileges(username, tablesToRevoke, clusterProps); + } + const tablesToGrant = tablePrivileges.filter(({ tableId, tableName, actions }) => { + const tableAdded = !oldTablePrivileges.find(({ tableId: otherTableId, tableName: otherTableName }) => (tableId === otherTableId && tableName === otherTableName)); + const actionsAdded = oldTablePrivileges.find(({ tableId: otherTableId, actions: otherActions }) => (tableId === otherTableId && otherActions.some(action => !actions.includes(action)))); + return tableAdded || actionsAdded; + }); + if (tablesToGrant.length > 0) { + await grantPrivileges(username, tablesToGrant, clusterProps); + } + return { replace: false }; +} +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJpdmlsZWdlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInByaXZpbGVnZXMudHMiXSwibmFtZXMiOltdLCJtY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7XG4gICAgYXdhaXQgcmV2b2tlUHJpdmlsZWdlcyh1c2VybmFtZSwgdGFibGVzVG9SZXZva2UsIGNsdXN0ZXJQcm9wcyk7XG4gIH1cblxuICBjb25zdCB0YWJsZXNUb0dyYW50ID0gdGFibGVQcml2aWxlZ2VzLmZpbHRlcigoeyB0YWJsZUlkLCB0YWJsZU5hbWUsIGFjdGlvbnMgfSkgPT4ge1xuICAgIGNvbnN0IHRhYmxlQWRkZWQgPSAhb2xkVGFibGVQcml2aWxlZ2VzLmZpbmQoKHsgdGFibGVJZDogb3RoZXJUYWJsZUlkLCB0YWJsZU5hbWU6IG90aGVyVGFibGVOYW1lIH0pID0+IChcbiAgICAgIHRhYmxlSWQgPT09IG90aGVyVGFibGVJZCAmJiB0YWJsZU5hbWUgPT09IG90aGVyVGFibGVOYW1lXG4gICAgKSk7XG4gICAgY29uc3QgYWN0aW9uc0FkZGVkID0gb2xkVGFibGVQcml2aWxlZ2VzLmZpbmQoKHsgdGFibGVJZDogb3RoZXJUYWJsZUlkLCBhY3Rpb25zOiBvdGhlckFjdGlvbnMgfSkgPT4gKFxuICAgICAgdGFibGVJZCA9PT0gb3RoZXJUYWJsZUlkICYmIG90aGVyQWN0aW9ucy5zb21lKGFjdGlvbiA9PiAhYWN0aW9ucy5pbmNsdWRlcyhhY3Rpb24pKVxuICAgICkpO1xuICAgIHJldHVybiB0YWJsZUFkZGVkIHx8IGFjdGlvbnNBZGRlZDtcbiAgfSk7XG4gIGlmICh0YWJsZXNUb0dyYW50Lmxlbmd0aCA+IDApIHtcbiAgICBhd2FpdCBncmFudFByaXZpbGVnZXModXNlcm5hbWUsIHRhYmxlc1RvR3JhbnQsIGNsdXN0ZXJQcm9wcyk7XG4gIH1cblxuICByZXR1cm4geyByZXBsYWNlOiBmYWxzZSB9O1xufVxuIl19 \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322/redshift-data.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.e275fde8d2a03c793e28878ff6a48e84af45d2655f0c79418b5b86f2add826f7/redshift-data.js similarity index 100% rename from packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322/redshift-data.js rename to packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.e275fde8d2a03c793e28878ff6a48e84af45d2655f0c79418b5b86f2add826f7/redshift-data.js diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322/table.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.e275fde8d2a03c793e28878ff6a48e84af45d2655f0c79418b5b86f2add826f7/table.js similarity index 52% rename from packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322/table.js rename to packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.e275fde8d2a03c793e28878ff6a48e84af45d2655f0c79418b5b86f2add826f7/table.js index b1d964720f151..a1a3886aa1ffc 100644 --- a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322/table.js +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.e275fde8d2a03c793e28878ff6a48e84af45d2655f0c79418b5b86f2add826f7/table.js @@ -123,10 +123,16 @@ async function updateTable(tableName, tableNamePrefix, tableNameSuffix, tableCol } const oldDistKey = (0, util_1.getDistKeyColumn)(oldTableColumns)?.name; const newDistKey = (0, util_1.getDistKeyColumn)(tableColumns)?.name; - if ((!oldDistKey && newDistKey) || (oldDistKey && !newDistKey)) { - return createTable(tableNamePrefix, tableNameSuffix, tableColumns, tableAndClusterProps); + if (!oldDistKey && newDistKey) { + // Table has no existing distribution key, add a new one + alterationStatements.push(`ALTER TABLE ${tableName} ALTER DISTSTYLE KEY DISTKEY ${newDistKey}`); + } + else if (oldDistKey && !newDistKey) { + // Table has a distribution key, remove and set to AUTO + alterationStatements.push(`ALTER TABLE ${tableName} ALTER DISTSTYLE AUTO`); } else if (oldDistKey !== newDistKey) { + // Table has an existing distribution key, change it alterationStatements.push(`ALTER TABLE ${tableName} ALTER DISTKEY ${newDistKey}`); } const oldSortKeyColumns = (0, util_1.getSortKeyColumns)(oldTableColumns); @@ -168,4 +174,4 @@ function getEncodingColumnString(column) { } return ''; } -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFibGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJ0YWJsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFFQSxtREFBbUQ7QUFDbkQsbUNBQTZFO0FBQzdFLGlDQUE4RTtBQUd2RSxLQUFLLFVBQVUsT0FBTyxDQUFDLEtBQTJCLEVBQUUsS0FBa0Q7SUFDM0csTUFBTSxlQUFlLEdBQUcsS0FBSyxDQUFDLFNBQVMsQ0FBQyxNQUFNLENBQUM7SUFDL0MsTUFBTSxlQUFlLEdBQUcsS0FBSyxDQUFDLFNBQVMsQ0FBQyxjQUFjLEtBQUssTUFBTSxDQUFDLENBQUMsQ0FBQyxHQUFHLEtBQUssQ0FBQyxTQUFTLENBQUMsU0FBUyxDQUFDLENBQUMsRUFBRSxDQUFDLENBQUMsRUFBRSxDQUFDLENBQUMsQ0FBQyxFQUFFLENBQUM7SUFDOUcsTUFBTSxZQUFZLEdBQUcsS0FBSyxDQUFDLFlBQVksQ0FBQztJQUN4QyxNQUFNLG9CQUFvQixHQUFHLEtBQUssQ0FBQztJQUNuQyxNQUFNLFlBQVksR0FBRyxLQUF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GFibGVBbmRDbHVzdGVyUHJvcHMpKSk7XG5cbiAgcmV0dXJuIHRhYmxlTmFtZTtcbn1cblxuZnVuY3Rpb24gZ2V0U29ydEtleUNvbHVtbnNTdHJpbmcoc29ydEtleUNvbHVtbnM6IENvbHVtbltdKSB7XG4gIHJldHVybiBzb3J0S2V5Q29sdW1ucy5tYXAoY29sdW1uID0+IGNvbHVtbi5uYW1lKS5qb2luKCk7XG59XG5cbmZ1bmN0aW9uIGdldEVuY29kaW5nQ29sdW1uU3RyaW5nKGNvbHVtbjogQ29sdW1uKTogc3RyaW5nIHtcbiAgaWYgKGNvbHVtbi5lbmNvZGluZykge1xuICAgIHJldHVybiBgIEVOQ09ERSAke2NvbHVtbi5lbmNvZGluZ31gO1xuICB9XG4gIHJldHVybiAnJztcbn1cbiJdfQ== \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322/types.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.e275fde8d2a03c793e28878ff6a48e84af45d2655f0c79418b5b86f2add826f7/types.js similarity index 100% rename from packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322/types.js rename to packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.e275fde8d2a03c793e28878ff6a48e84af45d2655f0c79418b5b86f2add826f7/types.js diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322/user.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.e275fde8d2a03c793e28878ff6a48e84af45d2655f0c79418b5b86f2add826f7/user.js similarity index 100% rename from packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322/user.js rename to packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.e275fde8d2a03c793e28878ff6a48e84af45d2655f0c79418b5b86f2add826f7/user.js diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322/util.js b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.e275fde8d2a03c793e28878ff6a48e84af45d2655f0c79418b5b86f2add826f7/util.js similarity index 100% rename from packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322/util.js rename to packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/asset.e275fde8d2a03c793e28878ff6a48e84af45d2655f0c79418b5b86f2add826f7/util.js diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/aws-cdk-redshift-cluster-database.assets.json b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/aws-cdk-redshift-cluster-database.assets.json index d5a82d3341b39..de6465621057e 100644 --- a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/aws-cdk-redshift-cluster-database.assets.json +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/aws-cdk-redshift-cluster-database.assets.json @@ -1,33 +1,33 @@ { - "version": "33.0.0", + "version": "34.0.0", "files": { - "9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322": { + "e275fde8d2a03c793e28878ff6a48e84af45d2655f0c79418b5b86f2add826f7": { "source": { - "path": "asset.9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322", + "path": "asset.e275fde8d2a03c793e28878ff6a48e84af45d2655f0c79418b5b86f2add826f7", "packaging": "zip" }, "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322.zip", + "objectKey": "e275fde8d2a03c793e28878ff6a48e84af45d2655f0c79418b5b86f2add826f7.zip", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } }, - "73b60c2cf141bf58c33cfaa33858f5c84103a0232ba7192d696536488f7731c4": { + "d002370061965c69bc4caf15dddb5eccc9df318933ade6e4fa57cddb81c5abef": { "source": { - "path": "asset.73b60c2cf141bf58c33cfaa33858f5c84103a0232ba7192d696536488f7731c4", + "path": "asset.d002370061965c69bc4caf15dddb5eccc9df318933ade6e4fa57cddb81c5abef", "packaging": "zip" }, "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "73b60c2cf141bf58c33cfaa33858f5c84103a0232ba7192d696536488f7731c4.zip", + "objectKey": "d002370061965c69bc4caf15dddb5eccc9df318933ade6e4fa57cddb81c5abef.zip", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } }, - "6fae0ba8b4b765af354f41f73909322034258496718c660bad8e5336344a6d56": { + "ca573f99ba918e98431bb642bacdfdc19dac77e1af6512f2e8552ae4d77f939b": { "source": { "path": "aws-cdk-redshift-cluster-database.template.json", "packaging": "file" @@ -35,7 +35,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "6fae0ba8b4b765af354f41f73909322034258496718c660bad8e5336344a6d56.json", + "objectKey": "ca573f99ba918e98431bb642bacdfdc19dac77e1af6512f2e8552ae4d77f939b.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/aws-cdk-redshift-cluster-database.template.json b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/aws-cdk-redshift-cluster-database.template.json index bc775401b82bd..4ff8a6269b12e 100644 --- a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/aws-cdk-redshift-cluster-database.template.json +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/aws-cdk-redshift-cluster-database.template.json @@ -715,7 +715,7 @@ "S3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "S3Key": "73b60c2cf141bf58c33cfaa33858f5c84103a0232ba7192d696536488f7731c4.zip" + "S3Key": "d002370061965c69bc4caf15dddb5eccc9df318933ade6e4fa57cddb81c5abef.zip" }, "Description": "AWS CDK resource provider framework - onEvent (aws-cdk-redshift-cluster-database/User/Resource/Provider)", "Environment": { @@ -854,7 +854,7 @@ "S3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "S3Key": "73b60c2cf141bf58c33cfaa33858f5c84103a0232ba7192d696536488f7731c4.zip" + "S3Key": "d002370061965c69bc4caf15dddb5eccc9df318933ade6e4fa57cddb81c5abef.zip" }, "Description": "AWS CDK resource provider framework - onEvent (aws-cdk-redshift-cluster-database/User/TablePrivileges/Resource/Provider)", "Environment": { @@ -1005,7 +1005,7 @@ "S3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "S3Key": "9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322.zip" + "S3Key": "e275fde8d2a03c793e28878ff6a48e84af45d2655f0c79418b5b86f2add826f7.zip" }, "Handler": "index.handler", "Role": { @@ -1108,7 +1108,7 @@ "S3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "S3Key": "73b60c2cf141bf58c33cfaa33858f5c84103a0232ba7192d696536488f7731c4.zip" + "S3Key": "d002370061965c69bc4caf15dddb5eccc9df318933ade6e4fa57cddb81c5abef.zip" }, "Description": "AWS CDK resource provider framework - onEvent (aws-cdk-redshift-cluster-database/Table/Resource/Provider)", "Environment": { @@ -1156,8 +1156,8 @@ }, "databaseName": "my_db", "tableName": { - "prefix": "awscdkredshiftclusterdatabaseTable24923533", - "generateSuffix": "true" + "prefix": "my_table", + "generateSuffix": "false" }, "tableColumns": [ { diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/cdk.out b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/cdk.out index 560dae10d018f..2313ab5436501 100644 --- a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/cdk.out +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/cdk.out @@ -1 +1 @@ -{"version":"33.0.0"} \ No newline at end of file +{"version":"34.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/integ.json b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/integ.json index d49d391c62762..d6b1f6a34fa22 100644 --- a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/integ.json +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/integ.json @@ -1,5 +1,5 @@ { - "version": "33.0.0", + "version": "34.0.0", "testCases": { "redshift-cluster-database-integ/DefaultTest": { "stacks": [ diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/manifest.json b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/manifest.json index a5c900cb614dc..f7ae3214eff7e 100644 --- a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/manifest.json +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/manifest.json @@ -1,5 +1,5 @@ { - "version": "33.0.0", + "version": "34.0.0", "artifacts": { "aws-cdk-redshift-cluster-database.assets": { "type": "cdk:asset-manifest", @@ -17,7 +17,7 @@ "validateOnSynth": false, "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/6fae0ba8b4b765af354f41f73909322034258496718c660bad8e5336344a6d56.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/ca573f99ba918e98431bb642bacdfdc19dac77e1af6512f2e8552ae4d77f939b.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/redshiftclusterdatabaseintegDefaultTestDeployAssert4339FB48.assets.json b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/redshiftclusterdatabaseintegDefaultTestDeployAssert4339FB48.assets.json index d39b55454659f..5420f11ae4d2b 100644 --- a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/redshiftclusterdatabaseintegDefaultTestDeployAssert4339FB48.assets.json +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/redshiftclusterdatabaseintegDefaultTestDeployAssert4339FB48.assets.json @@ -1,5 +1,5 @@ { - "version": "33.0.0", + "version": "34.0.0", "files": { "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { "source": { diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/tree.json b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/tree.json index e16c7fc3f7f65..ad0ea8b1afce2 100644 --- a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/tree.json +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.js.snapshot/tree.json @@ -1166,7 +1166,7 @@ "s3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "s3Key": "73b60c2cf141bf58c33cfaa33858f5c84103a0232ba7192d696536488f7731c4.zip" + "s3Key": "d002370061965c69bc4caf15dddb5eccc9df318933ade6e4fa57cddb81c5abef.zip" }, "description": "AWS CDK resource provider framework - onEvent (aws-cdk-redshift-cluster-database/User/Resource/Provider)", "environment": { @@ -1228,7 +1228,7 @@ }, "constructInfo": { "fqn": "constructs.Construct", - "version": "10.2.69" + "version": "10.2.70" } }, "TablePrivileges": { @@ -1408,7 +1408,7 @@ "s3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "s3Key": "73b60c2cf141bf58c33cfaa33858f5c84103a0232ba7192d696536488f7731c4.zip" + "s3Key": "d002370061965c69bc4caf15dddb5eccc9df318933ade6e4fa57cddb81c5abef.zip" }, "description": "AWS CDK resource provider framework - onEvent (aws-cdk-redshift-cluster-database/User/TablePrivileges/Resource/Provider)", "environment": { @@ -1470,13 +1470,13 @@ }, "constructInfo": { "fqn": "constructs.Construct", - "version": "10.2.69" + "version": "10.2.70" } } }, "constructInfo": { "fqn": "constructs.Construct", - "version": "10.2.69" + "version": "10.2.70" } } }, @@ -1639,7 +1639,7 @@ "s3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "s3Key": "9b854795d4a2f1dea5d1c14d6cfcee1621c5d70dd8dfed2613d6e55c19022322.zip" + "s3Key": "e275fde8d2a03c793e28878ff6a48e84af45d2655f0c79418b5b86f2add826f7.zip" }, "handler": "index.handler", "role": { @@ -1840,7 +1840,7 @@ "s3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "s3Key": "73b60c2cf141bf58c33cfaa33858f5c84103a0232ba7192d696536488f7731c4.zip" + "s3Key": "d002370061965c69bc4caf15dddb5eccc9df318933ade6e4fa57cddb81c5abef.zip" }, "description": "AWS CDK resource provider framework - onEvent (aws-cdk-redshift-cluster-database/Table/Resource/Provider)", "environment": { @@ -1902,7 +1902,7 @@ }, "constructInfo": { "fqn": "constructs.Construct", - "version": "10.2.69" + "version": "10.2.70" } } }, @@ -1946,7 +1946,7 @@ "path": "redshift-cluster-database-integ/DefaultTest/Default", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.2.69" + "version": "10.2.70" } }, "DeployAssert": { @@ -1992,7 +1992,7 @@ "path": "Tree", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.2.69" + "version": "10.2.70" } } }, diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.ts b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.ts index 87a9e403f0e88..74800d8c9e7ad 100644 --- a/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.ts +++ b/packages/@aws-cdk/aws-redshift-alpha/test/integ.database.ts @@ -1,10 +1,10 @@ #!/usr/bin/env node +import * as cdk from 'aws-cdk-lib'; import * as ec2 from 'aws-cdk-lib/aws-ec2'; import * as kms from 'aws-cdk-lib/aws-kms'; -import * as cdk from 'aws-cdk-lib'; // eslint-disable-next-line import/no-extraneous-dependencies -import { REDSHIFT_COLUMN_ID } from 'aws-cdk-lib/cx-api'; import * as integ from '@aws-cdk/integ-tests-alpha'; +import { REDSHIFT_COLUMN_ID } from 'aws-cdk-lib/cx-api'; import * as constructs from 'constructs'; import * as redshift from '../lib'; @@ -47,6 +47,7 @@ const databaseOptions = { const user = new redshift.User(stack, 'User', databaseOptions); const table = new redshift.Table(stack, 'Table', { ...databaseOptions, + tableName: 'my_table', tableColumns: [ { name: 'col1', dataType: 'varchar(4)', distKey: true, comment: 'A test column', encoding: redshift.ColumnEncoding.LZO }, { name: 'col2', dataType: 'float', sortKey: true, comment: 'A test column' }, From b00614e0d337118dfff621ea1e92c650d47ad289 Mon Sep 17 00:00:00 2001 From: Rizbir Khan Date: Mon, 25 Sep 2023 13:34:35 +0000 Subject: [PATCH 21/21] adding inline comments --- .../database-query-provider/privileges.test.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/packages/@aws-cdk/aws-redshift-alpha/test/database-query-provider/privileges.test.ts b/packages/@aws-cdk/aws-redshift-alpha/test/database-query-provider/privileges.test.ts index 5b91c38728f4b..e61d157d6e201 100644 --- a/packages/@aws-cdk/aws-redshift-alpha/test/database-query-provider/privileges.test.ts +++ b/packages/@aws-cdk/aws-redshift-alpha/test/database-query-provider/privileges.test.ts @@ -157,12 +157,17 @@ describe('update', () => { tablePrivileges: newTablePrivileges, }; + // Checking if the table resource has not been recreated await expect(managePrivileges(newResourceProperties, event)).resolves.toMatchObject({ PhysicalResourceId: physicalResourceId, }); + // Upon a table name change, Redshift maintains the same table priviliges as before. + // The name of the table has changed, a new table has not been created. + // Therefore 'REVOKE' statements should not be used. expect(mockExecuteStatement).not.toHaveBeenCalledWith(expect.objectContaining({ Sql: `REVOKE INSERT, SELECT ON ${newTableName} FROM ${username}`, })); + // Likewise, here the table name has changed, so the current priviliges will still be intact. expect(mockExecuteStatement).not.toHaveBeenCalledWith(expect.objectContaining({ Sql: expect.stringMatching(new RegExp(`.+ ON ${tableName} TO ${username}`)), })); @@ -175,12 +180,15 @@ describe('update', () => { tablePrivileges: newTablePrivileges, }; + // Checking if the table resource has not been recreated await expect(managePrivileges(newResourceProperties, event)).resolves.toMatchObject({ PhysicalResourceId: physicalResourceId, }); + // Old actions are REVOKED, as they are not included in the list expect(mockExecuteStatement).toHaveBeenCalledWith(expect.objectContaining({ Sql: `REVOKE INSERT, SELECT ON ${tableName} FROM ${username}`, })); + // New actions are GRANTED, as they are included in the list expect(mockExecuteStatement).toHaveBeenCalledWith(expect.objectContaining({ Sql: `GRANT DROP ON ${tableName} TO ${username}`, })); @@ -194,12 +202,18 @@ describe('update', () => { tablePrivileges: newTablePrivileges, }; + // Checking if the table resource has not been recreated, we are not changing on table id either. + // Due to the construct only needing to be changed on a new user, not a new table await expect(managePrivileges(newResourceProperties, event)).resolves.toMatchObject({ PhysicalResourceId: physicalResourceId, }); + // Upon removal of the old table, the priviliges will also be revoked automatically, + // as the table no longer exists. + // Calling REVOKE statments on a non-existing table will throw errors by Redshift expect(mockExecuteStatement).not.toHaveBeenCalledWith(expect.objectContaining({ Sql: expect.stringMatching(new RegExp(`REVOKE .+ ON ${tableName} FROM ${username}`)), })); + // Adds the permissions onto the newly created table expect(mockExecuteStatement).toHaveBeenCalledWith(expect.objectContaining({ Sql: expect.stringMatching(new RegExp(`GRANT .+ ON ${tableName} TO ${username}`)), })); @@ -220,9 +234,12 @@ describe('update', () => { }, }; + // Checking if the table resource has not been recreated await expect(managePrivileges(newResourceProperties, newEvent)).resolves.toMatchObject({ PhysicalResourceId: physicalResourceId, }); + // Upon initial deployment from non table id usage to table id usage, + // permissions would not need to be granted/revoked, as the table should already exist expect(mockExecuteStatement).not.toHaveBeenCalledWith(expect.objectContaining({ Sql: expect.stringMatching(new RegExp(`.+ ON ${tableName} FROM ${username}`)), }));