Skip to content

Commit

Permalink
Biganimal module - expose a boolean variable 'TF_VAR_ba_cloud_account…
Browse files Browse the repository at this point in the history
…' to set a default for biganimal's 'cloud_account' configuration option
  • Loading branch information
bryan-bar committed Aug 9, 2024
1 parent d54b09f commit e4e2ecf
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 22 deletions.
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,22 +240,23 @@ Pairing can be done by setting the allow list for the provider or using vpc-peer
- To change the allow list after provisioning, the file `terraform.tfvars.json` can be directly modified and use `terraform apply` again.

BigAnimal specific environment variables that can be used during `terraform plan` or `terraform apply`:
- `BA_API_URI` - api endpoint
- `BA_API_URI` (string) - api endpoint
- Default: `https://portal.biganimal.com/api/v3/`
- Setting access key
- `BA_ACCESS_KEY` (priority)
- `BA_ACCESS_KEY` (string) - Priority credential over BA_BEARER_TOKEN
- Go to `https://portal.biganimal.com/access-keys` to create an access token that last 1-365 days.
- `BA_BEARER_TOKEN` (deprecated).
- `BA_BEARER_TOKEN` (string) - Deprecated in favor of BA_ACCESS_KEY.
- [get-token.sh script](https://raw.githubusercontent.com/EnterpriseDB/cloud-utilities/main/api/get-token.sh) requires manual intervention every:
- New token request
- 30 days since initial token request
- Expired token is reused
- `TF_VAR_ba_project_id` - Biganimal project id if not defined within the yaml configuration.
- `TF_VAR_ba_project_id` (string) - Biganimal project id default if not defined within the yaml configuration.
- For persistence, a tfvars file can be created with `ba_project_id` defined.
- `TF_VAR_ba_cloud_account` (boolean) - Biganimal bring-your-own-account default if not defined within the yaml configuration.
- Custom Image (Only available for dev environments)
- `TF_VAR_ba_pg_image` - Biganimal postgres image if not defined within the yaml configuration
- `TF_VAR_ba_proxy_image` - Biganimal proxy image if not defined within the yaml configuration
- `TF_VAR_ba_ignore_image` - Ignore image values (Default: `false`)
- `TF_VAR_ba_pg_image` (string) - Biganimal postgres image default if not defined within the yaml configuration
- `TF_VAR_ba_proxy_image` (string) - Biganimal proxy image default if not defined within the yaml configuration
- `TF_VAR_ba_ignore_image` (string) - Ignore image values (Default: `false`)

### Environment variables
Terraform allows for top-level variables to be defined with cli arguments or environment variables.
Expand Down
19 changes: 11 additions & 8 deletions docs/examples/aws/biganimal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,22 @@ aws:
# pg: ""
# proxy: ""
data_groups:
# only pgd support multiple data nodes, single and ha should only define a single data node
one:
cloud_account: false
# Environment variable 'TF_VAR_ba_cloud_account' can be used to set a default instead of hardcoding
# cloud_account: false
region: us-east-1
type: pgd
node_count: 3
engine: epas
# type must match across data nodes
type: pgd # single | ha | pgd - supports 1-2 data nodes
node_count: 3 # single = 1 node | ha = 2-3 nodes | pgd = 2-3 nodes for 1 data group or 3 for 2 data groups
engine: epas # epas | pgextended | postgres
engine_version: 14
instance_type: c5.large
volume:
type: gp3
properties: gp3
size_gb: 32
# Use this to create a separate volume for the WAL
# Create a separate volume for the WAL
#wal_volume:
# type: gp3
# properties: gp3
Expand All @@ -48,7 +51,7 @@ aws:
allowed_machines:
- "*"
two:
cloud_account: false
# cloud_account: false
region: us-east-2
type: pgd
node_count: 3
Expand All @@ -59,7 +62,6 @@ aws:
type: gp3
properties: gp3
size_gb: 32
# Use this to create a separate volume for the WAL
#wal_volume:
# type: gp3
# properties: gp3
Expand All @@ -77,9 +79,10 @@ aws:
description: localhost
allowed_machines:
- "*"
# Witness group only required when 2 data groups are configured
witness_groups:
one:
cloud_account: false
# cloud_account: false
region: us-west-2
cloud_service_provider: aws
tags:
Expand Down
1 change: 1 addition & 0 deletions edbterraform/data/templates/aws/validation.tf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module "spec" {

ba_project_id_default = var.ba_project_id
ba_ignore_image_default = var.ba_ignore_image
ba_cloud_account_default = var.ba_cloud_account
ba_pg_image_default = var.ba_pg_image
ba_proxy_image_default = var.ba_proxy_image
}
Expand Down
1 change: 1 addition & 0 deletions edbterraform/data/templates/azure/validation.tf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module "spec" {

ba_project_id_default = var.ba_project_id
ba_ignore_image_default = var.ba_ignore_image
ba_cloud_account_default = var.ba_cloud_account
ba_pg_image_default = var.ba_pg_image
ba_proxy_image_default = var.ba_proxy_image
}
Expand Down
1 change: 1 addition & 0 deletions edbterraform/data/templates/gcloud/validation.tf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module "spec" {

ba_project_id_default = var.ba_project_id
ba_ignore_image_default = var.ba_ignore_image
ba_cloud_account_default = var.ba_cloud_account
ba_pg_image_default = var.ba_pg_image
ba_proxy_image_default = var.ba_proxy_image
}
Expand Down
12 changes: 11 additions & 1 deletion edbterraform/data/terraform/aws/modules/specification/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,17 @@ output "biganimal" {
# spec project tags
tags = merge(local.tags, biganimal_spec.tags, {
Name = format("%s-%s-%s", name, local.cluster_name, random_id.apply.id)
})
})
data_groups = {
for data_group_name, data_group_spec in biganimal_spec.data_groups : data_group_name => merge(data_group_spec, {
cloud_account = data_group_spec.cloud_account == null ? var.ba_cloud_account_default : data_group_spec.cloud_account
})
}
witness_groups = {
for witness_group_name, witness_group_spec in biganimal_spec.witness_groups : witness_group_name => merge(witness_group_spec, {
cloud_account = witness_group_spec.cloud_account == null ? var.ba_cloud_account_default : witness_group_spec.cloud_account
})
}
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,12 @@ variable "ba_project_id_default" {
nullable = true
}

variable "ba_cloud_account_default" {
description = "BigAnimal cloud account default"
type = string
nullable = true
}

variable "ba_pg_image_default" {
description = "Dev only: BigAnimal postgres image to use if not defined within the biganimal configuration"
type = string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,17 @@ output "biganimal" {
# spec project tags
tags = merge(local.tags, biganimal_spec.tags, {
Name = format("%s-%s-%s", name, local.cluster_name, random_id.apply.id)
})
})
data_groups = {
for data_group_name, data_group_spec in biganimal_spec.data_groups : data_group_name => merge(data_group_spec, {
cloud_account = data_group_spec.cloud_account == null ? var.ba_cloud_account_default : data_group_spec.cloud_account
})
}
witness_groups = {
for witness_group_name, witness_group_spec in biganimal_spec.witness_groups : witness_group_name => merge(witness_group_spec, {
cloud_account = witness_group_spec.cloud_account == null ? var.ba_cloud_account_default : witness_group_spec.cloud_account
})
}
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ variable "ba_project_id_default" {
nullable = true
}

variable "ba_cloud_account_default" {
description = "BigAnimal cloud account default"
type = string
nullable = true
}

variable "ba_pg_image_default" {
description = "Dev only: BigAnimal postgres image to use if not defined within the biganimal configuration"
type = string
Expand Down
15 changes: 11 additions & 4 deletions edbterraform/data/terraform/common_vars.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,35 @@ variable "cloud_service_provider" {
}

variable "ba_project_id" {
description = "BigAnimal project ID to use if not defined within the biganimal configuration"
description = "BigAnimal project ID default if not defined within the biganimal configuration"
type = string
nullable = true
default = null
}

variable "ba_cloud_account" {
description = "Bring-Your-Own-Account default if 'cloud_account' is not defined within the biganimal configuration"
type = string
nullable = true
default = null
}

variable "ba_pg_image" {
description = "Dev only: BigAnimal postgres image to use if not defined within the biganimal configuration"
description = "Dev only: BigAnimal postgres image default if not defined within the biganimal configuration"
type = string
nullable = true
default = null
}

variable "ba_proxy_image" {
description = "Dev only: BigAnimal proxy image to use if not defined within the biganimal configuration"
description = "Dev only: BigAnimal proxy image default if not defined within the biganimal configuration"
type = string
nullable = true
default = null
}

variable "ba_ignore_image" {
description = "Ignore biganimal custom images"
description = "Ignore biganimal custom images input"
type = bool
nullable = false
default = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,17 @@ output "biganimal" {
# spec project tags
tags = merge(local.tags, biganimal_spec.tags, {
Name = format("%s-%s-%s", name, local.cluster_name, random_id.apply.id)
})
})
data_groups = {
for data_group_name, data_group_spec in biganimal_spec.data_groups : data_group_name => merge(data_group_spec, {
cloud_account = data_group_spec.cloud_account == null ? var.ba_cloud_account_default : data_group_spec.cloud_account
})
}
witness_groups = {
for witness_group_name, witness_group_spec in biganimal_spec.witness_groups : witness_group_name => merge(witness_group_spec, {
cloud_account = witness_group_spec.cloud_account == null ? var.ba_cloud_account_default : witness_group_spec.cloud_account
})
}
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,12 @@ variable "ba_project_id_default" {
nullable = true
}

variable "ba_cloud_account_default" {
description = "BigAnimal cloud account default"
type = string
nullable = true
}

variable "ba_pg_image_default" {
description = "Dev only: BigAnimal postgres image to use if not defined within the biganimal configuration"
type = string
Expand Down

0 comments on commit e4e2ecf

Please sign in to comment.