aws / aws-sdk-js-v3

Modularized AWS SDK for JavaScript.
Apache License 2.0
2.98k stars 560 forks source link

Region is missing : CognitoIdentityProviderClient #5965

Closed howdyhyber closed 3 months ago

howdyhyber commented 3 months ago

Checkboxes for prior research

Describe the bug

I specified the region already, it works in local but it doesn't work in production.

SDK version number

"@aws-sdk/client-cognito-identity": "^3.549.0", "@aws-sdk/client-cognito-identity-provider": "^3.549.0", "@aws-sdk/credential-provider-cognito-identity": "^3.549.0"

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

v16.14.2

Reproduction Steps

const credentials = fromCognitoIdentityPool({
                clientConfig: { region: "ap-southeast-1" },
                identityPoolId: aws_cognito_identity_pool_id,
                logins: {
                    [`cognito-idp.ap-southeast-1.amazonaws.com/xxxx`]: jwtToken
                }
            });

            let client = new CognitoIdentityProviderClient(
                {
                    region: "ap-southeast-1",
                    credentials
                }
            )

            try {
                let data = await client.send(command);
                // process data.
                console.log("Data : ", data);
                resolve({ message: "okay" });
            } catch (error) {
                // error handling.
                console.log("Error : ", error);
                resolve({ message: "not okay" });
            }

Observed Behavior

Works when run locally, does not run in production

Expected Behavior

Based on the current code, it should work, the config is right

Possible Solution

No response

Additional Information/Context

No response

kuhe commented 3 months ago

please provide the full stack trace of the error

RanVaknin commented 3 months ago

Hi @howdyhyber ,

It's not clear what your production environment looks like.

Your code seems correct, and the fact that it works locally points to a potential problem with the environment itself.

Like @kuhe suggested, can you please share the full stack trace for the error and perhaps tell us more about the environment in which you are executing the SDK code?

Thanks, Ran~

howdyhyber commented 3 months ago

I figured out what the problem is, I did not use @aws-sdk/credential-provider-cognito-identity because it is said in npm in its usage info, "You probably shouldn't, at least directly. Please use [@aws-sdk/credential-providers (https://www.npmjs.com/package/@aws-sdk/credential-providers) instead." I used @aws-sdk/credential-providers and it is perfectly working now.

github-actions[bot] commented 2 months ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.