Skip to content

auth/aws: keep auth_type in InternalData so renewal works without it in iam_metadata - #32186

Open
locker95 wants to merge 2 commits into
hashicorp:mainfrom
locker95:fix/aws-renew-auth-type
Open

locker95 wants to merge 2 commits into
hashicorp:mainfrom
locker95:fix/aws-renew-auth-type

Conversation

@locker95

@locker95 locker95 commented Nov 4, 2026

Copy link
Copy Markdown

Description

Fixes #32183

AWS auth renewal picked the renew path from auth_type in the token metadata, and that key is only there when it's listed in iam_metadata / ec2_metadata. With something like iam_metadata=account_id, IAM tokens got renewed as EC2 and failed with "instance_id" not found in auth metadata.

This puts auth_type into InternalData at login (same as canonical_arn, role_name etc. that renew already reads from there) and reads it back with getMetadataValue, so it still falls back to Metadata and then ec2 for older leases.

Added a test that logs in through the mock STS server with auth_type left out of iam_metadata and renews; it fails on main with the error from the issue. go test ./builtin/credential/aws/ passes.

@locker95
locker95 requested review from a team as code owners November 4, 2026 19:41
@locker95
locker95 requested a review from clemon November 4, 2026 19:41
@locker95
locker95 force-pushed the fix/aws-renew-auth-type branch 20 times, most recently from 4bd4ccb to 10c953d Compare November 11, 2026 19:20
@locker95
locker95 force-pushed the fix/aws-renew-auth-type branch 7 times, most recently from 6185b62 to bfdc517 Compare November 18, 2026 01:14
@locker95
locker95 force-pushed the fix/aws-renew-auth-type branch 10 times, most recently from f273f8c to 7c5a934 Compare November 25, 2026 07:28
@locker95
locker95 force-pushed the fix/aws-renew-auth-type branch from 7c5a934 to 34c4711 Compare November 25, 2026 19:46
pathLoginRenew read auth_type from the token metadata only and fell back
to ec2 when it was missing. auth_type is only present there when it is
listed in iam_metadata/ec2_metadata, so IAM logins with a config that
leaves it out were renewed as EC2 tokens and failed with
"instance_id" not found in auth metadata.

Store auth_type in InternalData at login, like the other values that
renewal relies on, and read it with getMetadataValue so older leases
that only carry it in Metadata keep working.
@locker95
locker95 force-pushed the fix/aws-renew-auth-type branch from 34c4711 to 303a078 Compare November 26, 2026 07:48

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AWS auth: token renewal fails when iam_metadata omits auth_type ("instance_id" not found in auth metadata)

1 participant