CLI-driven Workflow
With the CLI integration, you can use Terrakubeβs collaboration features in the Terraform CLI workflow that you are already familiar with. This gives you the best of both worlds as a developer who uses the Terraform CLI, and it also works well with your existing CI/CD pipelines.
You can initiate runs with the usual terraform plan and terraform apply commands and then monitor the run progress from your terminal. These runs run remotely in Terrakube.
At the moment all the terraform operations are executed remotely in Terrakube
Configuration
To use the CLI-driven workflow the firts step will be to setup our project to use the terraform remote backend or the cloud block as the following example:
terraform {
backend "remote" {
hostname = "8080-azbuilder-terrakube-po7evw1u15x.ws-us86.gitpod.io"
organization = "simple"
workspaces {
name = "workspace1"
}
}
}
resource "random_string" "random" {
length = 16
special = true
override_special = "/@Β£$"
}terraform {
cloud {
organization = "simple"
hostname = "8080-azbuilder-terrakube-sscrnu9jbie.ws-us99.gitpod.io"
workspaces {
name = "samplecloud"
}
}
}
resource "random_string" "random" {
length = 16
special = true
override_special = "/@Β£$"
}Hostname
This should be the Terrakube API
Organization
This should be the Terrakube organization where the workspace will be created.
Workspace
The name of the workspace to be created. Or you can use an existing workspace created in the UI using the API or CLI driven workflow.
The cloud block is available in Terraform v1.1 and later. Previous versions can use the remote bakced to configure the CLI workflow and migrate state. Using tags in the cloud block is not yet supported
Terraform login.
Once we have added the terraform remote state configuration we will need to authenticate to Terrakube using the following command with the Terrakube API as the following:
The output will look something like the following:

Terraform Init
After the authentication is completed you can run the following command to initialized the workspace
The output will look like this:
If the initialization is successfull you should be able to see something like this:
Implicit Workspace Creation
Terrakube will create a new workspace with the name you specify in the cloud block if it doesnβt already exist in your organization. You will see a message about this when you run terraform init.
Terraform Plan
Once the terraform initialization is completed we should be able to run a terraform plan remotely using the following:
If you go to the Terrakube UI, you will be able to see the workspace plan execution.

Terraform Apply
You can also execute a terraform apply and it will run inside Terrakube remotely.

The terraform apply can only be approved using the terraform CLI. You wont be able to approve the job inside the UI.
Terraform Destroy
Executing the terraform destroy is also possible.
Inside the UI the terraform destroy operation will look like this.

The terraform destroy can only be approved using the terraform CLI. You wont be able to approve the job inside the UI.
Last updated