feat(modules/secret-manager): add support for version_destroy_ttl

Closes #2644
This commit is contained in:
Frits
2024-10-29 14:01:57 -07:00
committed by Wiktor Niesiobędzki
parent d4b594f83a
commit b9fbdbcf7b
3 changed files with 13 additions and 11 deletions

View File

@@ -192,8 +192,8 @@ module "secret-manager" {
| [project_id](variables.tf#L29) | Project id where the keyring will be created. | <code>string</code> | ✓ | |
| [iam](variables.tf#L17) | IAM bindings in {SECRET => {ROLE => [MEMBERS]}} format. | <code>map&#40;map&#40;list&#40;string&#41;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [labels](variables.tf#L23) | Optional labels for each secret. | <code>map&#40;map&#40;string&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [secrets](variables.tf#L34) | Map of secrets to manage, their optional expire time, locations and KMS keys in {LOCATION => KEY} format. {GLOBAL => KEY} format enables CMEK for automatic managed secrets. If locations is null, automatic management will be set. | <code title="map&#40;object&#40;&#123;&#10; expire_time &#61; optional&#40;string&#41;&#10; locations &#61; optional&#40;list&#40;string&#41;&#41;&#10; keys &#61; optional&#40;map&#40;string&#41;&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [versions](variables.tf#L44) | Optional versions to manage for each secret. Version names are only used internally to track individual versions. | <code title="map&#40;map&#40;object&#40;&#123;&#10; enabled &#61; bool&#10; data &#61; string&#10;&#125;&#41;&#41;&#41;">map&#40;map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [secrets](variables.tf#L34) | Map of secrets to manage, their optional expire time, version destroy ttl, locations and KMS keys in {LOCATION => KEY} format. {GLOBAL => KEY} format enables CMEK for automatic managed secrets. If locations is null, automatic management will be set. | <code title="map&#40;object&#40;&#123;&#10; expire_time &#61; optional&#40;string&#41;&#10; locations &#61; optional&#40;list&#40;string&#41;&#41;&#10; keys &#61; optional&#40;map&#40;string&#41;&#41;&#10; version_destroy_ttl &#61; optional&#40;string&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [versions](variables.tf#L45) | Optional versions to manage for each secret. Version names are only used internally to track individual versions. | <code title="map&#40;map&#40;object&#40;&#123;&#10; enabled &#61; bool&#10; data &#61; string&#10;&#125;&#41;&#41;&#41;">map&#40;map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
## Outputs

View File

@@ -36,11 +36,12 @@ locals {
}
resource "google_secret_manager_secret" "default" {
for_each = var.secrets
project = var.project_id
secret_id = each.key
labels = lookup(var.labels, each.key, null)
expire_time = each.value.expire_time
for_each = var.secrets
project = var.project_id
secret_id = each.key
labels = lookup(var.labels, each.key, null)
expire_time = each.value.expire_time
version_destroy_ttl = each.value.version_destroy_ttl
dynamic "replication" {
for_each = each.value.locations == null ? [""] : []

View File

@@ -32,11 +32,12 @@ variable "project_id" {
}
variable "secrets" {
description = "Map of secrets to manage, their optional expire time, locations and KMS keys in {LOCATION => KEY} format. {GLOBAL => KEY} format enables CMEK for automatic managed secrets. If locations is null, automatic management will be set."
description = "Map of secrets to manage, their optional expire time, version destroy ttl, locations and KMS keys in {LOCATION => KEY} format. {GLOBAL => KEY} format enables CMEK for automatic managed secrets. If locations is null, automatic management will be set."
type = map(object({
expire_time = optional(string)
locations = optional(list(string))
keys = optional(map(string))
expire_time = optional(string)
locations = optional(list(string))
keys = optional(map(string))
version_destroy_ttl = optional(string)
}))
default = {}
}