Skip to content
This repository has been archived by the owner on Mar 11, 2024. It is now read-only.

Commit

Permalink
Add cors option
Browse files Browse the repository at this point in the history
  • Loading branch information
pjuniorlima committed Feb 5, 2021
1 parent c76d64e commit 6ffefd7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ resource "aws_s3_bucket" "s3_default" {
force_destroy = var.force_destroy
acl = var.acl

dynamic "cors_rule" {
for_each = var.cors_rule_inputs == null ? [] : var.cors_rule_inputs

content {
allowed_headers = cors_rule.value.allowed_headers
allowed_methods = cors_rule.value.allowed_methods
allowed_origins = cors_rule.value.allowed_origins
expose_headers = cors_rule.value.expose_headers
}
}

versioning {
enabled = var.versioning
}
Expand Down
11 changes: 11 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,15 @@ variable "force_destroy" {
type = bool
default = false
description = "A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable."
}

variable "cors_rule_inputs" {
type = list(object({
allowed_headers = list(string)
allowed_methods = list(string)
allowed_origins = list(string)
expose_headers = list(string)
}))
default = null
description = "Specifies the allowed headers, methods, origins and exposed headers when using CORS on this bucket"
}

0 comments on commit 6ffefd7

Please sign in to comment.