Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use AWS sdk-v3 in ReactNative with DynamoDBClient and fromTemporaryCredentials. Returns Error: Credential is missing #5803

Closed
3 tasks done
rajleechaudry opened this issue Feb 16, 2024 · 3 comments
Assignees
Labels
bug This issue is a bug. closed-for-staleness p2 This is a standard priority issue response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days.

Comments

@rajleechaudry
Copy link

Checkboxes for prior research

Describe the bug

The issue is similar or identical to #4294, but doesn't seem solved. JS SDK V3 is compatible with ReactNative correct? Thanks for any guidance.

Errors with the combinations I've tried:

  1. If I include region: "us-east-1" at the top in opts, and clientConfig: { region : "us-east-1"} as below, then I get "Error: Credential is missing".
  2. If I don't include just the region: "us-east-1" at the top, I get "Region is missing".
  3. If I don't include both region statements, I get "Region is missing" <-- as I would expect
  4. If I don't include just the clientConfig: { region : "us-east-1"} I get "Region is missing".

I.E. Looks like I need both region elements, but the way I'm sending creds is bust anyway.

Code:


import { DynamoDBClient, ListTablesCommand } from "@aws-sdk/client-dynamodb";
import { fromTemporaryCredentials } from "@aws-sdk/credential-providers";

export async function mebananas(index: string, value: object) {
   try {
         const opts = {
            region: "us-east-1",
            credentials: fromTemporaryCredentials({
               params: {
                  RoleArn: "arn:aws:iam::<some long arn-id>",
               },
            clientConfig: { region : "us-east-1"},
            })
         }  

         const client = new DynamoDBClient(opts);
         const command = new ListTablesCommand({});
         const response = await client.send(command);
         
         console.log(response.TableNames?.join("\n"));

    } catch (err) {
       console.info("Bin Kaputs");
    }
}

### SDK version number

    "@aws-sdk/client-dynamodb": "^3.514.0",     "@aws-sdk/credential-providers": "^3.515.0",

### Which JavaScript Runtime is this issue in?

React Native

### Details of the browser/Node.js/ReactNative version

ReactNative 0.73 w/Fabric, New Arch

### Reproduction Steps


import { DynamoDBClient, ListTablesCommand } from "@aws-sdk/client-dynamodb";
import { fromTemporaryCredentials } from "@aws-sdk/credential-providers";

export async function mebananas(index: string, value: object) {
   try {
         const opts = {
            region: "us-east-1",
            credentials: fromTemporaryCredentials({
               params: {
                  RoleArn: "arn:aws:iam::<some long arn-id>",
               },
            clientConfig: { region : "us-east-1"},
            })
         }  

         const client = new DynamoDBClient(opts);
         const command = new ListTablesCommand({});
         const response = await client.send(command);
         
         console.log(response.TableNames?.join("\n"));

    } catch (err) {
       console.info("Bin Kaputs");
    }
}

### Observed Behavior

1. If I include **region: "us-east-1"** at the top in opts, and **clientConfig: { region : "us-east-1"}** as below, then I get "Error: Credential is missing".  
2. If I don't include just the **region: "us-east-1"** at the top, I get "Region is missing".
3. If I don't include both region statements, I get "Region is missing" <-- as I would expect
4. If I don't include just the  **clientConfig: { region : "us-east-1"}** I get "Region is missing".

### Expected Behavior

Umm, definitely not ^^^.  Expecting the name of a table to come back.

### Possible Solution

_No response_

### Additional Information/Context

_No response_
@rajleechaudry rajleechaudry added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Feb 16, 2024
@rajleechaudry rajleechaudry changed the title Cannot use sdk-v3 in ReactNative with DynamoDBClient and fromTemporaryCredentials. Returns Error: Credential is missing Cannot use AWS sdk-v3 in ReactNative with DynamoDBClient and fromTemporaryCredentials. Returns Error: Credential is missing Feb 17, 2024
@aBurmeseDev aBurmeseDev self-assigned this Feb 19, 2024
@kuhe
Copy link
Contributor

kuhe commented Feb 20, 2024

How are/were you providing credentials to the STS client used by fromTemporaryCredentials?

You need an initial set of credentials to use with fromTemporaryCredentials which can be supplied by the masterCredentials field.

https://www.npmjs.com/package/@aws-sdk/credential-providers#fromtemporarycredentials

@kuhe kuhe added response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days. p2 This is a standard priority issue and removed needs-triage This issue or PR still needs to be triaged. labels Feb 21, 2024
Copy link

github-actions bot commented Mar 2, 2024

This issue has not received a response in 1 week. If you still think there is a problem, please leave a comment to avoid the issue from automatically closing.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Mar 2, 2024
@github-actions github-actions bot closed this as completed Mar 6, 2024
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue is a bug. closed-for-staleness p2 This is a standard priority issue response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days.
Projects
None yet
Development

No branches or pull requests

3 participants