Terraform commands
Run init, validate, fmt, plan, apply and destroy through teriac with the managed binary, and turn .tf files into -target flags with --file.
teriac can run the common Terraform commands for you. They use the teriac-managed binary directly
(no PATH lookup), so they work even when another terraform comes first on your PATH.
The commands
teriac init
teriac validate
teriac fmt
teriac fmt -- -recursive
teriac plan
teriac apply
teriac destroyExtra Terraform flags go after --:
teriac init -- -upgrade
teriac plan -- -var="env=prod" -out=tfplan
teriac apply -- tfplanEvery command takes --provider tofu to use OpenTofu instead:
teriac init -p tofu
teriac plan -p tofu -- -var-file=prod.tfvarsTargets from a file: --file
plan, apply and destroy take --file (-f). teriac reads the .tf file and adds a
-target for every resource, data and module block it finds. Comments are stripped first, so a
commented-out block is never targeted.
teriac plan --file main.tf # targets taken from a file
teriac plan --file main.tf --file network.tf # several files
teriac plan --file main.tf -- -var="env=prod" # with extra terraform flags
teriac apply --file main.tf -- -auto-approve
teriac destroy --file main.tf -- -auto-approveExample
Given this network.tf:
resource "aws_vpc" "main" {
cidr_block = "10.0.0.0/16"
}
# resource "aws_vpc" "old" { ... } ← ignored, it's a comment
module "subnets" {
source = "./modules/subnets"
vpc_id = aws_vpc.main.id
}
data "aws_availability_zones" "available" {}teriac plan --file network.tf runs:
terraform plan \
-target=aws_vpc.main \
-target=module.subnets \
-target=data.aws_availability_zones.availableThis is useful when you work on one file of a large root module and want a fast, focused plan.
Terraform itself warns that
-targetis for exceptional cases. Run a full plan before you merge.
Or just use terraform
terraform on your PATH is ~/.teriac/bin/terraform, the same binary these commands run, so every
other Terraform command works as usual:
terraform state list
terraform workspace select prod
tofu providers lock -platform=linux_amd64