Description
Checkboxes for prior research
- I've gone through Developer Guide and API reference
- I've checked AWS Forums and StackOverflow.
- I've searched for previous similar issues and didn't find any solution.
Describe the bug
Any Projects using the AWS SDK Packages with version 3.499.0 when bundled and deployed lead to Webpack require issues after the recent change for use dynamic import for credential providers
[(https://github.com//pull/5698) (1452cd45)
SDK version number
@aws-sdk/[email protected]
Which JavaScript Runtime is this issue in?
Node.js
Details of the browser/Node.js/ReactNative version
v19.1.0
Reproduction Steps
Steps to Reproduce
- Please clone the repository Link
This repository contains a small Serverless Project which uses@aws-sdk/[email protected]
although it can be reproduced with any of the @AWS-SDK packages. - After cloning, Install the packages
npm install
- Bundle the files using Webpack
npm run bundle
- Deploy the project
serverless deploy --stage dev --region <REGION>
( I personally tried withap-southeast-1
andap-south-1
) - After deployment, a lambda function named
listEvents
and aevents-table-dev
DynamoDB table is created. - For this small demo app, we can manually insert a record into the table say:
{
"eventId": "8308b806-bf05-49f4-a61d-6c827554ca60",
"eventName": "Dummy Event"
}
Now From the Lambda Console, please invoke using the test event as below
{
"eventId": "8308b806-bf05-49f4-a61d-6c827554ca60"
}
Observed Behavior
Observed Behaviour
After we invoke the Lambda Function using the above test event
The following response is returned
{
"statusCode": 500,
"body": {
"code": "MODULE_NOT_FOUND",
"requireStack": [
"/var/task/listEvents/index.js",
"/var/runtime/index.mjs"
]
}
}
Following is the detailed CloudWatch Log for the same
2024-01-26T05:33:33.656Z 513845a7-5bb9-4b32-8e30-5f7ccdb54bc8 INFO Error: Cannot find module '../564/index.js'
Require stack:
- /var/task/listEvents/index.js
- /var/runtime/index.mjs
at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
at Module._load (node:internal/modules/cjs/loader:922:27)
at Module.require (node:internal/modules/cjs/loader:1143:19)
at require (node:internal/modules/cjs/helpers:119:18)
at __webpack_require__.f.require (/var/task/listEvents/index.js:21535:28)
at /var/task/listEvents/index.js:21474:40
at Array.reduce (<anonymous>)
at __webpack_require__.e (/var/task/listEvents/index.js:21473:67)
at fromSSO.fromSSO (/var/task/listEvents/index.js:8859:59)
at /var/task/listEvents/index.js:14871:39 {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/var/task/listEvents/index.js', '/var/runtime/index.mjs' ]
}
The above error where it references a folder ../564/index.js
is for the @aws-sdk/credential-provider-node
while bundled.
This should be bundled within the index.js
files if used. It didn't happen before this version(v3.499.0) release.
The issue is within the lambda runtime as we haven't included any of the AWS SDK Packages and are using the ones within the Lambda Runtime.
Expected Behavior
Expected Behaviour can be replicated by locally invoking the lambda as it doesn't use the bundled version of the files
Command To Get the Expected Response
serverless invoke local --function listEvents --data '{"eventId": "8308b806-bf05-49f4-a61d-6c827554ca60" }'
Response
{
"statusCode": 200,
"body": [
{
"eventId": "8308b806-bf05-49f4-a61d-6c827554ca60",
"eventName": "Dummy Event"
}
]
}
Possible Solution
No response
Additional Information/Context
No response