-
Notifications
You must be signed in to change notification settings - Fork 633
Open
Labels
bugThis issue is a bug.This issue is a bug.needs-triageThis issue or PR still needs to be triaged.This issue or PR still needs to be triaged.
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
CognitoIdentityServiceProviderClient is not a constructor in Lambda Node.js 20 runtime
Regression Issue
- Select this option if this issue appears to be a regression.
SDK version number
@aws-sdk/client-cognito-identity-provider: 3.585.0 and 3.556.0
Which JavaScript Runtime is this issue in?
Node.js
Details of the browser/Node.js/ReactNative version
nodejs20.x
Reproduction Steps
The most minimal reproduction steps use the AWS CLI directly, bypassing all frameworks:
- Create a folder and run npm init -y.
- Run npm install @aws-sdk/client-cognito-identity-provider.
- Create an index.js file with the following code:
exports.handler = async (event) => {
// This line throws the error
const client = new CognitoIdentityServiceProviderClient({ region: 'us-east-2' });
console.log("Client instantiated successfully.");
};
- Package the function: zip -r function.zip index.js node_modules
- Deploy using the AWS CLI: aws lambda create-function --function-name bug-repro-test
- Invoke the function.
Observed Behavior
The function fails with a TypeError: CognitoIdentityServiceProviderClient is not a constructor. Diagnostic logging shows that the property on the required module is undefined.
Expected Behavior
The Lambda function should execute successfully, and the CognitoIdentityServiceProviderClient should be a valid constructor.
Possible Solution
No response
Additional Information/Context
This issue was troubleshooted for over 20 man hours. We confirmed the bug persists across:
- Serverless Framework v4 (with native and serverless-esbuild bundlers).
- Lambda Layers deployment.
- Different module formats (.js with "type": "module", .cjs).
- Multiple versions of the SDK.
The only successful workaround was to abandon the v3 SDK entirely and use the v2 aws-sdk package.
Metadata
Metadata
Assignees
Labels
bugThis issue is a bug.This issue is a bug.needs-triageThis issue or PR still needs to be triaged.This issue or PR still needs to be triaged.