Add new variables to spanner instance and database (#4001)

* added new variables to instance and database

* tf fmt
This commit is contained in:
Antonio Lopez
2026-05-30 17:01:21 +02:00
committed by GitHub
parent ee8b7396b7
commit 129ebffe02
3 changed files with 24 additions and 18 deletions

View File

@@ -168,13 +168,13 @@ module "spanner_instance" {
| name | description | type | required | default | | name | description | type | required | default |
|---|---|:---:|:---:|:---:| |---|---|:---:|:---:|:---:|
| [instance](variables.tf#L89) | Instance attributes. | <code>object&#40;&#123;&#8230;&#125;&#41;</code> | ✓ | | | [instance](variables.tf#L90) | Instance attributes. | <code>object&#40;&#123;&#8230;&#125;&#41;</code> | ✓ | |
| [project_id](variables.tf#L134) | Project id. | <code>string</code> | ✓ | | | [project_id](variables.tf#L137) | Project id. | <code>string</code> | ✓ | |
| [databases](variables.tf#L17) | Databases. | <code>map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> | | [databases](variables.tf#L17) | Databases. | <code>map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [iam](variables.tf#L63) | IAM bindings in {ROLE => [MEMBERS]} format. | <code>map&#40;list&#40;string&#41;&#41;</code> | | <code>&#123;&#125;</code> | | [iam](variables.tf#L64) | IAM bindings in {ROLE => [MEMBERS]} format. | <code>map&#40;list&#40;string&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [iam_bindings](variables.tf#L69) | Authoritative IAM bindings in {KEY => {role = ROLE, members = [], condition = {}}}. Keys are arbitrary. | <code>map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> | | [iam_bindings](variables.tf#L70) | Authoritative IAM bindings in {KEY => {role = ROLE, members = [], condition = {}}}. Keys are arbitrary. | <code>map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [iam_bindings_additive](variables.tf#L79) | Individual additive IAM bindings. Keys are arbitrary. | <code>map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> | | [iam_bindings_additive](variables.tf#L80) | Individual additive IAM bindings. Keys are arbitrary. | <code>map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [instance_create](variables.tf#L127) | Set to false to manage databases and IAM bindings in an existing instance. | <code>bool</code> | | <code>true</code> | | [instance_create](variables.tf#L130) | Set to false to manage databases and IAM bindings in an existing instance. | <code>bool</code> | | <code>true</code> |
## Outputs ## Outputs

View File

@@ -55,12 +55,14 @@ resource "google_spanner_instance" "spanner_instance" {
? var.instance.config.name ? var.instance.config.name
: google_spanner_instance_config.spanner_instance_config[0].name : google_spanner_instance_config.spanner_instance_config[0].name
) )
name = var.instance.name name = var.instance.name
display_name = coalesce(var.instance.display_name, var.instance.name) display_name = coalesce(var.instance.display_name, var.instance.name)
num_nodes = var.instance.num_nodes num_nodes = var.instance.num_nodes
labels = var.instance.labels labels = var.instance.labels
force_destroy = var.instance.force_destroy force_destroy = var.instance.force_destroy
processing_units = var.instance.processing_units processing_units = var.instance.processing_units
edition = var.instance.edition
default_backup_schedule_type = var.instance.default_backup_schedule_type
dynamic "autoscaling_config" { dynamic "autoscaling_config" {
for_each = var.instance.autoscaling == null ? [] : [""] for_each = var.instance.autoscaling == null ? [] : [""]
content { content {
@@ -92,6 +94,7 @@ resource "google_spanner_database" "spanner_databases" {
instance = local.spanner_instance.name instance = local.spanner_instance.name
name = each.key name = each.key
ddl = each.value.ddl ddl = each.value.ddl
default_time_zone = each.value.default_time_zone
enable_drop_protection = each.value.enable_drop_protection enable_drop_protection = each.value.enable_drop_protection
deletion_protection = false deletion_protection = false
version_retention_period = each.value.version_retention_period version_retention_period = each.value.version_retention_period

View File

@@ -19,6 +19,7 @@ variable "databases" {
type = map(object({ type = map(object({
database_dialect = optional(string) database_dialect = optional(string)
ddl = optional(list(string), []) ddl = optional(list(string), [])
default_time_zone = optional(string)
deletion_protection = optional(bool) deletion_protection = optional(bool)
enable_drop_protection = optional(bool) enable_drop_protection = optional(bool)
iam = optional(map(list(string)), {}) iam = optional(map(list(string)), {})
@@ -115,12 +116,14 @@ variable "instance" {
)) ))
})) }))
})) }))
display_name = optional(string) display_name = optional(string)
labels = optional(map(string), {}) edition = optional(string)
name = string default_backup_schedule_type = optional(string)
num_nodes = optional(number) labels = optional(map(string), {})
processing_units = optional(number) name = string
force_destroy = optional(bool) num_nodes = optional(number)
processing_units = optional(number)
force_destroy = optional(bool)
}) })
} }