terraform init

Initialize a Terraform working directory and download providers.

low risk

interactive breakdown — edit the command and press Explain
$ 
What it does

terraform init initializes the working directory: downloads provider plugins, sets up the backend for state storage, and installs modules. Must be run before any other Terraform commands and after any backend or provider changes.

Common flags
FlagMeaning
-upgradeUpgrade providers to latest matching version constraints
-backend=falseSkip backend initialization
-reconfigureReconfigure backend ignoring existing config
-migrate-stateMigrate state when changing backends
Examples
terraform initInitialize working directory · explain & risk-check →
terraform init -upgradeUpgrade providers to latest allowed versions · explain & risk-check →
terraform init -backend-config=backend.hclInit with external backend config (for secrets) · explain & risk-check →
terraform init -reconfigureReset and reconfigure backend · explain & risk-check →
Pro tip

Use `terraform init -backend-config=backend.hcl` to keep backend credentials (S3 bucket, DynamoDB table names) out of version-controlled Terraform files — a required practice for security.

Related
terraform plan terraform apply kubectl apply
Open the full explainer →More in Terraform, Ansible & IaC

Reference text is hand-written and may be incomplete — check man terraform for your version. Test destructive commands on a non-production system first.