AWS credentials retrieved from AWS SSO not available in PowerShell
See original GitHub issueDescription
Credentials obtained from the AWS CLI v2 via AWS SSO should be available to PowerShell modules
Reproduction Steps
- Login via AWS SSO using AWS CLI v2
aws sso login --profile dev - Confirm credentials retrieved
aws sts get-caller-identity - Try to use credentials from PowerShell
Get-StsCallerIdentity -ProfileName dev. This fails reporting Get-STSCallerIdentity: Value cannot be null. (Parameter ‘Options property cannot be empty: ClientName’)
Environment
- Build Version: 4.1.10.0
- OS Info: Windows 10
- Build Environment: Terminal
This is a 🐛 bug-report
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Using AWS Credentials - AWS Tools for PowerShell
Each AWS Tools for PowerShell command must include a set of AWS credentials, which are used to cryptographically sign the corresponding web service...
Read more >AWSCredentialsFactory.TryGetAWSCredentials() returns ...
TryGetAWSCredentials () returns invalid SSOAWSCredentials #1821 ... AWS credentials retrieved from AWS SSO not available in PowerShell ...
Read more >Never put AWS temporary credentials in the ... - Ben Kehoe
Here's a well-trafficked GitHub issue on the CLI stating credentials stored by the CLI when AWS SSO do not conform to “AWS standards”,...
Read more >Resolve "Unable to locate credentials" error in Amazon S3
An "Unable to locate credentials" error indicates that Amazon S3 can't find the credentials to authenticate AWS API calls. To resolve this issue, ......
Read more >The AWS Access Key Id does not exist in our records
It looks like some values have been already set for the environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
With AWS Powershell Tools version
4.1.13.0, the reported error is gone, but now we get another error:However, installing and loading 2 more modules resolved the issue: Reference: https://docs.aws.amazon.com/powershell/latest/userguide/pstools-getting-set-up-windows.html
AWS.Tools modular version
4.1.13.0using commandUpdate-AWSToolsModule -CleanUp.Install-AWSToolsModule -Name AWS.Tools.SSOOIDCInstall-AWSToolsModule -Name AWS.Tools.SSOImport-Module AWS.Tools.SSOOIDCImport-Module AWS.Tools.SSOAWSPowerShell.NetCore large module
4.1.13.0ofAWSPowerShell.NetCoreusing commandInstall-Module -name AWSPowerShell.NetCore. OR4.1.13.0ofAWSPowerShell.NetCoreusing commandsUninstall-Module -Name AWSPowerShell.NetCore -AllVersionsandInstall-Module -name AWSPowerShell.NetCoreImport-Module AWSPowerShell.NetCoreUsing AWS CLI:
aws sso login --profile <INSERT-YOUR-PROFILE-NAME-HERE>Executing
Get-StsCallerIdentity -ProfileName <INSERT-YOUR-PROFILE-NAME-HERE>now works:@cpaton Please verify the fix using the above steps. Kindly let me know if this issue could be closed.
Thanks, Ashish
Yep - same for me. I can get my sso login to work with the aws cli, and boto3 will piggyback off this for python use, but I don’t seem to be able to login directly using powershell, or piggyback off a cli login like I can in python. The company I work at has now exclusivesly moved over to sso (no access or secret keys) for all AWS logins, so this basically rules out any powershell use with aws, which is a shame.
UPDATE
Some good news - It seems it’s not overly difficult to write a routine to lift the credentials from the AWS CLI and use them in PoSh - I got the crude PoC working below to return EC2 Instances using SSO on PoSh:
So you would login using the normal CLI and SSO:
And then you can use the temporary token from PoSh with a bit of work:
Or if you prefer you can even shadow the original profile and/or set a default - be careful if you do shadow it - the original script will fail if ran twice so more work would be needed to select the non-shadowed version of the profile for the initial call to get the URL… it might make more sense just to append ‘_sso’ or similar to the original profile name to avoid confusion.