Planton logoPlanton

Loading...

Terraform Commands

The planton terraform command group runs infrastructure operations using Terraform as the IaC engine. It shares the same HCL modules and execution engine as the OpenTofu commands but invokes the terraform binary instead of tofu.

Prerequisites

  • Terraform binary: The terraform binary must be installed and available on your PATH. Install from developer.hashicorp.com/terraform.
  • Module resolution: The CLI resolves HCL modules through the same resolution chain as OpenTofu: direct path, GitHub release archive, or staging area. See Module Management for details.

Relationship to OpenTofu

Planton's Terraform and OpenTofu command groups share the same:

  • HCL modules: Every deployment component has a single iac/tf/ directory used by both engines
  • Module resolution: Both use the same download, caching, and staging mechanisms
  • Execution engine: Both route through the same Go package (tofumodule.RunCommand) with the binary name as the only difference

The practical difference is the binary invoked: terraform vs. tofu. Choose based on your organization's licensing and toolchain preferences.

Subcommands

init

Initialize the backend configuration and download required providers.

planton terraform init --manifest database.yaml
planton terraform init --manifest database.yaml --backend-type s3 --backend-config bucket=my-state
FlagDefaultDescription
--backend-typelocalBackend type: local, s3, gcs, azurerm, etc.
--backend-configBackend configuration key=value pairs (repeatable)
--module-versionCheck out a specific version of the IaC modules

plan

Preview infrastructure changes without applying them.

planton terraform plan --manifest database.yaml
planton terraform plan --manifest database.yaml --destroy
FlagDefaultDescription
--destroyfalseCreate a destroy plan instead of an apply plan
--module-versionCheck out a specific version of the IaC modules
--no-cleanupfalseKeep workspace copy after execution

apply

Deploy infrastructure by applying the planned changes.

planton terraform apply --manifest database.yaml
planton terraform apply --manifest database.yaml --auto-approve
planton terraform apply --manifest api.yaml --set spec.container.replicas=5
FlagDefaultDescription
--auto-approvefalseSkip interactive approval before applying
--module-versionCheck out a specific version of the IaC modules
--no-cleanupfalseKeep workspace copy after execution

destroy

Tear down all resources managed by the current state.

planton terraform destroy --manifest database.yaml
planton terraform destroy --manifest database.yaml --auto-approve
FlagDefaultDescription
--auto-approvefalseSkip interactive approval before destroying
--module-versionCheck out a specific version of the IaC modules
--no-cleanupfalseKeep workspace copy after execution

refresh

Sync the Terraform state with actual cloud state without modifying any resources.

planton terraform refresh --manifest database.yaml
FlagDefaultDescription
--module-versionCheck out a specific version of the IaC modules
--no-cleanupfalseKeep workspace copy after execution

Flags

All planton terraform subcommands inherit persistent flags from the parent command. Like OpenTofu direct commands, --manifest does not have the -f shorthand.

Parent Persistent Flags (All Subcommands)

FlagShortDescription
--manifestPath to the deployment-component manifest file
--input-dirDirectory containing target.yaml and credential YAML files
--kustomize-dirDirectory containing kustomize configuration
--overlayKustomize overlay (e.g., prod, dev, staging)
--module-dirDirectory containing the Terraform module (default: current directory)
--setOverride manifest values using key=value pairs
--provider-config-pPath to provider credentials file

Direct Terraform commands do not support --clipboard, --stack-input, or the -f shorthand for --manifest. Use unified commands for those input methods.

Differences from OpenTofu Commands

FeatureTerraformOpenTofu
Subcommands5 (init, plan, apply, destroy, refresh)7 (adds generate-variables, load-tfvars)
Binaryterraformtofu
LicenseBSL 1.1 (HashiCorp)MPL 2.0 (OpenTofu)
HCL modulesSameSame
Module resolutionSameSame

The generate-variables and load-tfvars utility commands are only available under planton tofu. Their output is compatible with both Terraform and OpenTofu, so you can use planton tofu generate-variables even if you plan to run the generated files with Terraform.

Typical Workflow

# 1. Initialize backend and download providers
planton terraform init --manifest database.yaml \
  --backend-type s3 \
  --backend-config bucket=my-state \
  --backend-config key=database/terraform.tfstate

# 2. Preview
planton terraform plan --manifest database.yaml

# 3. Deploy
planton terraform apply --manifest database.yaml --auto-approve

# 4. Tear down when done
planton terraform destroy --manifest database.yaml --auto-approve

What's Next

  • CLI Reference — Complete flag reference
  • Unified Commands — Provisioner-agnostic alternative to direct Terraform commands
  • OpenTofu Commands — OpenTofu engine commands (shared execution engine)
  • Module Management — Module versioning and the staging area

Next article

Module Management

Module Management Planton deployment components ship as IaC modules — Pulumi programs (Go) and HCL configurations (Terraform/OpenTofu) — that are resolved and executed at runtime. This page covers the commands that manage those modules and the CLI binary itself. Module Resolution When you run a deployment command, the CLI needs to locate the correct IaC module for the component kind in your manifest. The resolution chain differs by engine. Pulumi Module Resolution Direct path: If --module-dir...
Read next article