Skip to content

Commit

Permalink
Make logging variables top level for simple_bucket module
Browse files Browse the repository at this point in the history
  • Loading branch information
matty-rose committed Jun 2, 2021
1 parent 44dc037 commit d6c676e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
3 changes: 2 additions & 1 deletion modules/simple_bucket/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ Functional examples are included in the
| labels | A set of key/value label pairs to assign to the bucket. | `map(string)` | `null` | no |
| lifecycle\_rules | The bucket's Lifecycle Rules configuration. | <pre>list(object({<br> # Object with keys:<br> # - type - The type of the action of this Lifecycle Rule. Supported values: Delete and SetStorageClass.<br> # - storage_class - (Required if action type is SetStorageClass) The target Storage Class of objects affected by this Lifecycle Rule.<br> action = any<br><br> # Object with keys:<br> # - age - (Optional) Minimum age of an object in days to satisfy this condition.<br> # - created_before - (Optional) Creation date of an object in RFC 3339 (e.g. 2017-06-13) to satisfy this condition.<br> # - with_state - (Optional) Match to live and/or archived objects. Supported values include: "LIVE", "ARCHIVED", "ANY".<br> # - matches_storage_class - (Optional) Storage Class of objects to satisfy this condition. Supported values include: MULTI_REGIONAL, REGIONAL, NEARLINE, COLDLINE, STANDARD, DURABLE_REDUCED_AVAILABILITY.<br> # - num_newer_versions - (Optional) Relevant only for versioned objects. The number of newer versions of an object to satisfy this condition.<br> condition = any<br> }))</pre> | `[]` | no |
| location | The location of the bucket. | `string` | n/a | yes |
| logging | Configuration of the bucket's access and storage logs. If log\_object\_prefix is set to the empty string, the name of the bucket will be used. | <pre>object({<br> log_bucket = string<br> log_object_prefix = string<br> })</pre> | `null` | no |
| log\_bucket | The bucket that will receive log objects. | `string` | `null` | no |
| log\_object\_prefix | The object prefix for log objects. If it's not provided, by default GCS sets this to this bucket's name | `string` | `null` | no |
| name | The name of the bucket. | `string` | n/a | yes |
| project\_id | The ID of the project to create the bucket in. | `string` | n/a | yes |
| retention\_policy | Configuration of the bucket's data retention policy for how long objects in the bucket should be retained. | <pre>object({<br> is_locked = bool<br> retention_period = number<br> })</pre> | `null` | no |
Expand Down
6 changes: 3 additions & 3 deletions modules/simple_bucket/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ resource "google_storage_bucket" "bucket" {
}

dynamic "logging" {
for_each = var.logging == null ? [] : [var.logging]
for_each = var.log_bucket == null ? [] : [var.log_bucket]
content {
log_bucket = var.logging.log_bucket
log_object_prefix = var.logging.log_object_prefix == "" ? var.name : var.logging.log_object_prefix
log_bucket = var.log_bucket
log_object_prefix = var.log_object_prefix
}
}
}
Expand Down
17 changes: 10 additions & 7 deletions modules/simple_bucket/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,14 @@ variable "lifecycle_rules" {
default = []
}

variable "logging" {
description = "Configuration of the bucket's access and storage logs. If log_object_prefix is set to the empty string, the name of the bucket will be used."
type = object({
log_bucket = string
log_object_prefix = string
})
default = null
variable "log_bucket" {
description = "The bucket that will receive log objects."
type = string
default = null
}

variable "log_object_prefix" {
description = "The object prefix for log objects. If it's not provided, by default GCS sets this to this bucket's name"
type = string
default = null
}

0 comments on commit d6c676e

Please sign in to comment.