Skip to content

[do not merge] feat: support account id in imds / new profile configs #3067

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lucix-aws
Copy link
Contributor

@lucix-aws lucix-aws commented Apr 17, 2025

DO NOT MERGE: the new -extended metadata endpoint is not yet available.

  • Support the new *-extended/ credentials endpoint for IMDS, with automatic fallback to the old one
  • Add support for AWS_EC2_INSTANCE_PROFILE_NAME and friends
  • Retrieve account ID in IMDS calls (on both the new and legacy endpoint per SEP).
  • Add implicit profile caching. This has actually been specified in older IMDS credential SEPs, but we never did it for some reason.

@lucix-aws lucix-aws requested a review from a team as a code owner April 17, 2025 21:08
@lucix-aws lucix-aws force-pushed the feat-imdsaccountid branch from 6bb19ab to 17dd424 Compare April 18, 2025 16:52
@lucix-aws lucix-aws force-pushed the feat-imdsaccountid branch from 17dd424 to 49c542f Compare April 18, 2025 16:53
Copy link
Contributor

@Madrigal Madrigal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor c

restoreEnv := awstesting.StashEnv()
defer awstesting.PopEnv(restoreEnv)

os.Setenv("AWS_EC2_METADATA_SERVICE_ENDPOINT", ec2MetadataURL)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: use t.Setenv instead


func (c EnvConfig) getEC2InstanceProfileName() (string, bool, error) {
if len(c.EC2InstanceProfileName) == 0 {
return "", false, nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was discussed to err on this rather than leaving it empty. My main concern would be that someone would want to set this to something on their shell, like export AWS_EC2_INSTANCE_PROFILE_NAME=$(some_process_that_returns_a_value), and that something returns an empty string, then they would make a request to the base URL rather than to the profile they were trying to use

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was addressed but not here -- it actually uses Lookupenv to check for explicit empty in the main load routine.

@lucix-aws lucix-aws changed the title feat: support account id in imds / new profile configs [do not merge] feat: support account id in imds / new profile configs Apr 21, 2025
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.

3 participants