‼️ NOTICE: S3 notifications fail to deploy on version 1.94.0 - ZipFile can only be used when Runtime is set to either of nodejs8.10...
See original GitHub issuePlease add your +1 👍 to let us know you have encountered this
Status: RESOLVED
Overview:
Users trying to configure s3 bucket notifications of any form will encounter a deployment failure. This includes:
bucket.addEventNotification
S3EventSource
These resources use a custom resource that is shipped with the CDK. The root cause is a recent upgrade we performed switching from the nodejs10.x
runtime to nodejs14.x
. CloudFormation does not support using nodejs14.x
on lambda functions that use inline code (i.e ZipFile
), which is indeed the case for this custom resource.
Complete Error Message:
ZipFile can only be used when Runtime is set to either of nodejs8.10, nodejs10.x, nodejs12.x, python2.7, python3.6, python3.7, python3.8
Workaround:
The workaround is to use escape hatches and modify the runtime property:
const handler = Stack.of(this).node.tryFindChild('BucketNotificationsHandler050a0587b7544547bf325f094a3db834')?.node.defaultChild as cdk.CfnResource
handler.addPropertyOverride("Runtime", "nodejs12.x");
Solution:
Patch is available: https://github.com/aws/aws-cdk/releases/tag/v1.94.1
Related Issues:
Originally reported as
Deploying our existing CDK stack fails with 1.94.0 -> https://github.com/aws/aws-cdk/blob/a5be04270c2a372132964ab13d080a16f1a6f00c/packages/%40aws-cdk/aws-s3/lib/notifications-resource/notifications-resource-handler.ts#L85
...
35/101 | 4:54:04 PM | UPDATE_FAILED | AWS::Lambda::Function | BucketNotificationsHandler050a0587b7544547bf325f094a3db834 (BucketNotificationsHandler050a0587b7544547bf325f094a3db8347ECC3691) ZipFile can only be used when Runtime is set to either of nodejs8.10, nodejs10.x, nodejs12.x, python2.7, python3.6, python3.7, python3.8.
new NotificationsResourceHandler (/home/deployer/.npm/_npx/2462/lib/node_modules/@wix/snowmobile-stack/node_modules/@aws-cdk/aws-s3/lib/notifications-resource/notifications-resource-handler.ts:78:22)
\_ Function.singleton (/home/deployer/.npm/_npx/2462/lib/node_modules/@wix/snowmobile-stack/node_modules/@aws-cdk/aws-s3/lib/notifications-resource/notifications-resource-handler.ts:39:16)
\_ BucketNotifications.createResourceOnce (/home/deployer/.npm/_npx/2462/lib/node_modules/@wix/snowmobile-stack/node_modules/@aws-cdk/aws-s3/lib/notifications-resource/notifications-resource.ts:107:55)
\_ BucketNotifications.addNotification (/home/deployer/.npm/_npx/2462/lib/node_modules/@wix/snowmobile-stack/node_modules/@aws-cdk/aws-s3/lib/notifications-resource/notifications-resource.ts:56:27)
\_ Bucket.addEventNotification (/home/deployer/.npm/_npx/2462/lib/node_modules/@wix/snowmobile-stack/node_modules/@aws-cdk/aws-s3/lib/bucket.ts:1459:24)
\_ S3EventSource.bind (/home/deployer/.npm/_npx/2462/lib/node_modules/@wix/snowmobile-stack/node_modules/@aws-cdk/aws-lambda-event-sources/lib/s3.ts:31:19)
\_ Function.addEventSource (/home/deployer/.npm/_npx/2462/lib/node_modules/@wix/snowmobile-stack/node_modules/@aws-cdk/aws-lambda/lib/function-base.ts:344:12)
\_ new SnowmobileStackConstruct (/home/deployer/.npm/_npx/2462/lib/node_modules/@wix/snowmobile-stack/lib/snowmobile-stack-construct.ts:236:20)
\_ new Snowmobile (/home/deployer/.npm/_npx/2462/lib/node_modules/@wix/snowmobile-stack/lib/Snowmobile.ts:16:18)
\_ Object.<anonymous> (/home/deployer/.npm/_npx/2462/lib/node_modules/@wix/snowmobile-stack/bin/cdk-stack.ts:33:1)
\_ Module._compile (internal/modules/cjs/loader.js:1063:30)
\_ Module.m._compile (/home/deployer/.npm/_npx/2515/lib/node_modules/ts-node/src/index.ts:1056:23)
\_ Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
\_ Object.require.extensions.<computed> [as .ts] (/home/deployer/.npm/_npx/2515/lib/node_modules/ts-node/src/index.ts:1059:12)
\_ Module.load (internal/modules/cjs/loader.js:928:32)
\_ Function.Module._load (internal/modules/cjs/loader.js:769:14)
\_ Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
\_ main (/home/deployer/.npm/_npx/2515/lib/node_modules/ts-node/src/bin.ts:198:14)
\_ Object.<anonymous> (/home/deployer/.npm/_npx/2515/lib/node_modules/ts-node/src/bin.ts:288:3)
\_ Module._compile (internal/modules/cjs/loader.js:1063:30)
\_ Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
\_ Module.load (internal/modules/cjs/loader.js:928:32)
\_ Function.Module._load (internal/modules/cjs/loader.js:769:14)
\_ Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
\_ /usr/local/lib/node_modules/npm/node_modules/libnpx/index.js:268:14
Reproduction Steps
Try to deploy a stack that has a lambda that triggered from an S3 bucket event, i.e.:
...
someBucket.grantRead(someLambda);
someLambda.addEventSource(
new S3EventSource(someBucket, {
events: [EventType.OBJECT_CREATED],
}),
);
...
What did you expect to happen?
The stack do be deployed =)
What actually happened?
The mentioned error.
Environment
- CDK CLI Version :
- Framework Version:
- Node.js Version:
- OS :
- Language (Version):
Other
This is 🐛 Bug Report
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:6 (4 by maintainers)
Top GitHub Comments
Thank you for the quick turnaround 🙂
A patch has been released: https://github.com/aws/aws-cdk/releases/tag/v1.94.1