# Terraform

Run Terraform and OpenTofu in Buddy pipelines - plan, approve, apply, detect drift, and keep state in a Buddy artifact or your own backend.

## Contents

- [Introduction](/docs/terraform/introduction.md) - How Buddy runs Terraform and OpenTofu: native Plan, Apply, and Drift Detection actions with a resource diff, plus the Terraform CLI action for any command.
- [Quick start](/docs/terraform/quickstart.md) - Build your first Terraform pipeline in Buddy: plan with OpenTofu, approve the diff, and apply it, with state kept in a Buddy artifact.
- [TF & OpenTofu tools](/docs/terraform/versions.md) - Choose the tool for Terraform actions in Buddy: OpenTofu, open-source Terraform, or a custom binary in your own Docker image, and pin the version to run.
- [Plan and Apply](/docs/terraform/plan-and-apply.md) - How the Terraform Plan and Apply actions in Buddy work: generated commands, the plan file, the structured resource diff, extra arguments, and conditional apply.
- [State backends](/docs/terraform/state.md) - Where the Terraform state lives in Buddy pipelines: a Buddy artifact with locking, S3 or GCS with integration credentials, or your own backend.
- [Credentials and variables](/docs/terraform/credentials-and-variables.md) - Give Terraform actions in Buddy access to AWS and Google with integrations, keep secrets in Buddy variables, and pass inputs with TF_VAR_ and tfvars files.
- [Workspaces and environments](/docs/terraform/workspaces-and-environments.md) - Run one Terraform configuration against several environments in Buddy with workspaces, separate state backends, or one pipeline per directory.
- [Drift detection](/docs/terraform/drift-detection.md) - Find infrastructure changed or removed outside of Terraform with the Drift Detection action in Buddy: run it on a schedule and get notified about drift.
- [Terraform CLI action](/docs/terraform/terraform-cli.md) - Run any Terraform command in a Buddy pipeline with the Terraform CLI action: fmt, validate, import, state, and output, with the same backends as Plan and Apply.
- [Output variables](/docs/terraform/output-variables.md) - Variables exported by the Terraform Plan, Apply, and Drift Detection actions in Buddy: change counters, summaries, destroyed resources, and how to use them.
- [Common workflows](/docs/terraform/recipes.md) - Ready-made Terraform pipelines for Buddy: plan on pull requests, destroy behind an approval, import existing resources, and lint and scan before planning.
- [Troubleshooting](/docs/terraform/troubleshooting.md) - Fixes for common Terraform problems in Buddy: missing plan file, Apply on the wrong state, artifact not found, stale plans, image tags, and state locks.

---
Original source: https://buddy.works/docs/terraform