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

feat: add support for EC2 Instance Identity roles #693

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion pkg/token/token.go
Expand Up @@ -623,6 +623,7 @@ func getIdentityFromSTSResponse(id *Identity, wrapper getCallerIdentityWrapper)
// 1. UserID:SessionName (for assumed roles)
// 2. UserID (for IAM User principals).
// 3. AWSAccount:CallerSpecifiedName (for federated users)
// 4. AWSAccount:aws:ec2-instance:instance-id (for EC2 instance identity roles)
// We want the entire UserID for federated users because otherwise,
// its just the account ID and is indistinguishable from the UserID
// of the root user.
Expand All @@ -634,7 +635,12 @@ func getIdentityFromSTSResponse(id *Identity, wrapper getCallerIdentityWrapper)
id.UserID = userIDParts[0]
id.SessionName = userIDParts[1]
} else {
return nil, NewSTSError(fmt.Sprintf("malformed UserID %q", result.UserID))
if len(userIDParts) == 4 && userIDParts[1] == "aws" && userIDParts[2] == "ec2-instance" {
id.UserID = userIDParts[1] + ":" + userIDParts[2]
id.SessionName = userIDParts[3]
} else {
return nil, NewSTSError(fmt.Sprintf("malformed UserID %q", result.UserID))
}
}
}

Expand Down