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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZnJhbWV3b3JrLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiZnJhbWV3b3JrLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSw0QkFBNEI7QUFDNUIsK0JBQStCO0FBQy9CLDhDQUE4QztBQUM5QyxtQ0FBbUM7QUFDbkMseUNBQTREO0FBQzVELGlDQUFxQztBQVVyQzs7Ozs7Ozs7O0dBU0c7QUFDSCxLQUFLLFVBQVUsT0FBTyxDQUFDLFVBQXVEO0lBQzVFLE1BQU0sZ0JBQWdCLEdBQUcsRUFBRSxHQUFHLFVBQVUsRUFBRSxXQUFXLEVBQUUsS0FBSyxFQUFXLENBQUM7SUFDeEUsSUFBQSxVQUFHLEVBQUMsZ0JBQWdCLEVBQUUsZ0JBQWdCLENBQUMsQ0FBQztJQUV4QyxVQUFVLENBQUMsa0JBQWtCLEdBQUcsVUFBVSxDQUFDLGtCQUFrQixJQUFJLEVBQUcsQ0FBQztJQUVyRSxNQUFNLGFBQWEsR0FBRyxNQUFNLGtCQUFrQixDQUFDLE1BQU0sQ0FBQyw4QkFBOEIsRUFBRSxnQkFBZ0IsRU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XG4gICAgICByZXR1cm4gcmVxLlBoeXNpY2FsUmVzb3VyY2VJZDtcblxuICAgIGRlZmF1bHQ6XG4gICAgICB0aHJvdyBuZXcgRXJyb3IoYEludmFsaWQgXCJSZXF1ZXN0VHlwZVwiIGluIHJlcXVlc3QgXCIke0pTT04uc3RyaW5naWZ5KHJlcSl9XCJgKTtcbiAgfVxufVxuIl19 \ 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/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3V0Ym91bmQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJvdXRib3VuZC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSwwQkFBMEI7QUFDMUIsK0JBQStCO0FBQy9CLDZEQUE2RDtBQUM3RCwwREFBaUg7QUFDakgsNkRBQTZEO0FBQzdELG9EQUFxRjtBQUNyRiw2REFBNkQ7QUFFN0QsTUFBTSx5QkFBeUIsR0FBRyxNQUFNLENBQUMsQ0FBQyxhQUFhO0FBRXZELDRFQUE0RTtBQUM1RSwwREFBMEQ7QUFDMUQsMkZBQTJGO0FBQzNGLE1BQU0sWUFBWSxHQUFHO0lBQ25CL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bGV0IHN0YXJ0RXhlY3V0aW9uID0gZGVmYXVsdFN0YXJ0RXhlY3V0aW9uO1xuZXhwb3J0IGxldCBpbnZva2VGdW5jdGlvbiA9IGRlZmF1bHRJbnZva2VGdW5jdGlvbjtcbmV4cG9ydCBsZXQgaHR0cFJlcXVlc3QgPSBkZWZhdWx0SHR0cFJlcXVlc3Q7XG4iXX0= \ 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInV0a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nN0cmluZ2lmeSh4LCB1bmRlZmluZWQsIDIpIDogeCkpO1xufVxuXG5leHBvcnQgaW50ZXJmYWNlIFJldHJ5T3B0aW9ucyB7XG4gIC8qKiBIb3cgbWFueSByZXRyaWVzICh3aWxsIGF0IGxlYXN0IHRyeSBvbmNlKSAqL1xuICByZWFkb25seSBhdHRlbXB0czogbnVtYmVyO1xuICAvKiogU2xlZXAgYmFzZSwgaW4gbXMgKi9cbiAgcmVhZG9ubHkgc2xlZXA6IG51bWJlcjtcbn1cblxuZXhwb3J0IGZ1bmN0aW9uIHdpdGhSZXRyaWVzPEEgZXh0ZW5kcyBBcnJheTxhbnk+LCBCPihvcHRpb25zOiBSZXRyeU9wdGlvbnMsIGZuOiAoLi4ueHM6IEEpID0+IFByb21pc2U8Qj4pOiAoLi4ueHM6IEEpID0+IFByb21pc2U8Qj4ge1xuICByZXR1cm4gYXN5bmMgKC4uLnhzOiBBKSA9PiB7XG4gICAgbGV0IGF0dGVtcHRzID0gb3B0aW9ucy5hdHRlbXB0cztcbiAgICBsZXQgbXMgPSBvcHRpb25zLnNsZWVwO1xuICAgIHdoaWxlICh0cnVlKSB7XG4gICAgICB0cnkge1xuICAgICAgICByZXR1cm4gYXdhaXQgZm4oLi4ueHMpO1xuICAgICAgfSBjYXRjaCAoZSkge1xuICAgICAgICBpZiAoYXR0ZW1wdHMtLSA8PSAwKSB7XG4gICAgICAgICAgdGhyb3cgZTtcbiAgICAgICAgfVxuICAgICAgICBhd2FpdCBzbGVlcChNYXRoLmZsb29yKE1hdGgucmFuZG9tKCkgKiBtcykpO1xuICAgICAgICBtcyAqPSAyO1xuICAgICAgfVxuICAgIH1cbiAgfTtcbn1cblxuYXN5bmMgZnVuY3Rpb24gc2xlZXAobXM6IG51bWJlcik6IFByb21pc2U8dm9pZD4ge1xuICByZXR1cm4gbmV3IFByb21pc2UoKG9rKSA9PiBzZXRUaW1lb3V0KG9rLCBtcykpO1xufSJdfQ== \ 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJpdmlsZWdlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInByaXZpbGVnZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBRUEsbURBQW1EO0FBRW5ELGlDQUF3QztBQUdqQyxLQUFLLFVBQVUsT0FBTyxDQUFDLEtBQXFELEVBQUUsS0FBa0Q7SUFDckksTUFBTSxRQUFRLEdBQUcsS0FBSyxDQUFDLFFBQVEsQ0FBQztJ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ZWQgfHwgYWN0aW9uc0FkZGVkO1xuICB9KTtcbiAgaWYgKHRhYmxlc1RvR3JhbnQubGVuZ3RoID4gMCkge1xuICAgIGF3YWl0IGdyYW50UHJpdmlsZWdlcyh1c2VybmFtZSwgdGFibGVzVG9HcmFudCwgY2x1c3RlclByb3BzKTtcbiAgfVxuXG4gIHJldHVybiB7IHJlcGxhY2U6IGZhbHNlIH07XG59XG4iXX0= \ 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZnJhbWV3b3JrLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiZnJhbWV3b3JrLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSw0QkFBNEI7QUFDNUIsK0JBQStCO0FBQy9CLDhDQUE4QztBQUM5QyxtQ0FBbUM7QUFDbkMseUNBQTREO0FBQzVELGlDQUF1RDtBQVV2RDs7Ozs7Ozs7O0dBU0c7QUFDSCxLQUFLLFVBQVUsT0FBTyxDQUFDLFVBQXVEO0lBQzVFLE1BQU0sZ0JBQWdCLEdBQUcsRUFBRSxHQUFHLFVBQVUsRUFBRSxXQUFXLEVBQUUsS0FBSyxFQUFXLENBQUM7SUFDeEUsSUFBQSxVQUFHLEVBQUMsZ0JBQWdCLEVBQUUsZ0JBQWdCLENBQUMsQ0FBQztJQUV4QyxVQUFVLENBQUMsa0JBQWtCLEdBQUcsVUFBVSxDQUFDLGtCQUFrQixJQUFJLEVBQUcsQ0FBQztJQUVyRSxNQUFNLGFBQWEsR0FBRyxNQUFNLGtCQUFrQixDQUFDLE1BQU0sQ0FBQyw4QkFBOEIsRUFBRSxnQkFBZ0IsRUFBRSxVQUFVLENBQUMsV0FBVyxDQUFvQixDQUFDO0lBQ25KLElBQUEsVUFBRyxFQUFDLG1CQUFtQixFQUFFLGFBQWEsQ0FBQyxDQUFDO0lBRXhDLG9GQUFvRjtJQUNwRixpQ0FBaUM7SUFDakMsTUFBTS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XG4gKi9cbmZ1bmN0aW9uIGRlZmF1bHRQaHlzaWNhbFJlc291cmNlSWQocmVxOiBBV1NMYW1iZGEuQ2xvdWRGb3JtYXRpb25DdXN0b21SZXNvdXJjZUV2ZW50KTogc3RyaW5nIHtcbiAgc3dpdGNoIChyZXEuUmVxdWVzdFR5cGUpIHtcbiAgICBjYXNlICdDcmVhdGUnOlxuICAgICAgcmV0dXJuIHJlcS5SZXF1ZXN0SWQ7XG5cbiAgICBjYXNlICdVcGRhdGUnOlxuICAgIGNhc2UgJ0RlbGV0ZSc6XG4gICAgICByZXR1cm4gcmVxLlBoeXNpY2FsUmVzb3VyY2VJZDtcblxuICAgIGRlZmF1bHQ6XG4gICAgICB0aHJvdyBuZXcgRXJyb3IoYEludmFsaWQgXCJSZXF1ZXN0VHlwZVwiIGluIHJlcXVlc3QgXCIke0pTT04uc3RyaW5naWZ5KHJlcSl9XCJgKTtcbiAgfVxufVxuIl19 \ 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3V0Ym91bmQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJvdXRib3VuZC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSwwQkFBMEI7QUFDMUIsK0JBQStCO0FBQy9CLDZEQUE2RDtBQUM3R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5jdGlvbjtcbmV4cG9ydCBsZXQgaHR0cFJlcXVlc3QgPSBkZWZhdWx0SHR0cFJlcXVlc3Q7XG4iXX0= \ 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;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JvcihgcmV0dXJuIHZhbHVlcyBmcm9tIHVzZXItaGFuZGxlcnMgbXVzdCBiZSBKU09OIG9iamVjdHMuIGdvdDogXCIke3RleHR9XCJgKTtcbiAgfVxufVxuIl19 \ 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJpdmlsZWdlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInByaXZpbGVnZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBR0EsbURBQW1EO0FBRW5ELGlDQUF3QztBQUVqQyxLQUFLLFVBQVUsT0FBTyxDQUFDLEtBQXFELEVBQUUsS0FBa0Q7SUFDckksTUFBTSxRQUFRLEdBQUcsS0FBSyxDQUFDLFFBQVEsQ0FBQztJQUNoQyxNQUFNLGVBQWUsR0FBRyxLQUFLLENBQUMsZUFBZSxDQUFDO0lBQzlDLE1BQU0sWUFBWSxHQUFHLEtBQUssQ0FBQztJQUUzQixJQUFJLEtBQUssQ0FBQyxXQUFXLEtBQUssUUFBUSxFQUFFO1FBQ2xDLE1BQU0sZUFBZSxDQUFDLFFBQVEsRUFBRSxlQUFlLEVBQUUsWUFBWSxDQUFDLENBQUM7UUFDL0QsT0FB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YWJsZU5hbWUgPT09IG90aGVyVGFibGVOYW1lXG4gICAgKSk7XG4gICAgY29uc3QgYWN0aW9uc0FkZGVkID0gb2xkVGFibGVQcml2aWxlZ2VzLmZpbmQoKHsgdGFibGVJZDogb3RoZXJUYWJsZUlkLCBhY3Rpb25zOiBvdGhlckFjdGlvbnMgfSkgPT4gKFxuICAgICAgdGFibGVJZCA9PT0gb3RoZXJUYWJsZUlkICYmIG90aGVyQWN0aW9ucy5zb21lKGFjdGlvbiA9PiAhYWN0aW9ucy5pbmNsdWRlcyhhY3Rpb24pKVxuICAgICkpO1xuICAgIHJldHVybiB0YWJsZUFkZGVkIHx8IGFjdGlvbnNBZGRlZDtcbiAgfSk7XG4gIGlmICh0YWJsZXNUb0dyYW50Lmxlbmd0aCA+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/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4gIHJldHVybiAnJztcbn1cbiJdfQ== \ 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' },