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

Add China arn compatibility. Use arn_prefix var for determinate which… #41

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ locals {
terraform_backend_config_template_file = var.terraform_backend_config_template_file != "" ? var.terraform_backend_config_template_file : "${path.module}/templates/terraform.tf.tpl"

bucket_name = var.s3_bucket_name != "" ? var.s3_bucket_name : module.s3_bucket_label.id

arn_prefix = "${substr(var.region, 0, 3) == "cn-" ? "arn:aws-cn" : var.arn_prefix}"
}

module "base_label" {
Expand Down Expand Up @@ -55,7 +57,7 @@ data "aws_iam_policy_document" "prevent_unencrypted_uploads" {
]

resources = [
"arn:aws:s3:::${local.bucket_name}/*",
"${local.arn_prefix}:s3:::${local.bucket_name}/*",
]

condition {
Expand Down Expand Up @@ -83,7 +85,7 @@ data "aws_iam_policy_document" "prevent_unencrypted_uploads" {
]

resources = [
"arn:aws:s3:::${local.bucket_name}/*",
"${local.arn_prefix}:s3:::${local.bucket_name}/*",
]

condition {
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ variable "region" {
description = "AWS Region the S3 bucket should reside in"
}

variable "arn_prefix" {
type = string
description = "AWS ARN prefix of resources. Because in China is different from the another regions"
default = "arn:aws"
}

variable "acl" {
type = string
description = "The canned ACL to apply to the S3 bucket"
Expand Down