Skip to content

Commit

Permalink
Merge pull request #168 from tablexi/enable-cors
Browse files Browse the repository at this point in the history
Enable CORS on some static sites
  • Loading branch information
hammerdr authored Oct 19, 2020
2 parents 46d2a1f + 8b3f1ff commit 1ef1da6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions aws/static_site/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ resource "aws_s3_bucket" "mod" {
}
)

cors_rule {
allowed_headers = ["*"]
allowed_methods = ["GET"]
allowed_origins = var.enable_cors_get ? ["*"] : []
max_age_seconds = 3000
}

website {
index_document = var.index_document
error_document = var.index_document
Expand Down
5 changes: 5 additions & 0 deletions aws/static_site/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,8 @@ variable "tags" {
type = map(string)
}

variable "enable_cors_get" {
description = "Enables Cross Origin Resource Sharing (CORS) get requests from any origin."
type = bool
default = false
}

0 comments on commit 1ef1da6

Please sign in to comment.