s3: Read AWS_EC2_METADATA_SERVICE_ENDPOINT for IAM credential resolution#6951
s3: Read AWS_EC2_METADATA_SERVICE_ENDPOINT for IAM credential resolution#6951jaisonerick wants to merge 1 commit intografana:mainfrom
Conversation
The S3 backend's IAM credential provider only reads TEST_IAM_ENDPOINT to override minio-go's default IMDS endpoint (169.254.169.254). This makes it impossible to use custom IMDS-compatible credential providers (e.g. AWS IAM Roles Anywhere credential helper) without setting a test-only env var. This adds AWS_EC2_METADATA_SERVICE_ENDPOINT as a fallback, matching the standard env var used by the AWS SDK. Priority: 1. TEST_IAM_ENDPOINT (backward compat) 2. AWS_EC2_METADATA_SERVICE_ENDPOINT (standard) 3. minio-go default (169.254.169.254)
|
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: db2faa8344
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| Transport: http.DefaultTransport, | ||
| }, | ||
| Endpoint: os.Getenv("TEST_IAM_ENDPOINT"), | ||
| Endpoint: iamEndpoint(), |
There was a problem hiding this comment.
Limit endpoint override to IMDS-only credential retrieval
Passing iamEndpoint() into credentials.IAM.Endpoint here affects more than IMDS in minio-go: IAM.RetrieveWithCredContext reuses Endpoint for the AWS_WEB_IDENTITY_TOKEN_FILE branch as the STS endpoint (see vendor/github.com/minio/minio-go/v7/pkg/credentials/iam_aws.go, case identityFile != ""). If AWS_EC2_METADATA_SERVICE_ENDPOINT is set in an IRSA/web-identity environment, credential exchange is sent to the IMDS URL instead of STS and auth fails. This regression is introduced by setting the endpoint unconditionally for all IAM provider modes.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Good catch on the shared Endpoint field — but this is a pre-existing issue with TEST_IAM_ENDPOINT, not something introduced by this PR. The current code:
Endpoint: os.Getenv("TEST_IAM_ENDPOINT"),has the exact same behavior: if TEST_IAM_ENDPOINT is set and AWS_WEB_IDENTITY_TOKEN_FILE is also set, the IMDS URL gets used as the STS endpoint. This PR just adds a standard env var as a fallback — it does not change how credentials.IAM.Endpoint is consumed.
The root issue is in minio-go: IAM.Endpoint is overloaded for both IMDS and STS paths. Fixing that belongs upstream in minio-go, not here.
In practice, AWS_EC2_METADATA_SERVICE_ENDPOINT is set in environments where IMDS is the credential source (custom IMDS proxies, IAM Roles Anywhere). It would not be set alongside AWS_WEB_IDENTITY_TOKEN_FILE in an IRSA environment.
|
Looks reasonable to me. @jaisonerick could you sign the license and add a line to the changelog? |
Summary
The S3 backend's IAM credential provider hardcodes
TEST_IAM_ENDPOINTas the only way to override minio-go's default IMDS endpoint (169.254.169.254). This makes it impossible to use custom IMDS-compatible credential providers — such as AWS IAM Roles Anywhere credential helper inservemode — without setting a test-only environment variable.This adds
AWS_EC2_METADATA_SERVICE_ENDPOINTas a standard fallback, matching the env var used by the AWS SDK for Go. Priority:TEST_IAM_ENDPOINT(backward compat, no behavior change for existing users)AWS_EC2_METADATA_SERVICE_ENDPOINT(standard AWS SDK env var)169.254.169.254)Motivation
When running Tempo outside of EC2/ECS (e.g., on a Raspberry Pi with IAM Roles Anywhere), the credential helper provides an IMDS-compatible endpoint on a custom address (
127.0.0.1:9911). The AWS SDK readsAWS_EC2_METADATA_SERVICE_ENDPOINTto find this endpoint, but Tempo's minio-go credential chain ignores it — causing a 90-second timeout against169.254.169.254followed byAccess Deniedon every S3 operation.Test plan
TEST_IAM_ENDPOINTbehavior is unchanged (checked first)