aws-tools-for-powershell: AWS PowerShell NetCore module does not respect $env:AWS_PROFILE
Expected Behavior
Cmdlets in the AWSPowerShell.NetCore module should use the profile specified in $env:AWS_PROFILE.
Current Behavior
Cmdlets in the AWSPowerShell.NetCore module do not respect the $env:AWS_PROFILE variable.
Possible Solution
When the variable is specified, its value should be used as the value of “ProfileName”
Steps to Reproduce (for bugs)
- Create a named profile in ~/.aws/credentials
- Run a Cmdlet which allows specifying a profile via the
-ProfileNameparameter, but do not specify a value for that parameter.
Context
- Writing documentation which targets both PowerShell and bash environments is more cumbersome because credentials are specified differently.
- Explaining the use of the module to peers can be problematic because some environment variables are supported by the Cmdlets and some are not.
- Tooling which indicates what profile is currently in use is significantly harder to write; the value needs to be maintained and managed as separate state rather than assuming that this variable is authoritative.
- To my knowledge, it is not possible to check the currently active profile after running
Set-AWSCredential
Your Environment
- AWSPowerShell.NetCore version used: 3.3.365.0
- Service assembly and version used: n/a
- Operating System and version: Windows 10 1703
- Visual Studio version: n/a
- Targeted .NET platform: n/a
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 10
- Comments: 17 (8 by maintainers)
This issue appears to be Windows-specific. On MacOS the
AWS_PROFILEenvironment variable does affect the behavior of the AWS PS commands as expected, while on Windows it does not.Also, with the AWS IAM Identity Center supporting SSO, along with the CLI
aws sso logincommand, thecredentialsfile and credential profiles become non-applicable, so theSet-AWSCredential -ProfileName $env:AWS_PROFILEis no longer a work-around.5 years is a good run for a bug to go unfixed. Let’s make AWS PS usable with sso.
We are currently looking to include this in our next major version update.
@bgshacklett Thanks for your reply. AWS PowerShell tools use .NET Core SDK and it should work as per code https://github.com/aws/aws-sdk-net/blob/a7c91a25e5b78376d1bf91c13f55383518b4a57b/sdk/src/Core/Amazon.Runtime/Credentials/FallbackCredentialsFactory.cs#L56
However, I was able to verify the environment variable
AWS_PROFILEsomehow does not work with latest version of Powershell tools 4.1.8.0. This needs some investigation.