diff --git a/edbterraform/data/terraform/aws/modules/specification/outputs.tf b/edbterraform/data/terraform/aws/modules/specification/outputs.tf index fc166e6f..e1ec4fcb 100644 --- a/edbterraform/data/terraform/aws/modules/specification/outputs.tf +++ b/edbterraform/data/terraform/aws/modules/specification/outputs.tf @@ -136,17 +136,14 @@ output "region_auroras" { } } -output "region_biganimals" { +output "biganimal" { value = { - for name, biganimal_spec in var.spec.biganimal : biganimal_spec.region => { - name = name - spec = merge(biganimal_spec, { + for name, biganimal_spec in var.spec.biganimal : name => merge(biganimal_spec, { # spec project tags tags = merge(local.tags, biganimal_spec.tags, { Name = format("%s-%s-%s", name, local.cluster_name, random_id.apply.id) - }) }) - }... + }) } } diff --git a/edbterraform/data/terraform/aws/modules/specification/variables.tf b/edbterraform/data/terraform/aws/modules/specification/variables.tf index c8cff069..343b678d 100644 --- a/edbterraform/data/terraform/aws/modules/specification/variables.tf +++ b/edbterraform/data/terraform/aws/modules/specification/variables.tf @@ -156,41 +156,43 @@ variable "spec" { tags = optional(map(string), {}) })), {}) biganimal = optional(map(object({ - type = string project = object({ id = optional(string) }) cloud_account = optional(bool) - region = string - node_count = number - engine = string - engine_version = number - instance_type = string - volume = object({ - size_gb = number - type = string - properties = string - iops = optional(number) - throughput = optional(number) - }) - wal_volume = optional(object({ - size_gb = number - type = string - properties = string - iops = optional(number) - throughput = optional(number) - })) password = string - pgvector = optional(bool) - settings = optional(list(object({ - name = string - value = string - })), []) - allowed_ip_ranges = optional(list(object({ - cidr_block = string - description = optional(string, "default description") + data_groups = optional(map(object({ + type = string + region = string + node_count = number + engine = string + engine_version = number + instance_type = string + volume = object({ + size_gb = number + type = string + properties = string + iops = optional(number) + throughput = optional(number) + }) + wal_volume = optional(object({ + size_gb = number + type = string + properties = string + iops = optional(number) + throughput = optional(number) + })) + pgvector = optional(bool) + settings = optional(list(object({ + name = string + value = string + })), []) + allowed_ip_ranges = optional(list(object({ + cidr_block = string + description = optional(string, "default description") + }))) + allowed_machines = optional(list(string)) }))) - allowed_machines = optional(list(string)) tags = optional(map(string), {}) })), {}) kubernetes = optional(map(object({ diff --git a/edbterraform/data/terraform/azure/modules/specification/outputs.tf b/edbterraform/data/terraform/azure/modules/specification/outputs.tf index 94e17f93..57459c67 100644 --- a/edbterraform/data/terraform/azure/modules/specification/outputs.tf +++ b/edbterraform/data/terraform/azure/modules/specification/outputs.tf @@ -124,17 +124,14 @@ output "region_databases" { } } -output "region_biganimals" { +output "biganimal" { value = { - for name, biganimal_spec in var.spec.biganimal : biganimal_spec.region => { - name = name - spec = merge(biganimal_spec, { + for name, biganimal_spec in var.spec.biganimal : name => merge(biganimal_spec, { # spec project tags tags = merge(local.tags, biganimal_spec.tags, { Name = format("%s-%s-%s", name, local.cluster_name, random_id.apply.id) - }) }) - }... + }) } } diff --git a/edbterraform/data/terraform/azure/modules/specification/variables.tf b/edbterraform/data/terraform/azure/modules/specification/variables.tf index 5d8b9997..fccd1d35 100644 --- a/edbterraform/data/terraform/azure/modules/specification/variables.tf +++ b/edbterraform/data/terraform/azure/modules/specification/variables.tf @@ -104,41 +104,43 @@ variable "spec" { public_access = optional(bool, false) })), {}) biganimal = optional(map(object({ - type = string project = object({ id = optional(string) }) cloud_account = optional(bool) - region = string - node_count = number - engine = string - engine_version = number - instance_type = string - volume = object({ - size_gb = number - type = string - properties = string - iops = optional(number) - throughput = optional(number) - }) - wal_volume = optional(object({ - size_gb = number - type = string - properties = string - iops = optional(number) - throughput = optional(number) - })) password = string - pgvector = optional(bool) - settings = optional(list(object({ - name = string - value = string - })), []) - allowed_ip_ranges = optional(list(object({ - cidr_block = string - description = optional(string, "default description") + data_groups = optional(map(object({ + type = string + region = string + node_count = number + engine = string + engine_version = number + instance_type = string + volume = object({ + size_gb = number + type = string + properties = string + iops = optional(number) + throughput = optional(number) + }) + wal_volume = optional(object({ + size_gb = number + type = string + properties = string + iops = optional(number) + throughput = optional(number) + })) + pgvector = optional(bool) + settings = optional(list(object({ + name = string + value = string + })), []) + allowed_ip_ranges = optional(list(object({ + cidr_block = string + description = optional(string, "default description") + }))) + allowed_machines = optional(list(string)) }))) - allowed_machines = optional(list(string)) tags = optional(map(string), {}) })), {}) kubernetes = optional(map(object({ diff --git a/edbterraform/data/terraform/gcloud/modules/specification/outputs.tf b/edbterraform/data/terraform/gcloud/modules/specification/outputs.tf index 22e331f9..0978c63e 100644 --- a/edbterraform/data/terraform/gcloud/modules/specification/outputs.tf +++ b/edbterraform/data/terraform/gcloud/modules/specification/outputs.tf @@ -127,17 +127,14 @@ output "region_alloys" { } } -output "region_biganimals" { +output "biganimal" { value = { - for name, biganimal_spec in var.spec.biganimal : biganimal_spec.region => { - name = name - spec = merge(biganimal_spec, { + for name, biganimal_spec in var.spec.biganimal : name => merge(biganimal_spec, { # spec project tags tags = merge(local.tags, biganimal_spec.tags, { Name = format("%s-%s-%s", name, local.cluster_name, random_id.apply.id) - }) }) - }... + }) } } diff --git a/edbterraform/data/terraform/gcloud/modules/specification/variables.tf b/edbterraform/data/terraform/gcloud/modules/specification/variables.tf index 0d120f7d..10b1212c 100644 --- a/edbterraform/data/terraform/gcloud/modules/specification/variables.tf +++ b/edbterraform/data/terraform/gcloud/modules/specification/variables.tf @@ -119,39 +119,43 @@ variable "spec" { tags = optional(map(string), {}) })), {}) biganimal = optional(map(object({ - type = string project = object({ id = optional(string) }) cloud_account = optional(bool) - region = string - node_count = number - engine = string - engine_version = number - instance_type = string - volume = object({ - size_gb = number - type = string - properties = string - }) - wal_volume = optional(object({ - size_gb = number - type = string - properties = string - iops = optional(number) - throughput = optional(number) - })) password = string - pgvector = optional(bool) - settings = optional(list(object({ - name = string - value = string - })), []) - allowed_ip_ranges = optional(list(object({ - cidr_block = string - description = optional(string, "default description") + data_groups = optional(map(object({ + type = string + region = string + node_count = number + engine = string + engine_version = number + instance_type = string + volume = object({ + size_gb = number + type = string + properties = string + iops = optional(number) + throughput = optional(number) + }) + wal_volume = optional(object({ + size_gb = number + type = string + properties = string + iops = optional(number) + throughput = optional(number) + })) + pgvector = optional(bool) + settings = optional(list(object({ + name = string + value = string + })), []) + allowed_ip_ranges = optional(list(object({ + cidr_block = string + description = optional(string, "default description") + }))) + allowed_machines = optional(list(string)) }))) - allowed_machines = optional(list(string)) tags = optional(map(string), {}) })), {}) kubernetes = optional(map(object({ diff --git a/edbterraform/lib.py b/edbterraform/lib.py index 572e44bd..c0ca9f10 100644 --- a/edbterraform/lib.py +++ b/edbterraform/lib.py @@ -631,4 +631,15 @@ def spec_compatability(infrastructure_variables, cloud_service_provider): if 'zone_name' not in spec_variables['kubernetes'][cluster] and 'zone' in spec_variables['kubernetes'][cluster]: spec_variables['kubernetes'][cluster]['zone_name'] = f'depreciated-{spec_variables["kubernetes"][machine]["zone"]}' + # BigAnimal supports single, ha, and pgd cluster types + # PGD uses its own resource and defines a set of data nodes and witness nodes. + # + # Handle single and ha under data_nodes + # which should be a single item object with a single key + if 'biganimal' in spec_variables: + for cluster in spec_variables['biganimal']: + if 'data_groups' not in spec_variables['biganimal'][cluster]: + items = spec_variables['biganimal'][cluster].copy() + spec_variables['biganimal'][cluster]['data_groups'] = {'deprecated': items} + return spec_variables