Skip to content

Commit

Permalink
Merge branch 'main' into bobertzh/docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] committed Jan 19, 2024
2 parents 94f9ac3 + 4952f36 commit 18d4095
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 3 deletions.
3 changes: 3 additions & 0 deletions packages/@aws-cdk/aws-redshift-alpha/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ junit.xml
test/
!*.lit.ts
**/*.snapshot

# include custom-resource-handlers
!custom-resource-handlers/*
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-redshift-alpha/lib/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
});
Expand Down
5 changes: 4 additions & 1 deletion packages/@aws-cdk/aws-redshift-alpha/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@
"cdk-build": {
"env": {
"AWSLINT_BASE_CONSTRUCT": true
}
},
"pre": [
"./scripts/airlift-custom-resource-handlers.sh"
]
},
"keywords": [
"aws",
Expand Down
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions packages/@aws-cdk/custom-resource-handlers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
},
],
Expand Down

0 comments on commit 18d4095

Please sign in to comment.