* Add support for lifecycle_rule in gcs module (#288) Co-authored-by: Ludovico Magnocavallo <ludomagno@google.com> * fix docs * rename unrelated interconnect module tests * fix doc example test Co-authored-by: iury <1934268+IuryAlves@users.noreply.github.com>
This commit is contained in:
parent
598e4f5ee1
commit
202892b344
|
@ -3,6 +3,7 @@
|
|||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## [Unreleased]
|
||||
- add support for `lifecycle_rule` in gcs module
|
||||
- create `pubsub` service identity if service is enabled
|
||||
- support for creation of GKE Autopilot clusters
|
||||
- add support for CMEK keys in Data Foundation end to end example
|
||||
|
|
|
@ -60,6 +60,40 @@ module "bucket" {
|
|||
# tftest:modules=1:resources=2
|
||||
```
|
||||
|
||||
### Example with lifecycle rule
|
||||
|
||||
```hcl
|
||||
module "bucket" {
|
||||
source = "./modules/gcs"
|
||||
project_id = "myproject"
|
||||
prefix = "test"
|
||||
name = "my-bucket"
|
||||
|
||||
iam = {
|
||||
"roles/storage.admin" = ["group:storage@example.com"]
|
||||
}
|
||||
|
||||
lifecycle_rule = {
|
||||
action = {
|
||||
type = "SetStorageClass"
|
||||
storage_class = "STANDARD"
|
||||
}
|
||||
condition = {
|
||||
age = 30
|
||||
created_before = null
|
||||
with_state = null
|
||||
matches_storage_class = null
|
||||
num_newer_versions = null
|
||||
custom_time_before = null
|
||||
days_since_custom_time = null
|
||||
days_since_noncurrent_time = null
|
||||
noncurrent_time_before = null
|
||||
}
|
||||
}
|
||||
}
|
||||
# tftest:modules=1:resources=2
|
||||
```
|
||||
|
||||
<!-- BEGIN TFDOC -->
|
||||
## Variables
|
||||
|
||||
|
@ -72,6 +106,7 @@ module "bucket" {
|
|||
| *force_destroy* | Optional map to set force destroy keyed by name, defaults to false. | <code title="">bool</code> | | <code title="">false</code> |
|
||||
| *iam* | IAM bindings in {ROLE => [MEMBERS]} format. | <code title="map(list(string))">map(list(string))</code> | | <code title="">{}</code> |
|
||||
| *labels* | Labels to be attached to all buckets. | <code title="map(string)">map(string)</code> | | <code title="">{}</code> |
|
||||
| *lifecycle_rule* | Bucket lifecycle rule | <code title="object({ action = object({ type = string storage_class = string }) condition = object({ age = number created_before = string with_state = string matches_storage_class = list(string) num_newer_versions = string custom_time_before = string days_since_custom_time = string days_since_noncurrent_time = string noncurrent_time_before = string }) })">object({...})</code> | | <code title="">null</code> |
|
||||
| *location* | Bucket location. | <code title="">string</code> | | <code title="">EU</code> |
|
||||
| *logging_config* | Bucket logging configuration. | <code title="object({ log_bucket = string log_object_prefix = string })">object({...})</code> | | <code title="">null</code> |
|
||||
| *prefix* | Prefix used to generate the bucket name. | <code title="">string</code> | | <code title="">null</code> |
|
||||
|
|
|
@ -71,6 +71,27 @@ resource "google_storage_bucket" "bucket" {
|
|||
max_age_seconds = max(3600, var.cors.max_age_seconds)
|
||||
}
|
||||
}
|
||||
|
||||
dynamic lifecycle_rule {
|
||||
for_each = var.lifecycle_rule == null ? [] : [""]
|
||||
content {
|
||||
action {
|
||||
type = var.lifecycle_rule.action["type"]
|
||||
storage_class = var.lifecycle_rule.action["storage_class"]
|
||||
}
|
||||
condition {
|
||||
age = var.lifecycle_rule.condition["age"]
|
||||
created_before = var.lifecycle_rule.condition["created_before"]
|
||||
with_state = var.lifecycle_rule.condition["with_state"]
|
||||
matches_storage_class = var.lifecycle_rule.condition["matches_storage_class"]
|
||||
num_newer_versions = var.lifecycle_rule.condition["num_newer_versions"]
|
||||
custom_time_before = var.lifecycle_rule.condition["custom_time_before"]
|
||||
days_since_custom_time = var.lifecycle_rule.condition["days_since_custom_time"]
|
||||
days_since_noncurrent_time = var.lifecycle_rule.condition["days_since_noncurrent_time"]
|
||||
noncurrent_time_before = var.lifecycle_rule.condition["noncurrent_time_before"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resource "google_storage_bucket_iam_binding" "bindings" {
|
||||
|
|
|
@ -110,3 +110,25 @@ variable "cors" {
|
|||
})
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "lifecycle_rule" {
|
||||
description = "Bucket lifecycle rule"
|
||||
type = object({
|
||||
action = object({
|
||||
type = string
|
||||
storage_class = string
|
||||
})
|
||||
condition = object({
|
||||
age = number
|
||||
created_before = string
|
||||
with_state = string
|
||||
matches_storage_class = list(string)
|
||||
num_newer_versions = string
|
||||
custom_time_before = string
|
||||
days_since_custom_time = string
|
||||
days_since_noncurrent_time = string
|
||||
noncurrent_time_before = string
|
||||
})
|
||||
})
|
||||
default = null
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue