This repository contains a collection of Terraform configurations to deploy a CrateDB cluster to various environments.
Supported environments are:
- aws: Deployment of EC2 instances with a public-facing load balancer
- azure: Deployment of Azure VMs with a public-facing load balancer
TFLint is configured to check the code for issues.
Inside the respective subdirectories, run tflint --init
to initialize it, and tflint
to run it. Different .tflint.hcl
configurations exist for each subdirectory.
Before committing, please run terraform fmt
to apply Terraform's standard configuration style consistently.
Integration testing is done using Terratest. The tests start a new cluster and perform a few very basic checks to verify if the deployment was successful.
Since the tests need details on the cloud environment to run in, set up corresponding environment variables, e.g. in a .env
file:
AWS_TEST_REGION=eu-central-1
AWS_TEST_VPC_ID=vpc-123
AWS_TEST_SSH_KEYPAIR=cratedb_terraform
AWS_TEST_SUBNET_IDS="[\"subnet-123\", \"subnet-124\"]"
AWS_TEST_AVAILABILITY_ZONES="[\"eu-central-1b\", \"eu-central-1a\"]"
AZURE_TEST_SUBSCRIPTION_ID=abc
To run the test, load the environment variables and pass them to go test
(see run.sh):
cd test
source .env
AWS_TEST_REGION=$AWS_TEST_REGION \
AWS_TEST_VPC_ID=$AWS_TEST_VPC_ID \
AWS_TEST_SSH_KEYPAIR=$AWS_TEST_SSH_KEYPAIR \
AWS_TEST_SUBNET_IDS=$AWS_TEST_SUBNET_IDS \
AWS_TEST_AVAILABILITY_ZONES=$AWS_TEST_AVAILABILITY_ZONES \
AZURE_TEST_SUBSCRIPTION_ID=$AZURE_TEST_SUBSCRIPTION_ID \
go test
If you want to run only a single test, you can specific the name of the test, e.g. go test -run TestTerraformAzure
.