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

region in config file profile not honored #1349

Closed
ghost opened this issue Jul 8, 2019 · 5 comments
Closed

region in config file profile not honored #1349

ghost opened this issue Jul 8, 2019 · 5 comments
Labels
blocked Work is blocked on this issue for this codebase. Other labels or comments may indicate why. breaking-change This issue requires a breaking change to remediate. bug This issue is a bug. closed-for-staleness

Comments

@ghost
Copy link

ghost commented Jul 8, 2019

Expected Behavior
Using config and credentials files together, the region defined in config is not honored.

Current Behavior
Unless defined elsewhere, a "no region" error is thrown.

Steps to Reproduce (for bugs)
~/.aws/credentials file contains (obfuscated of course):

[credprofile]
aws_access_key_id=ASIAABCDEFG
aws_secret_access_key=ABCDEFGHIJK012345
aws_session_token=ABCDEFGHIJK012345ABCDEFGHIJK012345ABCDEFGHIJK012345

~/.aws/config file contains:

[profile configprofile]
role_arn = arn:aws:iam::0123456789:role/my-crossaccount-role
source_profile = credprofile
region = us-east-2

Running an AWSPowershell cmdlet results in:

PS > Get-EC2Instance -ProfileName configprofile
Get-EC2Instance : No region specified or obtained from persisted/shell defaults.

Your Environment

  • Affected module: AWSPowerShell and AWSPowerShell.NetCore
  • Module version: 3.3.509.0 for both.
  • Operating System and version: Microsoft Windows 10.0.17763
  • PowerShell versions: Desktop: 5.1.17763.503, Core: 6.2.1
@matteo-prosperi matteo-prosperi transferred this issue from aws/aws-tools-for-powershell Jul 10, 2019
@matteo-prosperi
Copy link
Contributor

Transferring this issue to the AWS SDK for .NET repository because the root cause of the issue is there.
For reference, this is tracked internally as DOTNET-3195.

@matteo-prosperi matteo-prosperi added blocked Work is blocked on this issue for this codebase. Other labels or comments may indicate why. breaking-change This issue requires a breaking change to remediate. bug This issue is a bug. labels Jul 10, 2019
@matteo-prosperi
Copy link
Contributor

matteo-prosperi commented Jul 10, 2019

Useful references.

Similar issues for other SDKs are here: aws/aws-sdk-java#1707, boto/botocore#1511.
The format of the config file is defined here.

@matteo-prosperi
Copy link
Contributor

This is a known issue related with the AWS SDK for .NET (and possibly other SDKs) looking for a [profile default] entry (instead of a [default] entry) in the config file.
Fixing this issue has backward compatibility concerns: this would change the behavior for:

  • users who have [profile default] in their config file because that configuration would not be used anymore (unless we allow reading [profile default] as fallback in case [default] is not present.
  • users who have [default] in their config file because we would start using that configuration.
  • users who have both [default] and [profile default] in their config file (with different configurations) because we would switch from using the latter to the former.

We will likely be able to address this only in a major version bump of the SDK when subtle backward incompatible changes are expected.

@jgardsentry You could try one of these workarounds:

  • Add a [profile default] section to the ~/.aws/config file. You can also leave a [default] section with the same configurations in the file in order not to break the behavior of the AWS CLI or other SDKs.
  • Add the region configuration to the [default] section in the ~/.aws/credentials file.

@github-actions
Copy link

We have noticed this issue has not recieved attention in a year. We will close this issue for now. If you think this is in error, please feel free to comment and reopen the issue.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Jul 10, 2020
@github-actions github-actions bot added closed-for-staleness and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Jul 17, 2020
@tucomel
Copy link

tucomel commented Aug 16, 2022

dotnet does not respect the profile selected for the region, it always uses the default.
i have on my .aws\config file 2 profiles

[default]
region = us-east-1
[profile southamerica]
region = sa-east-1

im passing the second profile but the dotnet still use default

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Work is blocked on this issue for this codebase. Other labels or comments may indicate why. breaking-change This issue requires a breaking change to remediate. bug This issue is a bug. closed-for-staleness
Projects
None yet
Development

No branches or pull requests

2 participants