mooyoul / aws-cdk-ses-domain-identity

Constructs for provisioning and referencing domain identities which can be used in SES RuleSets and Actions Construct.
MIT License
37 stars 13 forks source link

AWS SDK v2 is no longer included in Node 18+ runtime, upgrade to v3 is required #83

Open arpadgabor opened 10 months ago

arpadgabor commented 10 months ago

As you are probably aware, AWS SDK v2 is not included in the latest Node runtimes. From what I see, the lambda code is still using the v2 version instead of v3, and the custom resource fails to run with the following error:

{
    "errorType": "Runtime.ImportModuleError",
    "errorMessage": "Error: Cannot find module 'aws-sdk/clients/route53'\nRequire stack:\n- /var/task/verifier.js\n- /var/task/handlers/create.js\n- /var/task/handlers/index.js\n- /var/task/index.js\n- /var/runtime/index.mjs",
    "stack": [
        "Runtime.ImportModuleError: Error: Cannot find module 'aws-sdk/clients/route53'",
        "Require stack:",
        "- /var/task/verifier.js",
        "- /var/task/handlers/create.js",
        "- /var/task/handlers/index.js",
        "- /var/task/index.js",
        "- /var/runtime/index.mjs",
        "    at _loadUserApp (file:///var/runtime/index.mjs:1087:17)",
        "    at async UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1119:21)",
        "    at async start (file:///var/runtime/index.mjs:1282:23)",
        "    at async file:///var/runtime/index.mjs:1288:1"
    ]
}

As there currently is no way to deploy the construct in the current state, I think a short-term fix would be to provide a 2.1.1 release with Node 16 runtime (as it's still supported until June). A longer-term and simple option would be to bundle the v2 SDK. Finally, the harder option would be a complete upgrade.

I'll see if I can get a PR started for the upgrade.

mooyoul commented 10 months ago

Ahhh I missed that. I think just moving aws-sdk v1 from dev dep to dep would be quick fix. I know that aws sdk v1 is now deprecated but repairing handler to work is much important than refactoring code to use aws sdk v2 IMO.

So my plan would be like:

  1. Bundle aws-sdk v1 then release with patch version bump
  2. Refactor code to use aws-sdk v2 then release with minor version bump

It would be so appreiciated if you can submit for 1 for now :)

arpadgabor commented 9 months ago

Created a PR for bundling: #85