Skip to content

(custom-resource): node18 doesn't import sdk v2, and framework depends on sdk v2. #26732

@ahammond

Description

@ahammond

Describe the bug

Received response status [FAILED] from custom resource. Message returned: Error: Cannot find module 'aws-sdk' Require stack: - /var/task/index.js - /var/runtime/index.mjs Logs: /aws/lambda/GlobalProdProdUsEast22-Do-ProdUsEast22Dochistorypr-94AvLumRaUIU Require stack: - /var/task/index.js - /var/runtime/index.mjs at _loadUserApp (file:///var/runtime/index.mjs:997:17) at async UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1029:21) at async start (file:///var/runtime/index.mjs:1192:23) at async file:///var/runtime/index.mjs:1198:1 (RequestId: 87ecf43c-da3d-4806-86b9-c03465a20501)

Upgraded to v2.91.0, issue persists (I did some yarn.lock surgery to make sure only v2.91.0 was present). Downgraded to v2.86.0 and managed to unblock by deploying from my laptop.

I assume it's related to #26325

Expected Behavior

I expected to not have to ever think about the custom resource provider framework. Instead... they break when upgraded to node18 because of bundling issues? Why not upgraded them to use sdk v3 before changing them to node18?!?

Current Behavior

Breaks huge swaths of custom resources. Super awesome when combined with older stacks which will fail to roll back because they were previously on node12. I can't emphasize enough how much CustomResources are both essential and yet also horrible when they have issues. Thankfully the only stack I've fully trashed with this was a test system, but wow. Can CDK / Cfn be trusted to deploy resources which store data?

Reproduction Steps

Working: https://github.com/ahammond/repro-node18-bundling-cdk

switch branch to https://github.com/ahammond/repro-node18-bundling-cdk/tree/with-cdk-latest

and it fails.

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.87.0 breaks things

Framework Version

No response

Node.js Version

v16.20.

OS

MacOS

Language

Typescript

Language Version

5.1.3

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions