cloudflare / cloudflare-docs

Cloudflare’s documentation
https://developers.cloudflare.com
Creative Commons Attribution 4.0 International
2.9k stars 3.24k forks source link

R2 with Terraform configuration missing `region` mandatory argument #8634

Closed garysassano closed 11 months ago

garysassano commented 1 year ago

Which Cloudflare product does this pertain to?

Terraform

Existing documentation URL(s)

Section that requires update

terraform {
  required_providers {
    aws = {
      source = "hashicorp/aws"
      version = "4.20.1"
    }
  }
}

provider "aws" {
  access_key = <R2 Access Key>
  secret_key = <R2 Secret Key>
  skip_credentials_validation = true
  skip_region_validation = true
  skip_requesting_account_id = true
  endpoints {
    s3 = "https://<account id>.r2.cloudflarestorage.com"
  }
}

resource "aws_s3_bucket" "cloudflare-bucket" {
  bucket = "my-tf-test-bucket"
}

What needs to change?

provider "aws" {
  access_key = <R2 Access Key>
  secret_key = <R2 Secret Key>
  skip_credentials_validation = true
  skip_region_validation = true
  skip_requesting_account_id = true
  endpoints {
    s3 = "https://<account id>.r2.cloudflarestorage.com"
  }
}

How should it change?

provider "aws" {
  region = "auto"
  access_key = <R2 Access Key>
  secret_key = <R2 Secret Key>
  skip_credentials_validation = true
  skip_region_validation = true
  skip_requesting_account_id = true
  endpoints {
    s3 = "https://<account id>.r2.cloudflarestorage.com"
  }
}

Additional information

I tried to deploy the configuration provided in the docs with CDKTF and got the following error:

 Error: creating Amazon S3 (Simple Storage) Bucket (test-bucket): MissingRegion: could not find region configuration

   with aws_s3_bucket.R2Bucket_test-bucket (R2Bucket_test-bucket),
   on cdk.tf.json line 38, in resource.aws_s3_bucket.R2Bucket_test-bucket (R2Bucket_test-bucket):
   38:       }

So I tried to add an AWS region and got this other error:

 Error: creating Amazon S3 (Simple Storage) Bucket (test-bucket): InvalidRegionName: The region name 'eu-central-1' is not valid. Must be one of: wnam, enam, weur, eeur, apac, auto
      status code: 400, request id: , host id: 

   with aws_s3_bucket.R2Bucket_test-bucket (R2Bucket_test-bucket),
   on cdk.tf.json line 38, in resource.aws_s3_bucket.R2Bucket_test-bucket (R2Bucket_test-bucket):
   38:       }

So I renamed the region to auto and it worked.

dcpena commented 11 months ago

This was addressed as part of PR https://github.com/cloudflare/cloudflare-docs/pull/10887.