Skip to content

Commit 7a0f82a

Browse files
authored
Parametrize the AWS ARN for S3 bucket policies (#39)
This change allows a user to override the AWS ARN (which to defaults to the most common use case of "arn:aws") in order to allow one to use this module in the AWS GovCloud/China regions. This can be done by setting the value of the arn_format variable to "arn:aws-us-gov"/"arn:aws-cn" respectively.
1 parent 9487b8d commit 7a0f82a

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ Available targets:
160160
|------|-------------|:----:|:-----:|:-----:|
161161
| acl | The canned ACL to apply to the S3 bucket | string | `private` | no |
162162
| additional_tag_map | Additional tags for appending to each tag map | map(string) | `<map>` | no |
163+
| arn_format | ARN format to be used. May be changed to support deployment in GovCloud/China regions. | string | `arn:aws` | no |
163164
| attributes | Additional attributes (e.g. `state`) | list(string) | `<list>` | no |
164165
| billing_mode | DynamoDB billing mode | string | `PROVISIONED` | no |
165166
| block_public_acls | Whether Amazon S3 should block public ACLs for this bucket | bool | `true` | no |

docs/terraform.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
|------|-------------|:----:|:-----:|:-----:|
55
| acl | The canned ACL to apply to the S3 bucket | string | `private` | no |
66
| additional_tag_map | Additional tags for appending to each tag map | map(string) | `<map>` | no |
7+
| arn_format | ARN format to be used. May be changed to support deployment in GovCloud/China regions. | string | `arn:aws` | no |
78
| attributes | Additional attributes (e.g. `state`) | list(string) | `<list>` | no |
89
| billing_mode | DynamoDB billing mode | string | `PROVISIONED` | no |
910
| block_public_acls | Whether Amazon S3 should block public ACLs for this bucket | bool | `true` | no |

main.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ data "aws_iam_policy_document" "prevent_unencrypted_uploads" {
5555
]
5656

5757
resources = [
58-
"arn:aws:s3:::${local.bucket_name}/*",
58+
"${var.arn_format}:s3:::${local.bucket_name}/*",
5959
]
6060

6161
condition {
@@ -83,7 +83,7 @@ data "aws_iam_policy_document" "prevent_unencrypted_uploads" {
8383
]
8484

8585
resources = [
86-
"arn:aws:s3:::${local.bucket_name}/*",
86+
"${var.arn_format}:s3:::${local.bucket_name}/*",
8787
]
8888

8989
condition {

variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ variable "region" {
8787
description = "AWS Region the S3 bucket should reside in"
8888
}
8989

90+
variable "arn_format" {
91+
type = string
92+
default = "arn:aws"
93+
description = "ARN format to be used. May be changed to support deployment in GovCloud/China regions."
94+
}
95+
9096
variable "acl" {
9197
type = string
9298
description = "The canned ACL to apply to the S3 bucket"

0 commit comments

Comments
 (0)