Skip to content

Commit

Permalink
BigAnimal spec - handle biganimal configurations under a mapping of d…
Browse files Browse the repository at this point in the history
…ata_groups. single and ha should only contain a single item while pgd will be able to define multiple data_groups per cluster
  • Loading branch information
bryan-bar committed Jun 5, 2024
1 parent 59ddceb commit bbf6f83
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})
}...
})
}
}

Expand Down
60 changes: 31 additions & 29 deletions edbterraform/data/terraform/aws/modules/specification/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})
}...
})
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})
}...
})
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
11 changes: 11 additions & 0 deletions edbterraform/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit bbf6f83

Please sign in to comment.