diff --git a/packages/@aws-cdk/aws-redshift-alpha/.npmignore b/packages/@aws-cdk/aws-redshift-alpha/.npmignore index 2f484b8db6b88..c2a9af3116e2f 100644 --- a/packages/@aws-cdk/aws-redshift-alpha/.npmignore +++ b/packages/@aws-cdk/aws-redshift-alpha/.npmignore @@ -27,3 +27,6 @@ junit.xml test/ !*.lit.ts **/*.snapshot + +# include custom-resource-handlers +!custom-resource-handlers/* \ No newline at end of file diff --git a/packages/@aws-cdk/aws-redshift-alpha/lib/cluster.ts b/packages/@aws-cdk/aws-redshift-alpha/lib/cluster.ts index 3facb2452bfa5..e80d9bcf8b87d 100644 --- a/packages/@aws-cdk/aws-redshift-alpha/lib/cluster.ts +++ b/packages/@aws-cdk/aws-redshift-alpha/lib/cluster.ts @@ -713,7 +713,7 @@ export class Cluster extends ClusterBase { const rebootFunction = new lambda.SingletonFunction(this, 'RedshiftClusterRebooterFunction', { uuid: '511e207f-13df-4b8b-b632-c32b30b65ac2', runtime: lambda.Runtime.NODEJS_18_X, - code: lambda.Code.fromAsset(path.join(__dirname, '..', '..', 'custom-resource-handlers', 'dist', 'aws-redshift-alpha', 'cluster-parameter-change-reboot-handler')), + code: lambda.Code.fromAsset(path.join(__dirname, '..', 'custom-resource-handlers', 'dist', 'aws-redshift-alpha', 'cluster-parameter-change-reboot-handler')), handler: 'index.handler', timeout: Duration.seconds(900), }); diff --git a/packages/@aws-cdk/aws-redshift-alpha/package.json b/packages/@aws-cdk/aws-redshift-alpha/package.json index c9c7653e0676a..51cd306772e4b 100644 --- a/packages/@aws-cdk/aws-redshift-alpha/package.json +++ b/packages/@aws-cdk/aws-redshift-alpha/package.json @@ -66,7 +66,10 @@ "cdk-build": { "env": { "AWSLINT_BASE_CONSTRUCT": true - } + }, + "pre": [ + "./scripts/airlift-custom-resource-handlers.sh" + ] }, "keywords": [ "aws", diff --git a/packages/@aws-cdk/aws-redshift-alpha/scripts/airlift-custom-resource-handlers.sh b/packages/@aws-cdk/aws-redshift-alpha/scripts/airlift-custom-resource-handlers.sh new file mode 100755 index 0000000000000..6d74f9e2cf420 --- /dev/null +++ b/packages/@aws-cdk/aws-redshift-alpha/scripts/airlift-custom-resource-handlers.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +scriptdir=$(cd $(dirname $0) && pwd) +customresourcedir=$(node -p "path.dirname(require.resolve('@aws-cdk/custom-resource-handlers/package.json'))") +awscdklibdir=${scriptdir}/.. + +function airlift() { + if [[ $1 != dist/core/nodejs-entrypoint-handler && ($1 = dist/core || $1 = dist/core/*) ]]; + then + mkdir -p $awscdklibdir/core/lib/$1 + cp $customresourcedir/$2 $awscdklibdir/core/lib/$1 + else + mkdir -p $awscdklibdir/custom-resource-handlers/$1 + cp $customresourcedir/$2 $awscdklibdir/custom-resource-handlers/$1 + fi +} + +recurse() { + local dir=$1 + + for file in $dir/*; do + if [ -f $file ]; then + case $file in + $customresourcedir/dist/aws-redshift-alpha/*/index.*) + cr=$(echo $file | rev | cut -d "/" -f 2-4 | rev) + airlift $cr $cr/index.* + ;; + esac + fi + + if [ -d $file ]; then + recurse $file + fi + done +} + +recurse $customresourcedir/dist diff --git a/packages/@aws-cdk/custom-resource-handlers/README.md b/packages/@aws-cdk/custom-resource-handlers/README.md index 23f040d381a92..e469ec0413ecd 100644 --- a/packages/@aws-cdk/custom-resource-handlers/README.md +++ b/packages/@aws-cdk/custom-resource-handlers/README.md @@ -16,12 +16,15 @@ and included as part of the `aws-cdk-lib` package. ### Experimental: - aws-amplify-alpha/asset-deployment-handler +- aws-redshift-alpha/asset-deployment-handler These handlers are excluded from `aws-cdk-lib/custom-resource-handlers` and are individually copied into their respective `-alpha` packages at build time. When an `-alpha` package is stabilized, part of the stabilization process **must** be to remove `-alpha` from the folder name, so that it is included in `aws-cdk-lib`. +`*/generated.ts` files are not supported for alpha modules due to import paths that only work for stable modules in `aws-cdk-lib`. These files must be added to `custom-resources-framework/config.ts` as `ComponentType.NO_OP`. + ## Nodejs Entrypoint This package also includes `nodejs-entrypoint.ts`, which is a wrapper that talks to diff --git a/packages/@aws-cdk/custom-resource-handlers/lib/custom-resources-framework/config.ts b/packages/@aws-cdk/custom-resource-handlers/lib/custom-resources-framework/config.ts index f17c002cc8217..24436234b3678 100644 --- a/packages/@aws-cdk/custom-resource-handlers/lib/custom-resources-framework/config.ts +++ b/packages/@aws-cdk/custom-resource-handlers/lib/custom-resources-framework/config.ts @@ -226,7 +226,7 @@ export const config: HandlerFrameworkConfig = { 'aws-redshift-alpha': { 'cluster-reboot-provider': [ { - type: ComponentType.SINGLETON_FUNCTION, + type: ComponentType.NO_OP, sourceCode: path.resolve(__dirname, '..', 'aws-redshift-alpha', 'cluster-parameter-change-reboot-handler', 'index.ts'), }, ],