Terraform Cloud Operator 2.3 adds workspace run operations

Terraform Cloud Operator for Kubernetes adds more Day 2 operations. Users can now start runs using workspace resource annotations.

In November 2023, we announced the general availability of the Terraform Cloud Operator for Kubernetes. The Terraform Cloud Operator streamlines infrastructure management, allowing platform teams to offer a Kubernetes-native experience for their users while standardizing on Terraform workflows. Today we are excited to announce the general availability of version 2.3 of the Terraform Cloud Operator, with the ability to initiate workspace runs declaratively.

»Introducing workspace run operations

In previous versions of the Terraform Cloud Operator v2, the only way to start a run was by patching the restartedAt timestamp in the Module resource. But this approach was not intuitive, did not work for all types of workspaces and workflows, and did not allow users to control the type of run to perform. This challenge hindered migration efforts to the newest version of the Terraform Cloud Operator. . Now with version 2.3, users can declaratively start plan, apply, and refresh runs on workspaces. This enhances self-service by allowing developers to initiate runs on any workspace managed by the Operator, including VCS-driven workspaces.

The Workspace custom resource in version 2.3 of the operator supports three new annotations to initiate workspace runs:

  •  workspace.app.terraform.io/run-new: Set this annotation to "true" to trigger a new run.
  •  workspace.app.terraform.io/run-type: Set to plan (default), apply, or refresh to control the type of run.
  •  workspace.app.terraform.io/run-terraform-version: Specifies the version of Terraform to use for a speculative plan run. For other run types, the workspace version is used.

As an example, a basic Workspace resource looks like this:

apiVersion: app.terraform.io/v1alpha2kind: Workspacemetadata:  name: thisspec:  organization: kubernetes-operator  token:    secretKeyRef:      name: tfc-operator      key: token  name: kubernetes-operator

Using kubectl as shown here, annotate the above resource to immediately start a new apply run:

kubectl annotate workspace this \    workspace.app.terraform.io/run-new="true" \    workspace.app.terraform.io/run-type=apply --overwrite

The annotation is reflected in the Workspace resource for observability:

apiVersion: app.terraform.io/v1alpha2kind: Workspacemetadata: annotations:    workspace.app.terraform.io/run-new: "true"    workspace.app.terraform.io/run-type: apply  name: thisspec:  organization: kubernetes-operator  token:    secretKeyRef:      name: tfc-operator      key: token  name: kubernetes-operator

After the run is successfully triggered, the operator will set the run-new value back to "false".

»Learn more and get started

HashiCorp works to continuously improve the Kubernetes ecosystem by enabling platform teams at scale. Learn more about the Terraform Cloud Operator by reading the documentation and the Deploy infrastructure with the Terraform Cloud Kubernetes Operator v2 tutorial. If you are completely new to Terraform, sign up for Terraform Cloud and get started using the Free offering today.

Sign up for the latest HashiCorp news

By submitting this form, you acknowledge and agree that HashiCorp will process your personal information in accordance with the Privacy Policy.