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

aws_s3_bucket doesn't support region #4310

Closed
failshell opened this issue Dec 14, 2015 · 5 comments
Closed

aws_s3_bucket doesn't support region #4310

failshell opened this issue Dec 14, 2015 · 5 comments

Comments

@failshell
Copy link

When creating an S3 bucket manually, it's possible to specify in which region you want the bucket to be in.

Although not in the doc, Terraform seems to accept the region parameter.

Code example:

resource "aws_s3_bucket" "logs_us_west_2" {
  bucket = "logs.uswest2"
  acl = "private"
  region = "us-west-2"

  tags { Name = "logs.uswest2" }
}

terraform plan seems to understand region though:

+ aws_s3_bucket.logs_us_west_1
    acl:              "" => "private"
    bucket:           "" => "logs.uswest1"
    force_destroy:    "" => "0"
    hosted_zone_id:   "" => "<computed>"
    region:           "" => "us-west-1"
    tags.#:           "" => "1"
    tags.Name:        "" => "logs.uswest1"
    website_domain:   "" => "<computed>"
    website_endpoint: "" => "<computed>"

So does terraform apply:

aws_s3_bucket.logs_us_west_1: Creating...
  acl:              "" => "private"
  bucket:           "" => "logs.uswest1"
  force_destroy:    "" => "0"
  hosted_zone_id:   "" => "<computed>"
  region:           "" => "us-west-1"
  tags.#:           "" => "1"
  tags.Name:        "" => "logs.uswest1"
  website_domain:   "" => "<computed>"
  website_endpoint: "" => "<computed>"
aws_s3_bucket.logs_us_west_1: Creation complete

But then, if you run terraform plan again, it tries to reconfigure the bucket to the proper region, as it was created in us-east-1 (us standard):

~ aws_s3_bucket.logs_us_west_1
    region: "us-east-1" => "us-west-1"

Would be great if aws_s3_bucket supported regions.

Note: this is with 0.6.3.

@failshell
Copy link
Author

Also, my provider is set to use us-east-1 (variable) as it's default region.

provider "aws" {
  access_key = "${var.access_key}"
  secret_key = "${var.secret_key}"
  region = "${var.region}"
}

@stack72
Copy link
Contributor

stack72 commented Dec 14, 2015

@failshell for this to work, you would have to do the following:

provider "aws" {
  access_key = "${var.access_key}"
  secret_key = "${var.secret_key}"
  region = "${var.region}"
}
provider "aws" {
  alias = "usw2"
  access_key = "${var.access_key}"
  secret_key = "${var.secret_key}"
  region = "${var.region}"
}

Then to create a bucket in us-west-2, it would be as follows:

resource "aws_s3_bucket" "logs_us_west_2" {
  bucket = "logs.uswest2"
  acl = "private"
  provider = "aws.usw2"

  tags { Name = "logs.uswest2" }
}

@stack72
Copy link
Contributor

stack72 commented Jul 5, 2016

Hi @failshell

I am going to close this as a duplicate. #6051 was opened and has a little more explanation of what seems to be the issue.

We are going to track the issue there

Thanks for opening the issue

Paul

@stack72 stack72 closed this as completed Jul 5, 2016
@apremalal
Copy link

@stack72 suggested fix doesn't seems to work with existing buckets. I tried to import a s3 bucket from a different region and then executed `terraform plan which resulted in a bad request error.

@ghost
Copy link

ghost commented Apr 7, 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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants