Merge remote-tracking branch 'origin/master' into fast-dev

This commit is contained in:
Ludo
2025-07-09 09:11:06 +02:00
9 changed files with 54 additions and 15 deletions

View File

@@ -313,6 +313,7 @@ module "additive_iam" {
| [iam_bindings_additive](variables-iam.tf#L58) | Individual additive IAM bindings. Keys are arbitrary. | <code title="map&#40;object&#40;&#123;&#10; member &#61; string&#10; role &#61; string&#10; condition &#61; optional&#40;object&#40;&#123;&#10; expression &#61; string&#10; title &#61; string&#10; description &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [iam_by_principals](variables-iam.tf#L73) | Authoritative IAM binding in {PRINCIPAL => [ROLES]} format. Principals need to be statically defined to avoid cycle errors. Merged internally with the `iam` variable. | <code>map&#40;list&#40;string&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [labels](variables.tf#L206) | Labels to be attached to the registry. | <code>map&#40;string&#41;</code> | | <code>&#123;&#125;</code> |
| [tag_bindings](variables.tf#L227) | Tag bindings for this repository, in key => tag value id format. | <code>map&#40;string&#41;</code> | | <code>&#123;&#125;</code> |
## Outputs

View File

@@ -1,5 +1,5 @@
/**
* Copyright 2024 Google LLC
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -217,3 +217,10 @@ resource "google_artifact_registry_repository" "registry" {
}
}
resource "google_tags_location_tag_binding" "binding" {
for_each = var.tag_bindings
parent = "//artifactregistry.googleapis.com/${google_artifact_registry_repository.registry.id}"
location = var.location
tag_value = each.value
}

View File

@@ -223,3 +223,10 @@ variable "project_id" {
description = "Registry project id."
type = string
}
variable "tag_bindings" {
description = "Tag bindings for this repository, in key => tag value id format."
type = map(string)
nullable = false
default = {}
}

View File

@@ -991,7 +991,7 @@ module "sole-tenancy" {
| [service_account_email](outputs.tf#L73) | Service account email. | |
| [service_account_iam_email](outputs.tf#L78) | Service account email. | |
| [template](outputs.tf#L87) | Template resource. | |
| [template_name](outputs.tf#L92) | Template name. | |
| [template_name](outputs.tf#L96) | Template name. | |
## Fixtures

View File

@@ -86,10 +86,18 @@ output "service_account_iam_email" {
output "template" {
description = "Template resource."
value = try(google_compute_instance_template.default[0], null)
value = (
local.template_regional
? try(google_compute_region_instance_template.default[0], null)
: try(google_compute_instance_template.default[0], null)
)
}
output "template_name" {
description = "Template name."
value = try(google_compute_instance_template.default[0].name, null)
value = (
local.template_regional
? try(google_compute_region_instance_template.default[0].name, null)
: try(google_compute_instance_template.default[0].name, null)
)
}

View File

@@ -332,13 +332,6 @@ resource "google_compute_region_instance_template" "default" {
}
}
dynamic "network_interface" {
for_each = var.network_attached_interfaces
content {
network_attachment = network_interface.value
}
}
scheduling {
automatic_restart = !var.options.spot
instance_termination_action = local.termination_action

View File

@@ -192,8 +192,9 @@ 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, 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> |
| [project_number](variables.tf#L34) | Project number of var.project_id. Set this to avoid permadiffs when creating tag bindings. | <code>string</code> | | <code>null</code> |
| [secrets](variables.tf#L40) | 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; tag_bindings &#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#L52) | 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

@@ -1,5 +1,5 @@
/**
* Copyright 2023 Google LLC
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,6 +25,15 @@ locals {
}
]
])
tag_bindings = merge([
for k, v in var.secrets : {
for kk, vv in v.tag_bindings : "${k}/${kk}" => {
parent = "//secretmanager.googleapis.com/projects/${coalesce(var.project_number, var.project_id)}/secrets/${google_secret_manager_secret.default[k].secret_id}"
tag_value = vv
}
}
if v.tag_bindings != null
]...)
version_pairs = flatten([
for secret, versions in var.versions : [
for name, attrs in versions : merge(attrs, { name = name, secret = secret })
@@ -96,3 +105,9 @@ resource "google_secret_manager_secret_iam_binding" "default" {
secret_id = google_secret_manager_secret.default[each.value.secret].id
members = each.value.members
}
resource "google_tags_tag_binding" "binding" {
for_each = local.tag_bindings
parent = each.value.parent
tag_value = each.value.tag_value
}

View File

@@ -1,5 +1,5 @@
/**
* Copyright 2023 Google LLC
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,12 +31,19 @@ variable "project_id" {
type = string
}
variable "project_number" {
description = "Project number of var.project_id. Set this to avoid permadiffs when creating tag bindings."
type = string
default = null
}
variable "secrets" {
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))
tag_bindings = optional(map(string))
version_destroy_ttl = optional(string)
}))
default = {}