Skip to main content
The ubx-plugin-terraform plugin translates IR JSON to Terraform HCL (main.tf) and wraps the terraform CLI for plan, apply, and destroy operations.

Install

ubx plugin install terraform

Configure

In workspace.xcl:
workspace {
  engine = "terraform"
}

What the plugin generates

.ubx/
└── main.tf     # Complete Terraform HCL configuration
The generated main.tf contains:
  1. File header comment (# Generated by ubx-plugin-terraform — do not edit)
  2. terraform {} block (backend + required_providers)
  3. provider {} blocks (from XCL provider declarations)
  4. variable {} blocks (from XCL input declarations)
  5. locals {} block (from XCL locals declarations)
  6. resource {} blocks (from XCL resource declarations)
  7. output {} blocks (from XCL output declarations)

Type path mapping

XCL type paths are converted to Terraform resource type names using CamelCase → snake_case:
XCL type pathTerraform resource type
aws.ec2.Vpcaws_vpc
aws.ec2.NatGatewayaws_ec2_nat_gateway
aws.s3.Bucketaws_s3_bucket
aws_vpcaws_vpc (single-segment: passed through)
Multi-segment paths are lowercased with segments joined by _ after CamelCase-to-snake_case conversion.

Input → variable mapping

XCL input fields become Terraform variable blocks:
// XCL
input "networking" {
  vpc_cidr: string = "10.0.0.0/16"
}
# Generated HCL
variable "vpc_cidr" {
  type    = string
  default = "10.0.0.0/16"
}

Output → output mapping

XCL output blocks become Terraform output blocks:
// XCL
output vpc_id {
  value = vpc.id
}
# Generated HCL
output "vpc_id" {
  value = aws_vpc.networking-vpc.id
}

Plugin RPCs

RPCDescription
CompileGenerates main.tf, returns artifact_uri
PlanRuns terraform plan, returns summary
ApplyRuns terraform apply, streams events
DestroyRuns terraform destroy, streams events

Prerequisites

The terraform binary must be on $PATH. Install from developer.hashicorp.com/terraform.

Backend

Terraform backend configuration is generated from the XCL backend {} block:
terraform {
  backend "s3" {
    bucket = "my-state-bucket"
    key    = "ubx/networking/state"
    region = "us-east-1"
  }
}
For local backend, no backend block is emitted (Terraform defaults to local).