Installation
Use the documents below to install Terraform on Linux and Windows
https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli
To verify terraform Installation
run terraform -help
Prepare Terraform
After installing Terraform on your Machine, create a Terraform directory with resource.tf file and copy the corresponding resource.tf file from the document below into it
https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli
Use the document below to configure and get your BigAnimal API-Token.
Your Terraform directory should look like the output below
The Resources.tf file
Describes the various resources that you want to provision inside the BigAnimal Cluster like Instance_type, Storage and IP_range.
Below are examples of the resource.tf files for provisioning BigAnimal in Azure and AWS
Provisioning BigAnimal in Azure
terraform {
required_providers {
biganimal = {
source = "EnterpriseDB/biganimal"
version = "0.4.2"
}
random = {
source = "hashicorp/random"
version = "3.5.1"
}
}
}
resource "random_password" "password" {
length = 16
special = true
override_special = "!#$%&*()-_=+[]{}<>:?"
}
variable "cluster_name" {
type = string
description = "The name of the cluster."
}
variable "project_id" {
type = string
description = "BigAnimal Project ID"
}
resource "biganimal_cluster" "single_node_cluster" {
cluster_name = var.cluster_name
project_id = var.project_id
allowed_ip_ranges {
cidr_block = "127.0.0.1/32"
description = "localhost"
}
allowed_ip_ranges {
cidr_block = "192.168.0.1/32"
description = "description!"
}
backup_retention_period = "6d"
cluster_architecture {
id = "single"
nodes = 1
}
csp_auth = false
instance_type = "azure:Standard_D2s_v3"
password = resource.random_password.password.result
pg_config {
name = "application_name"
value = "created through terraform"
}
pg_config {
name = "array_nulls"
value = "off"
}
storage {
volume_type = "azurepremiumstorage"
volume_properties = "P1"
size = "4 Gi"
}
pg_type = "epas"
pg_version = "14"
private_networking = false
cloud_provider = "azure"
read_only_connections = false
region = "eastus2"
}
output "password" {
sensitive = true
value = resource.biganimal_cluster.single_node_cluster.password
}
output "faraway_replica_ids" {
value = biganimal_cluster.single_node_cluster.faraway_replica_ids
Provisioning BigAnimal in AWS
terraform {
required_providers {
biganimal = {
source = "EnterpriseDB/biganimal"
version = "0.4.2"
}
random = {
source = "hashicorp/random"
version = "3.5.1"
}
}
}
resource "random_password" "password" {
length = 16
special = true
override_special = "!#$%&*()-_=+[]{}<>:?"
}
variable "cluster_name" {
type = string
description = "The name of the cluster."
}
variable "project_id" {
type = string
description = "BigAnimal Project ID"
}
resource "biganimal_cluster" "single_node_cluster" {
cluster_name = var.cluster_name
project_id = var.project_id
allowed_ip_ranges {
cidr_block = "127.0.0.1/32"
description = "localhost"
}
allowed_ip_ranges {
cidr_block = "192.168.0.1/32"
description = "description!"
}
backup_retention_period = "6d"
cluster_architecture {
id = "single"
nodes = 1
}
csp_auth = true
instance_type = "aws:m5.large"
password = resource.random_password.password.result
pg_config {
name = "application_name"
value = "created through terraform"
}
pg_config {
name = "array_nulls"
value = "off"
}
storage {
volume_type = "gp3"
volume_properties = "gp3"
size = "4 Gi"
}
pg_type = "epas"
pg_version = "14"
private_networking = false
cloud_provider = "aws"
read_only_connections = false
region = "us-east-1"
}
output "password" {
sensitive = true
value = resource.biganimal_cluster.single_node_cluster.password
}
output "faraway_replica_ids" {
value = biganimal_cluster.single_node_cluster.faraway_replica_ids
}
For more information regarding the resource.tf file, please refer to the document below
Provisioning BigAnimal Cluster
To provision BigAnimal, first you have to initialize terraform.
Run terraform init
You will get an output like the one below confirming that terraform have been initialize.
After running terraform init, grant permission to the get-token.sh file as shown below
chmod 775 get-token.sh
Run ./get-token.sh to get your BigAnimal Token.
You will get an output with the token as shown below
Before you enter 'y' for yes, Copy the BigAnimal Authentication code link and paste it on a web browser to confirm and authenticate BigAnimal
After the confirmation and verification of the code, you can enter 'y' for yes and will receive a token as shown in the screenshot below
Now you can run terraform apply to start provisioning of BigAnimal cluster
Run terraform apply
It will prompt you to enter the Cluster name of the BigAnimal Cluster you want to provision, then the project ID and the token. Copy the token without the double quote "" signs at the begin and end of the token. See screenshot below.
Terraform will show you which actions it is going to perform
Terraform will then show you what it plans to do and prompts you to approve it. See screenshot below. Terraform will start to provision the Cluster if you enter yes
At this Point you should be able to see your BigAnimal Cluster creating on the BigAnimal Portal
Run Terraform destroy
If you want to delete the cluster, run terraform destroy and it will prompt you to give the cluster name, Project ID and token as shown on the screenshot below
Terraform will show all the actions to be performed to destroy the cluster and ask you to confirm if you really want to destroy the cluster