Deployment with Terraform in cloud.ca
This deployment example will deploy :
- A VPC
- Two tiers, web (load balancing enabled) and data (standard).
- The web tier will contain 3 load balanced instances
- The data tier will contain 1 instance
- A public IP address will be acquired to load balance the instances in the web tier
- The tfstate.tf state file will be stored in swift to allow sharing within a team
-
Install Terraform
-
Retrive your API keys for your cloud.ca compute and object-storage environments, and export them to environment variables
export TF_VAR_api_key=YOUR_CS_API_KEY export TF_VAR_secret_key=YOUR_CS_SECRET_KEY export OS_USERNAME=YOUR_SWIFT_USERNAME export OS_PASSWORD=YOUR_SWIFT_PASSWORD export OS_TENANT_NAME=YOUR_SWIFT_TENANT_NAME export OS_AUTH_URL=https://auth-qc.cloud.ca/v2.0
-
Set terraform to use a container as remote backend.
terraform remote config -backend=swift -backend-config="path=dev"
By default, backend_container variable is set to dev. If you would like to use a different container, be sure to change it in the variables.tf file and modify the command above.
-
View plan to deploy infrastructure
terraform plan
-
Deploy your infrastructure
terraform apply