Skip to content

Commit 2d7b4ef

Browse files
committed
feat: Adding terminal autoclass variable for simple and multiple bucket
1 parent e2ef692 commit 2d7b4ef

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed

main.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ resource "google_storage_bucket" "buckets" {
7575
lower(each.value),
7676
false,
7777
)
78+
terminal_storage_class = lookup(
79+
var.terminal_autoclass,
80+
lower(each.value),
81+
"NEARLINE"
82+
)
7883
}
7984
hierarchical_namespace {
8085
enabled = lookup(

modules/simple_bucket/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ resource "google_storage_bucket" "bucket" {
3535

3636
autoclass {
3737
enabled = var.autoclass
38+
terminal_storage_class = var.terminal_autoclass
3839
}
3940

4041
hierarchical_namespace {

modules/simple_bucket/variables.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,16 @@ variable "autoclass" {
7575
default = false
7676
}
7777

78+
variable "terminal_autoclass" {
79+
description = "The storage class that objects in the bucket eventually transition to if they are not read for a certain length of time. Supported values include: NEARLINE, ARCHIVE. Only used if autoclass is set as true"
80+
type = string
81+
default = "NEARLINE"
82+
validation {
83+
condition = var.autoclass == false || var.terminal_autoclass == "NEARLINE" || var.terminal_autoclass == "ARCHIVE"
84+
error_message = "Acceptable value for terminal_autoclass is NEARLINE or ARCHIVE"
85+
}
86+
}
87+
7888
variable "hierarchical_namespace" {
7989
description = "When set to true, hierarchical namespace is enable for this bucket."
8090
type = bool

variables.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,16 @@ variable "autoclass" {
6666
default = {}
6767
}
6868

69+
variable "terminal_autoclass" {
70+
description = "Optional map of storage class that objects in the bucket eventually transitions to. Supported values include: NEARLINE, ARCHIVE. Only used if autoclass is set as true. bucket_name => value, defaults to NEARLINE"
71+
type = map(string)
72+
default = {}
73+
validation {
74+
condition = alltrue([ for _, v in var.terminal_autoclass : var.autoclass == false || v == "NEARLINE" || v == "ARCHIVE"])
75+
error_message = "Acceptable value for terminal_autoclass is NEARLINE or ARCHIVE"
76+
}
77+
}
78+
6979
variable "hierarchical_namespace" {
7080
description = "Optional map of lowercase unprefixed bucket name => boolean, defaults to false."
7181
type = map(bool)

0 commit comments

Comments
 (0)