diff --git a/README.md b/README.md index 2e33561f..691150a4 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,7 @@ Functional examples are included in the | labels | Labels to be attached to the buckets | `map(string)` | `{}` | no | | lifecycle\_rules | List of lifecycle rules to configure. Format is the same as described in provider documentation https://www.terraform.io/docs/providers/google/r/storage_bucket.html#lifecycle_rule except condition.matches\_storage\_class should be a comma delimited string. |
set(object({
# Object with keys:
# - type - The type of the action of this Lifecycle Rule. Supported values: Delete and SetStorageClass.
# - storage_class - (Required if action type is SetStorageClass) The target Storage Class of objects affected by this Lifecycle Rule.
action = map(string)

# Object with keys:
# - age - (Optional) Minimum age of an object in days to satisfy this condition.
# - created_before - (Optional) Creation date of an object in RFC 3339 (e.g. 2017-06-13) to satisfy this condition.
# - with_state - (Optional) Match to live and/or archived objects. Supported values include: "LIVE", "ARCHIVED", "ANY".
# - matches_storage_class - (Optional) Comma delimited string for storage class of objects to satisfy this condition. Supported values include: MULTI_REGIONAL, REGIONAL, NEARLINE, COLDLINE, STANDARD, DURABLE_REDUCED_AVAILABILITY.
# - num_newer_versions - (Optional) Relevant only for versioned objects. The number of newer versions of an object to satisfy this condition.
condition = map(string)
}))
| `[]` | no | | location | Bucket location. | `string` | `"EU"` | no | +| logging | Map of lowercase unprefixed name => bucket logging config object. Format is the same as described in provider documentation https://www.terraform.io/docs/providers/google/r/storage_bucket.html#logging | `any` | `{}` | no | | names | Bucket name suffixes. | `list(string)` | n/a | yes | | prefix | Prefix used to generate the bucket name. | `string` | n/a | yes | | project\_id | Bucket project id. | `string` | n/a | yes | diff --git a/main.tf b/main.tf index 3a1b9556..dddedcb3 100644 --- a/main.tf +++ b/main.tf @@ -105,6 +105,13 @@ resource "google_storage_bucket" "buckets" { } } + dynamic "logging" { + for_each = lookup(var.logging, each.value, {}) != {} ? { v = lookup(var.logging, each.value) } : {} + content { + log_bucket = lookup(logging.value, "log_bucket", null) + log_object_prefix = lookup(logging.value, "log_object_prefix", null) + } + } } resource "google_storage_bucket_iam_binding" "admins" { diff --git a/variables.tf b/variables.tf index 2a9a89e2..5dd9dc6b 100644 --- a/variables.tf +++ b/variables.tf @@ -199,3 +199,9 @@ variable "website" { default = {} description = "Map of website values. Supported attributes: main_page_suffix, not_found_page" } + +variable "logging" { + description = "Map of lowercase unprefixed name => bucket logging config object. Format is the same as described in provider documentation https://www.terraform.io/docs/providers/google/r/storage_bucket.html#logging" + type = any + default = {} +}