Initialize a Terraform working directory and download providers.
low risk
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.
| Flag | Meaning |
|---|---|
-upgrade | Upgrade providers to latest matching version constraints |
-backend=false | Skip backend initialization |
-reconfigure | Reconfigure backend ignoring existing config |
-migrate-state | Migrate state when changing backends |
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 →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.
Reference text is hand-written and may be incomplete — check man terraform for your version. Test destructive commands on a non-production system first.