aws-lite icon indicating copy to clipboard operation
aws-lite copied to clipboard

ECS Fargate: ECS IMDSv2 token not found

Open beeequeue opened this issue 1 year ago • 2 comments

Describe the issue

I'm trying to use aws-lite in a ECS Fargate container, but ran into the ECS IMDSv2 token not found error when trying to make calls.

Expected behavior

For aws-lite to be able to create/find a token to call the API with

Steps to reproduce

  1. Call aws-lite from a ECS Fargate (only? I'm not sure, we only use Fargate) container
  2. See error

Platform / version

  • OS + version: ECS Fargate, node:alpine docker image
  • Node version: Node.js 22.8
  • Package manager version: pnpm 9.10

How urgent do you feel this bug is?

P2

Additional context

I tried to look through the sources for how the token is found to try to debug it more, but deploying our services takes forever and setting up a new one would take even longer, so I gave up and went back to using the official SDK.

beeequeue avatar Oct 03 '24 15:10 beeequeue

Seems like the aws-lite implementation for IMDS is incomplete. This is the aws-sdk solution which does a request to the IMDS service when the token or token file is missing in the container (which is the case here)

https://github.com/smithy-lang/smithy-typescript/blob/main/packages/credential-provider-imds/src/fromContainerMetadata.ts

Specifically, in my case and probably yours, only AWS_CONTAINER_CREDENTIALS_RELATIVE_URI exists in the environment.

https://github.com/smithy-lang/smithy-typescript/blob/c8d257b99707b880dc6500709269461477bbc321/packages/credential-provider-imds/src/fromContainerMetadata.ts#L71-L76

arpadgabor avatar Oct 28 '24 06:10 arpadgabor

I'm having the same issues. The IMDS incorrectly assumes that a token is required for all metadata requests. This is not the case in fargate where no authorization token is required. Setting AWS_CONTAINER_AUTHORIZATION_TOKEN env variable to a dummy value (for example AWS_CONTAINER_AUTHORIZATION_TOKEN="dummy") fixed the issue for me.

jriegel-unitb avatar Jun 17 '25 12:06 jriegel-unitb