Skip to content

Commit

Permalink
Merge pull request #19 from ministryofjustice/cors-rules
Browse files Browse the repository at this point in the history
add cors_rule support to s3 module
  • Loading branch information
mtrbls authored Nov 12, 2019
2 parents 7bf4975 + bf57c92 commit b83c140
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
26 changes: 24 additions & 2 deletions example/s3.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,34 @@ module "example_team_s3_bucket" {
aws = "aws.london"
}

/*
* The following example can be used if you need to define CORS rules for your s3 bucket.
* Follow the guidance here "https://www.terraform.io/docs/providers/aws/r/s3_bucket.html#using-cors"
*
cors_rule =[
{
allowed_headers = ["*"]
allowed_methods = ["GET"]
allowed_origins = ["https://s3-website-test.hashicorp.com"]
expose_headers = ["ETag"]
max_age_seconds = 3000
},
{
allowed_headers = ["*"]
allowed_methods = ["PUT"]
allowed_origins = ["https://s3-website-test.hashicorp.com"]
expose_headers = [""]
max_age_seconds = 3000
},
]
/*
* The following example can be used if you need to set a lifecycle for your s3.
* Follow the guidance here "https://www.terraform.io/docs/providers/aws/r/s3_bucket.html#using-object-lifecycle"
* "https://docs.aws.amazon.com/AmazonS3/latest/dev/object-lifecycle-mgmt.html"
*
*
lifecycle_rule = [
{
enabled = true
Expand Down
2 changes: 2 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ resource "aws_s3_bucket" "bucket" {
policy = "${data.template_file.bucket_policy.rendered}"

lifecycle_rule = "${var.lifecycle_rule}"

cors_rule = "${var.cors_rule}"

server_side_encryption_configuration {
rule {
Expand Down
5 changes: 5 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,8 @@ variable "lifecycle_rule" {
description = "lifecycle"
default = []
}

variable "cors_rule" {
description = "cors rule"
default = []
}

0 comments on commit b83c140

Please sign in to comment.