-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
[V2] Save temporary credentials in .aws/credentials for v1 compatibility #4676
Comments
Cannot +1 this enough. Without providing a mechanism to add the temp credentials too Many tools are used to provision infrastructure on-top of the various AWS SDK's, they all rely on creds in |
Agreed, this breaks lots...please allow a work around until other tools can implement fixes. |
This is required for the AWS Toolkits (PyCharm / VSC) to operate without manual intervention. |
Hi everyone, we do plan on addressing this. It's worth mentioning that, long-term,the plan is that all SDKs and CLIs (including CLI v1) will support SSO credentials, so all of the official AWS SDKs/CLIs will "just work." We launched this in CLI v2 early to get customer feedback. We did something similar years back when the CLI first added assume role support, with all the SDKs eventually adding support. However, the shorter term option that someone suggested that I like is being able to export your current credentials as various formats. I forget the exact suggested command, but something like "aws configure export-creds" will do its normal credential loading, but then print them out in various formats. For example, it could print them out as The reason I like this approach of exporting your creds as env vars or config snippets, etc, is because it's decoupled from a specific credential provider so in theory will work for any new credential providers we add in the future. It will also work for cases today such as assume-role which also use a cache file instead of writing to Lastly, while I know it's convenient, I do want to mention that writing temporary credentials to It's be great to hear what others think of an "export credentials" command. |
How about adding an
and |
I like @pcolmer's idea of an Really, I'm OK with almost any way we can do this. I really, really want to use the new v2 command, but the fact that it doesn't play well with others is preventing me from fully embracing it right now. |
If you just syscall exec whatever comes after your |
The main issue I have with this is that on Windows, the CLI2 profiles now don't work with AWS Tools for powershell. Hopefully this gets addressed very soon. |
@sethbacon you could open an issue on the AWS Tools for PowerShell repo |
You should be leveraging the |
I was searching for a similar feature some time ago, with no luck. Here is my custom solution that does |
I can't express how frustrating it is not to be able to get KeyID and Secret from the commandline when it's clearly already implemented and just not exposed anywhere. The AWS SSO Portal will happily generate credentials on the website for you. The client is generating them and storing them in the ~/.aws/sso/cache/ directory, but there doesn't appear to be a way to map those filenames to a given profile. The solution given by @tarasrng above is just "grab the most recently modified JSON file there and hope that it's the right one". If you've got multiple consoles open and running commands, then there's no guarantees about who's going to be most recent. I've tried looking through the codebase but can't find anything obvious so far. Edit: Looks like awscli/customizations/sso/utils.py is responsible for that cache directory, and it uses Botocore's SSOTokenFetcher to manage it. I got lost in the code there - it seems like it's encoding the start URL, which makes me think that perhaps that cache file is re-used for each profile, but I'm uncertain at the moment. |
Yeah, for our project it would be great to login via SSO, and then get credentials for different accounts/roles to use with tools like Terraform. |
@felipesere the solution we've adopted for use with tools like Terraform is https://github.com/linaro-its/aws2-wrap |
@pcolmer That is brilliant! I'll take a closer look later today. Is it OK it port it to |
Absolutely! |
I gave up on trying to decode the AWS Source code and have written a script to brute-force finding the credentials from the local cache directory. Call it like so:
It takes a single parameter which is the AWS Profile name, for which it then determines the current Profile's ARN. Note that it requires I'm specifically writing it so that I can stuff the values into docker containers, so I'm outputting to ~/aws_credentials.$ProfileName See the Gist for the script: https://gist.github.com/willhughes-au/d74594e1c37259b003854dc02d8e144a I'd appreciate any bugfixes/suggestions. It works for me, but as with any code off the internet - take care, vet that it does what you want, and don't blame me if it runs up your AWS bill or deletes production. |
@pcolmer aws2-wrap is a lifesaver until Boto3 and the other SDKs catch up with sso support and/or aws sso adds one of the export options discussed here. Kudos! |
Throwing my hat into the ring. I wrote a tool, For people who want the raw credentials directly, they can also use this tool on its own, because the output of a credential process is a JSON object (to stdout) containing the current credentials, including the ability to refresh the credentials and/or the token if needed. |
Thanks @benkehoe, this is exactly whats needed until sso credentials become a first class citizen in the sdks. |
Now that #7398 has been merged, the An earlier comment on this issue provided more context on why this may be the better approach. |
I expected that
aws2 configure sso
would get secrets viaaws2 sso get-role-credentials
and save them in .aws/credentialsThe aws cli v1 and all current tools out there could continue using those temp credentials.
The text was updated successfully, but these errors were encountered: