Skip to content

Commit

Permalink
fix: Correct behavior of website and cors variables. (#132)
Browse files Browse the repository at this point in the history
* fixed websites, cors parameter

* generate_docs

* ignoring not defined website parameter

* moved cors parameter to type set
  • Loading branch information
odise authored Sep 17, 2021
1 parent 93ff75f commit 3e6e7f4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Functional examples are included in the
| bucket\_policy\_only | Disable ad-hoc ACLs on specified buckets. Defaults to true. Map of lowercase unprefixed name => boolean | `map(bool)` | `{}` | no |
| bucket\_storage\_admins | Map of lowercase unprefixed name => comma-delimited IAM-style per-bucket storage admins. | `map(string)` | `{}` | no |
| bucket\_viewers | Map of lowercase unprefixed name => comma-delimited IAM-style per-bucket viewers. | `map(string)` | `{}` | no |
| cors | Map of maps of mixed type attributes for CORS values. See appropriate attribute types here: https://www.terraform.io/docs/providers/google/r/storage_bucket.html#cors | `any` | `{}` | no |
| cors | Set of maps of mixed type attributes for CORS values. See appropriate attribute types here: https://www.terraform.io/docs/providers/google/r/storage_bucket.html#cors | `set(any)` | `[]` | no |
| creators | IAM-style members who will be granted roles/storage.objectCreators on all buckets. | `list(string)` | `[]` | no |
| encryption\_key\_names | Optional map of lowercase unprefixed name => string, empty strings are ignored. | `map(string)` | `{}` | no |
| folders | Map of lowercase unprefixed name => list of top level folder objects. | `map(list(string))` | `{}` | no |
Expand All @@ -77,7 +77,7 @@ Functional examples are included in the
| storage\_class | Bucket storage class. | `string` | `"MULTI_REGIONAL"` | no |
| versioning | Optional map of lowercase unprefixed name => boolean, defaults to false. | `map(bool)` | `{}` | no |
| viewers | IAM-style members who will be granted roles/storage.objectViewer on all buckets. | `list(string)` | `[]` | no |
| website | Map of website values. Supported attributes: main\_page\_suffix, not\_found\_page | `any` | `{}` | no |
| website | Map of website values. Supported attributes: main\_page\_suffix, not\_found\_page | `map(any)` | `{}` | no |

## Outputs

Expand Down
4 changes: 2 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ resource "google_storage_bucket" "buckets" {
}
}
dynamic "cors" {
for_each = lookup(var.cors, each.value, {}) != {} ? { v = lookup(var.cors, each.value) } : {}
for_each = var.cors
content {
origin = lookup(cors.value, "origin", null)
method = lookup(cors.value, "method", null)
Expand All @@ -89,7 +89,7 @@ resource "google_storage_bucket" "buckets" {
}
}
dynamic "website" {
for_each = lookup(var.website, each.value, {}) != {} ? { v = lookup(var.website, each.value) } : {}
for_each = length(keys(var.website)) == 0 ? toset([]) : toset([var.website])
content {
main_page_suffix = lookup(website.value, "main_page_suffix", null)
not_found_page = lookup(website.value, "not_found_page", null)
Expand Down
8 changes: 4 additions & 4 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,13 @@ variable "lifecycle_rules" {
}

variable "cors" {
description = "Map of maps of mixed type attributes for CORS values. See appropriate attribute types here: https://www.terraform.io/docs/providers/google/r/storage_bucket.html#cors"
type = any
default = {}
description = "Set of maps of mixed type attributes for CORS values. See appropriate attribute types here: https://www.terraform.io/docs/providers/google/r/storage_bucket.html#cors"
type = set(any)
default = []
}

variable "website" {
type = any
type = map(any)
default = {}
description = "Map of website values. Supported attributes: main_page_suffix, not_found_page"
}
Expand Down

0 comments on commit 3e6e7f4

Please sign in to comment.