aws / aws-sdk-js-v3

Modularized AWS SDK for JavaScript.
Apache License 2.0
3.04k stars 569 forks source link

Required region in IAM Client #6343

Open anhnh131 opened 1 month ago

anhnh131 commented 1 month ago

Checkboxes for prior research

Describe the bug

In aws-sdk v2, the IAM region was not required, but in v3, an error occurs "Error: Region is missing" if there is no region. same issue https://github.com/aws/aws-sdk-js-v3/issues/1995, but I think it isn't fixed.

SDK version number

@aws-sdk/client-iam@3.620.0

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

v18.18.2

Reproduction Steps

execute source code

async function iam_summary_test() {
    const iam = new IAMClient({ credentials: makeCredentials() })
    const command = new GetAccountAuthorizationDetailsCommand({});
    const data = await iam.send(command);

    return data
}

Observed Behavior

Throw error Region is missing

Expected Behavior

Work properly

Possible Solution

No response

Additional Information/Context

No response

zshzbh commented 1 month ago

Hey @anhnh131 ,

Sorry this this experience, I confirm that I can reproduce this issue.

SDK version : @aws-sdk/client-iam 3.621.0

Code I have :

import {IAMClient,GetAccountAuthorizationDetailsCommand} from '@aws-sdk/client-iam'
async function iam_summary_test() {
    const iam = new IAMClient()
    const command = new GetAccountAuthorizationDetailsCommand({});
    const data = await iam.send(command);
    console.log(data);
    return data
    }

    await iam_summary_test()

Error message:

/Users/zshzbh/Desktop/newProj/node_modules/@smithy/config-resolver/dist-cjs/index.js:117
    throw new Error("Region is missing");
          ^

I will report this issue to the JS SDK SDE team. I will let you know if we have any updates!

Thanks! Maggie

zshzbh commented 1 month ago

Hey @anhnh131 ,

Thank you for bringing this up! We have put this issue in the queue.

While waiting for the fix in the pkg, there's some workarounds to unblock your work for now. I'm sharing 2 ways to configure the region:

  1. You can put the service region(eg: us-west-1) in the client config input for now

    const iam = new IAMClient({region: 'us-east-1'});
  2. You can add region in the aws config file.

    Screenshot 2024-08-01 at 12 44 18 PM

Thanks! Maggie