aws / aws/aws-tools-for-powershell
After using Invoke-AWSLogin cmdlet with the -region parameter, I cannot successufully use Get-AWSCredential cmdlet
- Dominant language
- C#
- Stars
- 298
- Forks
- 102
- Avg merge
- 7d 17m
- Merged PRs (30d)
- 2
Description
### Describe the bug
When I use the Invoke-AWSLogin cmdlet with the -region and -profilename parameter, the region value does not get written to the ~/.aws/config file for the named profile.
### Regression Issue
- [ ] Select this option if this issue appears to be a regression.
### Expected Behavior
> Invoke-AWSLogin -Region "us-east-1" -ProfileName "MyProfile"
[clipped]
> cat ~/.aws/config
[profile MyProfile]
login_session=arn:aws:sts::xxxxxxxxxxxx:assumed-role/XXXXXXX/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
region=us-east-1
### Current Behavior
> Invoke-AWSLogin -Region "us-east-1" -ProfileName "MyProfile"
[clipped]
> cat ~/.aws/config
[profile MyProfile]
login_session=arn:aws:sts::xxxxxxxxxxxx:assumed-role/XXXXXXX/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Comparatively, if i run the Invoke-AWSLogin command without the region and respond to the prompt, the region gets written to the config.
> Invoke-AWSLogin -ProfileName "MyProfile"
Press Ctrl+C to cancel the following login prompts.
Specify AWS Region
No AWS region has been configured. The AWS region is the geographic location of your AWS resources.
If you've used AWS before and already have resources in your account, tell us which region they were created in. If you
haven't created resources in your account before, you can pick the region closest to you:
https://docs.aws.amazon.com/global-infrastructure/latest/regions/aws-regions.html
AWS Region: us-east-1
Using region 'us-east-1'
Attempting to open the login page for 'us-east-1' in your default browser.
If the browser does not open, use the following URL to complete your login:
[clipped]
> cat ~/.aws/config
[profile MyProfile]
login_session=arn:aws:sts::xxxxxxxxxxxx:assumed-role/XXXXXXX/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
region=us-east-1
### Reproduction Steps
Import-Module AWSPowerShell.NetCore
Invoke-AWSLogin -Region "us-east-1" -ProfileName "MyProfile"
cat ~/.aws/config
### Possible Solution
Specifying a region on the Invoke-AWSLogin command allows for better automation without prompting for user input in the shell. Without the region getting persisted into the profile in the config, we're unable to get a credential object for the profile - the commands below fails with the listed error messages.
>Get-AWSCredential -ProfileName "MyProfile"
Get-AWSCredential: Value cannot be null. (Parameter 'Region')
>Get-AWSCredential -ProfileName "MyProfile" -Region "us-east-1"
Get-AWSCredential: A parameter cannot be found that matches parameter name 'Region'.
### Additional Information/Context
_No response_
### AWS Tools for PowerShell version used
> Get-AWSPowerShellVersion
AWS Tools for PowerShell
Version 5.0.274
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
Amazon Web Services SDK for .NET
Core Runtime Version 4.0.101.0
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
Release notes: https://github.com/aws/aws-tools-for-powershell/tree/main/changelogs
### PowerShell version used
> $PSVersionTable
Name Value
---- -----
PSVersion 7.5.1
PSEdition Core
GitCommitId 7.5.1
OS Darwin 25.5.0 Darwin Kernel Version 25.5.0: Tue Jun 9 22:28:34 PDT 2026; root:xnu-1237…
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
### Operating System and version
macOS Tahoe
Contributor guide
Assessment
This issue has not been assessed yet.