Explain Terraform code

Paste Terraform and Vibe explains what it will build and change: each resource, variable and output, what plan and apply do, and why one changed value can destroy and rebuild a resource.

main.tf

Up to 1,500 characters (about 60 lines). Your code is sent to Unvibe and Anthropic to write the explanation. Don't paste keys or passwords. Common key formats are refused.

Vibe25 lines selected

Press Explain it for the sample, or paste your own code first.

What this Terraform sample shows

providers and init
required_providers says which plugins the code needs and pins their versions. terraform init downloaded hashicorp/local v2.9.1 and hashicorp/random v3.9.1, printed signed by HashiCorp for each, and wrote .terraform.lock.hcl with those versions. Terraform's own message says to commit that lock file so later terraform init runs pick the same versions.
resources and references
Each resource block is one thing Terraform manages. random_pet.name.id points at the name the first resource makes, so Terraform created random_pet first and the file second, and wrote out/staging.json with {"env":"staging","name":"immense-dassie"}. A typo, random_pet.nme.id, stopped terraform validate with Reference to undeclared resource.
plan and apply
terraform plan lists what would change and changes nothing: Plan: 2 to add, 0 to change, 0 to destroy. apply does it, but asks first: Only 'yes' will be accepted to approve. Answering no printed Apply cancelled. and created nothing, and -auto-approve skips the question. Run again with nothing changed, apply printed No changes. Your infrastructure matches the configuration.
variables and outputs
env defaults to staging, and -var env=production changes it for one run. The output printed app_name = "immense-dassie" after the first apply, and terraform output prints it again any time. Because the name's keepers include env, changing env made a new name, powerful-giraffe, instead of keeping the old one.

Good to know

  • Run with Terraform 1.17.1 on Linux, downloaded from releases.hashicorp.com and checked against HashiCorp's signed checksums, in a new folder holding only main.tf, with no backend, so the state stayed in a local terraform.tfstate. No cloud account or credentials were used.
  • When out/production.json was deleted by hand, the next plan noticed and planned to write it again: local_file.config will be created, Plan: 1 to add.

Watch out: Changing one value can destroy things, not just edit them. With -var env=production, the plan said must be replaced for both resources and ended Plan: 2 to add, 0 to change, 2 to destroy. Apply deleted out/staging.json and replaced the name. Read the destroy count in every plan before you type yes. The state file also keeps a copy of what it wrote: terraform.tfstate held the JSON file's full content in plain text, so never commit it.

Explain Terraform code beside your editor

Unvibe is a free app for Mac and Windows. In the app there is no pasting: select code in any app and press Control+U (Ctrl+Alt+U on Windows).

Install on Mac

curl -fsSL https://unvibe.site/install.sh | bash

Paste into Terminal. Unvibe isn't notarized by Apple yet, so this is the smooth path.

Opening the .dmg the first time
  1. Open the .dmg and drag Unvibe to Applications.
  2. Open it once; macOS says it can't verify it. Click Done.
    macOS dialog: Unvibe Not Opened, with Done and Move to Trash
    Real screen, macOS 15
  3. System Settings › Privacy & Security › Open Anyway. Confirm, then enter your Mac password. The button shows for about an hour after you try to open Unvibe.
    macOS Privacy & Security, Security section: Unvibe was blocked to protect your Mac, with the Open Anyway button
    Real screen, macOS 15

The Terminal line checks the download against the published SHA-256 and Unvibe's self-signed signature before it installs anything. More help with the first open