christophgysin / aws-sdk-js-v3

Modularized AWS SDK for JavaScript.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CredentialsProviderError: Could not load credentials from any providers

hlolli opened this issue · comments

Describe the bug

Long story short, it seems something is preventing Deno from getting CredentialProvider automatically (or via fromContainerMetadata manually) when it's running in a Fargate task with specified taskRole. This behavior differs from what I'm seeing what running two identical code snippets on nodejs and deno.

On nodejs I have this snippet

import { STSClient, GetCallerIdentityCommand } from "@aws-sdk/client-sts";

(async () => {
  const client = new STSClient();
  const command = new GetCallerIdentityCommand();
  const response = await client.send(command);
  console.log({ response });
})();

it prints

  response: {
    '$metadata': {
      httpStatusCode: 200,
      requestId: 'ELIDED',
      extendedRequestId: undefined,
      cfId: undefined,
      attempts: 1,
      totalRetryDelay: 0
    },
    UserId: 'ELIDED',
    Account: 'ELIDED',
    Arn: 'arn:aws:sts::ELIDED:assumed-role/xxx-xxx-fargate-role/xxxxxxxxxxxxxxxxxx'
  }

and Deno

import {
  STSClient,
  GetCallerIdentityCommand,
} from "https://deno.land/x/aws_sdk@v3.32.0-1/client-sts/mod.ts";

const client = new STSClient({});
const command = new GetCallerIdentityCommand({});
const response = await client.send(command);
console.log({ response });

I get

error: Uncaught (in promise) CredentialsProviderError: Could not load credentials from any providers
      throw new CredentialsProviderError("Could not load credentials from any providers", false);
            ^
    at providers (https://deno.land/x/aws_sdk@v3.32.0-1/credential-provider-node/mod.ts:67:13)
    at https://deno.land/x/aws_sdk@v3.32.0-1/property-provider/chain.ts:20:18
    at async coalesceProvider (https://deno.land/x/aws_sdk@v3.32.0-1/property-provider/memoize.ts:57:18)
    at async SignatureV4.credentialProvider (https://deno.land/x/aws_sdk@v3.32.0-1/property-provider/memoize.ts:79:18)
    at async SignatureV4.signRequest (https://deno.land/x/aws_sdk@v3.32.0-1/signature-v4/SignatureV4.ts:220:25)
    at async https://deno.land/x/aws_sdk@v3.32.0-1/middleware-signing/middleware.ts:26:18
    at async StandardRetryStrategy.retry (https://deno.land/x/aws_sdk@v3.32.0-1/middleware-retry/StandardRetryStrategy.ts:83:38)
    at async https://deno.land/x/aws_sdk@v3.32.0-1/middleware-logger/loggerMiddleware.ts:22:22
    at async file:///app/bug.ts:12:18

Your environment

SDK version number

@aws-sdk/package-name@version

https://deno.land/x/aws_sdk@v3.32.0-1

Details of the deno version

deno 1.22.1 (darwin locally, linux in ECS)

Greetings! We’re closing this issue because it has been open a long time and hasn’t been updated in a while and may not be getting the attention it deserves. We encourage you to check if this is still an issue in the latest release and if you find that this is still a problem, please feel free to comment or open a new issue.