Skip to content

TITLE FOR BUG REPORT #7427

@jfrabell

Description

@jfrabell

Checkboxes for prior research

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:

  1. Create a folder and run npm init -y.
  2. Run npm install @aws-sdk/client-cognito-identity-provider.
  3. 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.");
};
  1. Package the function: zip -r function.zip index.js node_modules
  2. Deploy using the AWS CLI: aws lambda create-function --function-name bug-repro-test
  3. 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

No one assigned

    Labels

    bugThis issue is a bug.needs-triageThis issue or PR still needs to be triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions