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

[login] allow sourcing STS credentials from environment (closes #861) #864

Conversation

christophetd
Copy link
Contributor

@christophetd christophetd commented Feb 11, 2022

Sample usage:

export AWS_ACCESS_KEY_ID=ASIA25...
export AWS_SECRET_ACCESS_KEY=ASyJq4...
export AWS_SESSION_TOKEN=IQoJb3JpZ2luX2Vj...
aws-vault login --from-env

Sample error:

export AWS_ACCESS_KEY_ID=ASIA25...
export AWS_SECRET_ACCESS_KEY=ASyJq4...
aws-vault login --from-env

aws-vault: error: login: failed to retrieve a session token. Cannot generate a login URL without it
exit status 1

Main use-case: Allow generating sign-in links when temporary credentials have been obtained from another way than aws-vault. There is third-party tooling doing it such as https://github.com/NetSPI/aws_consoler, but I feel like it's worth it to have it built in aws-vault.

Notes:

  • While we could support login --from-env with only IAM credentials, it would a bit more complex (retrieve from environment, then use the GetFederationToken provider) for something that IMHO doesn't add value. If you have IAM credentials, they are long-lived by definition and they should be managed through aws-vault anyway

@mtibben
Copy link
Member

mtibben commented Feb 16, 2022

Hmm I wonder if --from-env is even required. If the profile is missing, source from the environment?

That would also allow workflows such as

$ aws-vault exec foo
foo $ aws s3 ls
foo $ aws-vault login

Where aws-vault could use the environment to login from within an exec subshell.

Any downsides to that approach?

@christophetd
Copy link
Contributor Author

Good point, and it's a workflow I've needed multiple times. The only downside I see is that if you run aws-vault login without creds in your environment and forget the profile name, which error message to display? We're unsure if the user expected to have creds in the environment, or if they just forgot the profile name

@christophetd
Copy link
Contributor Author

Done in bfbbfda, let me know how that looks!

@christophetd
Copy link
Contributor Author

@mtibben I've been using this feature locally for a few days, works great for me. Let me know if you require any changes!

@christophetd
Copy link
Contributor Author

@mtibben Eager to get this merged as I'm using it every day and I'm sure it will be useful to other folks. :) Let me know any way I can help!

@christophetd christophetd force-pushed the login-source-credentials-from-environment branch from 9d26b0e to d07990f Compare March 7, 2022 09:51
@mtibben mtibben merged commit f8eab90 into 99designs:master Mar 7, 2022
@christophetd christophetd deleted the login-source-credentials-from-environment branch March 8, 2022 05:44
@christophetd
Copy link
Contributor Author

Thanks for the review, when's the next release planned for?

@mtibben
Copy link
Member

mtibben commented Mar 8, 2022

Out now! I made one modification to the error message - hope this is OK? 67d1aea

@christophetd
Copy link
Contributor Author

No strong opinion. Having this behavior in usage docs would have made it easier to discover, possibly?

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.

2 participants