Skip to content

Terraform & Helm: Terraform: everyday workflow

8 Terraform & Helm commands: Terraform: everyday workflow. Click a command to see what each part does.

Index
8 items
Click a command to see what each part does.

Terraform: everyday workflow8

  • terraform init -upgradeInitialise and upgrade providers

    What each part does

    1. initdownload providers/modules and configure the backend
    2. -upgradepick the newest versions allowed by the constraints
  • terraform fmt -recursive -check && terraform validateFormat and validate

    What each part does

    1. fmt -recursiveformat .tf files in sub-folders too
    2. -checkdon't change files; exit non-zero if formatting is needed (CI)
    3. validatecheck syntax and internal consistency (no API calls)
  • terraform plan -var-file=<env>.tfvars -out=tfplanPlan with a var file and save the plan

    What each part does

    1. plancompute what would change
    2. -var-file=<env>.tfvarsload variable values from a file (repeatable)
    3. -out=tfplansave this exact plan to apply later (contains values in clear text: keep it private)
  • terraform apply tfplanApply exactly the reviewed planCaution

    What each part does

    1. apply tfplanapply the saved plan with no re-planning and no prompt
  • terraform plan -input=false -no-color -detailed-exitcode -out=tfplanCI-friendly plan: did anything change?

    What each part does

    1. -input=falsenever prompt for variables
    2. -no-colorplain output for logs
    3. -detailed-exitcodeexit 0 = no changes, 1 = error, 2 = changes present
  • terraform plan -target=<address> -out=tfplanPlan only one resource (exceptional cases)

    What each part does

    1. -target=<address>limit to that resource and its dependencies (use sparingly)
  • terraform plan -replace=<address> -out=tfplanForce replacement of one resourceCaution

    What each part does

    1. -replace=<address>plan to destroy and recreate it (successor of taint)
  • terraform -chdir=<dir> planRun in another folder without cd

    What each part does

    1. -chdir=<dir>global option, goes before the subcommand

My DevOps Playbook by Angelo John Calleja

New runbook

GitHub not connected

Saving is handled by the site: the GitHub token is stored in Cloudflare, not in your browser. Enter the editor password (the EDITOR_PASSWORD secret) to unlock saving in this browser.

Saving commits to gelogrammer/My_DevOps_Playbook. Create a fine-grained token with access to only this repo andContents: Read and write, then paste it here. It is stored only in this browser.

src/content/docs/…