Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(redshift): enableRebootForParameterChanges fails synth with "cannot find entry file…" #28760

Merged
merged 7 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong custom resource :)

- 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