Skip to main content

Deployment via Terraform commands

Navigate to the specific module directory which you are planning to deploy and follow below steps:

Setup Terraform Backend

By default, Terraform stores state locally in a file named terraform.tfstate. This default configuration can make Terraform usage difficult for teams when multiple users run Terraform at the same time and each machine has its own understanding (i.e. state file) of the current infrastructure.

To help you avoid such issues, configure a remote state that points to a Cloud Storage bucket. Remote state is a feature of Terraform backends. It stores the state as an object in a configurable prefix in a pre-existing bucket on Google Cloud Storage (GCS). The bucket must exist prior to configuring the backend.

This backend supports state locking.

note

It is highly recommended that you enable Object Versioning on the GCS bucket to allow for state recovery in the case of accidental deletions and human error.

Example Configuration

Create a file add the following text to a new Terraform configuration file called backend.tf.

terraform {
backend "gcs" {
bucket = "TF_STATE_BUCKET"
prefix = "PATH_TO_GCS_FOLDER"
}
}

TF_STATE_BUCKET: GCS Bucket ID to store Terraform state.

PATH_TO_GCS_FOLDER: Path to folders/sub-folders within TF_STATE_BUCKET.

Deploy a RAD Lab Module

Execute below commands in the same order to deploy the module:

# Initialise the Terraform codebase
terraform init -upgrade -reconfigure

# Create the necessary resources
terraform apply -auto-approve
RAD Lab Deployment ID

Save the deployment_id from the output for future reference. It is required to supply the deployment id for updating or deleting the RAD Lab module deployment.