File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -71,14 +71,19 @@ resource "google_secret_manager_secret" "default" {
7171 }
7272 }
7373 }
74- # dynamic "rotation" {
75- # for_each = try(each.value.rotation_config, null) == null ? [] : [""]
76- # content {
77- # next_rotation_time = each.value.rotation_config.next_time
78- # rotation_period = each.value.rotation_config.period
79- # }
80- # }
81- # topics
74+ dynamic "rotation" {
75+ for_each = try (each. value . rotation_config , null ) == null ? [] : [" " ]
76+ content {
77+ next_rotation_time = each. value . rotation_config . next_time
78+ rotation_period = each. value . rotation_config . period
79+ }
80+ }
81+ dynamic "topics" {
82+ for_each = coalesce (try (each. value . topics , null ), [])
83+ content {
84+ name = topics. value
85+ }
86+ }
8287 lifecycle {
8388 ignore_changes = [
8489 rotation [0 ]. next_rotation_time
Original file line number Diff line number Diff line change @@ -43,14 +43,19 @@ resource "google_secret_manager_regional_secret" "default" {
4343 )
4444 }
4545 }
46- # dynamic "rotation" {
47- # for_each = try(each.value.rotation_config, null) == null ? [] : [""]
48- # content {
49- # next_rotation_time = each.value.rotation_config.next_time
50- # rotation_period = each.value.rotation_config.period
51- # }
52- # }
53- # topics
46+ dynamic "rotation" {
47+ for_each = try (each. value . rotation_config , null ) == null ? [] : [" " ]
48+ content {
49+ next_rotation_time = each. value . rotation_config . next_time
50+ rotation_period = each. value . rotation_config . period
51+ }
52+ }
53+ dynamic "topics" {
54+ for_each = coalesce (try (each. value . topics , null ), [])
55+ content {
56+ name = topics. value
57+ }
58+ }
5459 lifecycle {
5560 ignore_changes = [
5661 rotation [0 ]. next_rotation_time
Original file line number Diff line number Diff line change @@ -100,13 +100,20 @@ variable "secrets" {
100100 write_only_version = optional (number )
101101 }))
102102 })), {})
103- # rotation_config = optional(object({
104- # next_time = string
105- # period = number
106- # }))
107- # topics
103+ rotation_config = optional (object ({
104+ next_time = optional ( string )
105+ period = string
106+ }))
107+ topics = optional ( list ( string ))
108108 }))
109109 default = {}
110+ validation {
111+ condition = alltrue ([
112+ for k , v in var . secrets :
113+ try (v. rotation_config , null ) == null || (try (length (v. topics ), 0 ) > 0 )
114+ ])
115+ error_message = " At least one topic must be configured when rotation_config is set."
116+ }
110117 validation {
111118 condition = alltrue ([
112119 for k , v in var . secrets :
You can’t perform that action at this time.
0 commit comments