Skip to main content
The Terraform Cloud job agent creates workspaces and triggers runs, enabling infrastructure-as-code deployments with webhook-based status tracking.

How It Works

  1. Ctrlplane renders a workspace configuration from your template
  2. The workspace is created or updated via Terraform Cloud API
  3. Variables are synced to match your template
  4. A webhook notification configuration (ctrlplane-webhook) is created on the workspace (idempotent)
  5. A run is triggered with auto-apply
  6. Terraform Cloud sends webhook notifications as the run progresses
  7. The ctrlplane API receives webhooks and updates job status in the database
This is a fire-and-forget dispatch model — the workspace-engine does not poll or maintain long-running goroutines. Status tracking is handled entirely by TFC webhooks, making it resilient to engine restarts.

Prerequisites

  • Terraform Cloud or Terraform Enterprise account
  • API token with workspace, run, and notification configuration permissions
  • VCS connection (optional, for Git-based workflows)
  • A reachable webhook endpoint (the ctrlplane API must be accessible from TFC)

Configuration

Job Agent Setup

Create a job agent with type tfe:

Deployment Configuration

Environment Variables

Both the API and workspace-engine must share the same TFE_WEBHOOK_SECRET.

Webhook Status Mapping

When TFC sends a notification, the webhook handler maps the trigger to a ctrlplane job status:

Workspace Template

The template defines the Terraform Cloud workspace:

VCS Repository Settings

Variable Configuration

Template Context

The template has access to the full dispatch context:

triggerRunOnChange: false

When triggerRunOnChange is set to false, the dispatcher will:
  1. Upsert the workspace
  2. Sync variables
  3. Ensure the notification config exists
  4. Skip creating a run
This is useful when you want VCS pushes to trigger runs instead of ctrlplane creating them directly. The webhook notification config is still created so that run status updates flow back to ctrlplane.
Note: Correlating VCS-triggered runs back to ctrlplane jobs (by workspace name/ID instead of run ID) is a planned follow-up.

Example: Multi-Environment Infrastructure

Example: Agent-Based Execution

For private infrastructure, use agent execution mode:

Terraform Provider Configuration

When using the ctrlplane Terraform provider:

Troubleshooting

Workspace creation fails

  • Verify organization name is correct
  • Check API token has workspace:write permission
  • Ensure workspace name is valid (alphanumeric, hyphens, underscores)

VCS connection errors

  • Verify OAuth token ID is correct
  • Check repository exists and is accessible
  • Ensure branch or tag exists

Run fails to start

  • Check workspace has valid configuration
  • Verify VCS connection is working
  • Review workspace settings in Terraform Cloud UI

Variables not updating

  • Verify variable keys match expected format
  • Check for duplicate variable definitions
  • Sensitive variables won’t show values in UI

Webhook returns 401

  • Check TFE_WEBHOOK_SECRET is set on the API
  • Verify the same secret was used when creating the notification config on TFC
  • Ensure the x-tfe-notification-signature header is present

No webhook notifications received

  • Verify the webhookUrl is reachable from Terraform Cloud
  • Check the notification config exists on the TFC workspace (Settings > Notifications)
  • Review TFC’s notification delivery log for errors
  • For local development, use smee.io or localtunnel to expose your API

Job stays in inProgress

  • Verify webhooks are reaching the API (check API logs for POST /api/tfe/webhook)
  • Check the TFC run status directly in the TFC UI