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 toplan
(default),apply
, orrefresh
to control the type of run. -
workspace.app.terraform.io/run-terraform-version
: Specifies the version of Terraform to use for a speculativeplan
run. For other run types, the workspace version is used.
As an example, a basic Workspace
resource looks like this:
apiVersion: app.terraform.io/v1alpha2
kind: Workspace
metadata:
name: this
spec:
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/v1alpha2
kind: Workspace
metadata:
annotations:
workspace.app.terraform.io/run-new: "true"
workspace.app.terraform.io/run-type: apply
name: this
spec:
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
More blog posts like this one
Fix the developers vs. security conflict by shifting further left
Resolve the friction between dev and security teams with platform-led workflows that make cloud security seamless and scalable.
HashiCorp at AWS re:Invent: Your blueprint to cloud success
If you’re attending AWS re:Invent in Las Vegas, Dec. 2 - Dec. 6th, visit us for breakout sessions, expert talks, and product demos to learn how to take a unified approach to Infrastructure and Security Lifecycle Management.
Speed up app delivery with automated cancellation of plan-only Terraform runs
Automatic cancellation of plan-only runs allows customers to easily cancel any unfinished runs for outdated commits to speed up application delivery.