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

Set region of aws provider via profile (i.e. from ~/.aws/config) #1767

Closed
herbrandson opened this issue Sep 28, 2017 · 12 comments
Closed

Set region of aws provider via profile (i.e. from ~/.aws/config) #1767

herbrandson opened this issue Sep 28, 2017 · 12 comments
Labels
bug Addresses a defect in current functionality. provider Pertains to the provider itself, rather than any interaction with AWS.

Comments

@herbrandson
Copy link

According to the docs for aws provider here (https://www.terraform.io/docs/providers/aws/#region), "region" is a required field which can be set "via a shared credentials file if profile is specified"

I read this to mean that if I configure my provider something like this

provider "aws" {
	profile = "stage"
}

and ~/.aws/config contains something like the following

[profile stage]
output = json
region = us-gov-west-1

the "region" argument should be set to "us-gov-west-1".

However, when I use this configuration and run terraform plan I get the following:

provider.aws.region
  The region where AWS operations will take place. Examples
  are us-east-1, us-west-2, etc.

  Default: us-east-1
  Enter a value:

Am I misunderstanding the documentation?

Terraform Version

Terraform v0.10.6

@kzw
Copy link

kzw commented Sep 28, 2017

I think you have the wrong format in your ~/.aws/config . Noprofile should appear when you specify your profile name. Please check examples found online

@herbrandson
Copy link
Author

The ~/.aws/config file was generated via the cli by using aws configure --profile stage. I should point out that there are two files in the ~/.aws/ directory. There's both a config and credentials. The aws key and secret are in the credentials file, but the region is in config.

@Ninir Ninir added bug Addresses a defect in current functionality. question A question about existing functionality; most questions are re-routed to discuss.hashicorp.com. labels Oct 11, 2017
@ekini
Copy link
Contributor

ekini commented Oct 12, 2017

Currently, as far as I understand, ~/.aws/config is not parsed at all. Some steps have been made to support it here #1608

However, it looks like the current code always overrides region anyway.

@danlsgiga
Copy link

I had the same issue today while configuring terraform aws provider to use a profile... the region is set in the profile but not respected by terraform.

@bflad bflad added provider Pertains to the provider itself, rather than any interaction with AWS. and removed question A question about existing functionality; most questions are re-routed to discuss.hashicorp.com. labels Jan 29, 2018
@lvampa
Copy link

lvampa commented Feb 20, 2018

+1 for this issue

Terraform v0.11.3
+ provider.aws v1.9.0

@kevinchabreck
Copy link

+1

Terraform v0.11.5
+ provider.aws v1.13.0

@chad-p
Copy link

chad-p commented Aug 1, 2018

+1

Terraform v0.11.7
`+ provider.aws v1.29.0

@tony-kerz
Copy link

yeah, this is effecting me as well.

apparently need to specify via AWS_DEFAULT_REGION or in tf backend/provider stanza's...

would be great to be able to specify in ~/.aws tho...

@delichty
Copy link

Any updates on this, or a targeted/expected version this may be fixed in?

@markwellis
Copy link

Still an issue with
Terraform v0.11.11
`+ provider.aws v1.56.0

@bflad
Copy link
Contributor

bflad commented Jul 7, 2020

Hi folks 👋 This appears to be a duplicate of #687, so to consolidate discussions and efforts, I'm going to close this issue in preference of that one. Please 👍 upvote that issue and subscribe to it for further updates on this topic.

@bflad bflad closed this as completed Jul 7, 2020
@ghost
Copy link

ghost commented Aug 6, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Aug 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. provider Pertains to the provider itself, rather than any interaction with AWS.
Projects
None yet
Development

No branches or pull requests