Create sessions in IMDS response for static keypair profiles#2
Merged
benkehoe merged 3 commits intobenkehoe:mainfrom Jul 26, 2023
Merged
Create sessions in IMDS response for static keypair profiles#2benkehoe merged 3 commits intobenkehoe:mainfrom
benkehoe merged 3 commits intobenkehoe:mainfrom
Conversation
Owner
|
I just wanted to say I see this, it's useful and needed, but I won't get to it until after re:Invent. And I'll need to do the same thing for aws-export-credentials as well. |
Owner
|
Finally getting around to this 😅. This looks good, but I've got some organizational refactoring for it, could I push that to your branch? Also, would you like to create a |
Contributor
Author
|
Happy to help - let me know if that works. |
Owner
|
This is great, thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When using imds with a static AWS keypair, the aws cli doesn't understand what to do with it when it appears via the metadata service. For example, let's say you have a static key ID/secret in a profile in aws-vault and use it to launch the credential server like so:
aws-vault exec --no-session myprofile -- ./imds-credential-serverThis normally would say "directly pass the keypair so I don't have an expiration".
The app itself doesn't complain because it can read the Principal just fine, but when it returns the keypair in metadata, sdk/cli clients return "no credentials found" because they don't expect to see anything other than a valid session in there.
This change (apologies for my mediocre Go) looks to see if there's a sessiontoken missing and if so, spins up a session to get one.
Why do this, you might ask, vs just having aws/aws-vault handle session generation, e.g.:
aws-vault exec myprofile -- ./imds-credential-serveror
./imds-credential-server --profile myprofileor otherwise?
The basic reason is that while I want to keep credentials off disk (and out of the .aws/credentials file!), I can't eliminate the need for longer lived keypairs just yet. This means storing credentials in things like aws-vault and 1Password.
1Password in particular is of note because it leverages credential_helper, and unlike aws-vault it typically gets configured for static credentials.
Let me know what you think!