Skip to content

Commit

Permalink
BigAnimal spec/module - add witness_groups option
Browse files Browse the repository at this point in the history
  • Loading branch information
bryan-bar committed Jun 5, 2024
1 parent cf7171f commit 640f22d
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 1 deletion.
1 change: 1 addition & 0 deletions edbterraform/data/templates/aws/biganimal.tf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module "biganimal" {
cluster_name = module.spec.base.tags.cluster_name
password = each.value.password
data_groups = each.value.data_groups
witness_groups = each.value.witness_groups
service_cidrblocks = local.biganimal_service_cidrblocks
machine_cidrblocks = local.machine_cidrblocks

Expand Down
1 change: 1 addition & 0 deletions edbterraform/data/templates/azure/biganimal.tf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module "biganimal" {
cluster_name = module.spec.base.tags.cluster_name
password = each.value.password
data_groups = each.value.data_groups
witness_groups = each.value.witness_groups
service_cidrblocks = local.biganimal_service_cidrblocks
machine_cidrblocks = local.machine_cidrblocks

Expand Down
1 change: 1 addition & 0 deletions edbterraform/data/templates/gcloud/biganimal.tf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module "biganimal" {
cluster_name = module.spec.base.tags.cluster_name
password = each.value.password
data_groups = each.value.data_groups
witness_groups = each.value.witness_groups
service_cidrblocks = local.biganimal_service_cidrblocks
machine_cidrblocks = local.machine_cidrblocks

Expand Down
33 changes: 33 additions & 0 deletions edbterraform/data/terraform/aws/modules/biganimal/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,39 @@ variable data_groups {
}
}

variable "witness_groups" {
description = "A single witness node is needed when using 2 data groups. It can be in a different cloud provider but cannot be in the same region as the data groups when using the same provider."
default = {}
nullable = false
type = map(object({
region = string
cloud_service_provider = string
maintenance_window = optional(object({
is_enabled = bool
start_day = number
start_time = string
}), {
is_enabled = false
start_day = 0
start_time = "00:00"
})
}))

validation {
condition = (
var.witness_groups == {} ||
var.witness_groups == null ||
alltrue([for k, v in var.witness_groups: v.maintenance_window.is_enabled == true || v.maintenance_window.start_day == 0 && v.maintenance_window.start_time == "00:00"])
)
error_message = (
<<-EOT
When maintenance window is disabled, start day and start time must be 0
# https://github.com/EnterpriseDB/terraform-provider-biganimal/issues/491
EOT
)
}
}

variable "project" {
type = object({
id = optional(string)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ variable "spec" {
})))
allowed_machines = optional(list(string))
})))
witness_groups = optional(map(object({
region = string
cloud_service_provider = string
})), {})
tags = optional(map(string), {})
})), {})
kubernetes = optional(map(object({
Expand Down
33 changes: 33 additions & 0 deletions edbterraform/data/terraform/azure/modules/biganimal/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,39 @@ variable data_groups {
}
}

variable "witness_groups" {
description = "A single witness node is needed when using 2 data groups. It can be in a different cloud provider but cannot be in the same region as the data groups when using the same provider."
default = {}
nullable = false
type = map(object({
region = string
cloud_service_provider = string
maintenance_window = optional(object({
is_enabled = bool
start_day = number
start_time = string
}), {
is_enabled = false
start_day = 0
start_time = "00:00"
})
}))

validation {
condition = (
var.witness_groups == {} ||
var.witness_groups == null ||
alltrue([for k, v in var.witness_groups: v.maintenance_window.is_enabled == true || v.maintenance_window.start_day == 0 && v.maintenance_window.start_time == "00:00"])
)
error_message = (
<<-EOT
When maintenance window is disabled, start day and start time must be 0
# https://github.com/EnterpriseDB/terraform-provider-biganimal/issues/491
EOT
)
}
}

variable "project" {
type = object({
id = optional(string)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ variable "spec" {
})))
allowed_machines = optional(list(string))
})))
witness_groups = optional(map(object({
region = string
cloud_service_provider = string
})), {})
tags = optional(map(string), {})
})), {})
kubernetes = optional(map(object({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,36 @@ variable data_groups {
}

variable "witness_groups" {

description = "A single witness node is needed when using 2 data groups. It can be in a different cloud provider but cannot be in the same region as the data groups when using the same provider."
default = {}
nullable = false
type = map(object({
region = string
cloud_service_provider = string
maintenance_window = optional(object({
is_enabled = bool
start_day = number
start_time = string
}), {
is_enabled = false
start_day = 0
start_time = "00:00"
})
}))

validation {
condition = (
var.witness_groups == {} ||
var.witness_groups == null ||
alltrue([for k, v in var.witness_groups: v.maintenance_window.is_enabled == true || v.maintenance_window.start_day == 0 && v.maintenance_window.start_time == "00:00"])
)
error_message = (
<<-EOT
When maintenance window is disabled, start day and start time must be 0
# https://github.com/EnterpriseDB/terraform-provider-biganimal/issues/491
EOT
)
}
}

variable "project" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ variable "spec" {
})))
allowed_machines = optional(list(string))
})))
witness_groups = optional(map(object({
region = string
cloud_service_provider = string
})), {})
tags = optional(map(string), {})
})), {})
kubernetes = optional(map(object({
Expand Down

0 comments on commit 640f22d

Please sign in to comment.