snippetbashTip
terraform init — Initialize a new or existing Terraform working directory. More information: <https://developer.hashi
Viewed 0 times
commandterraform initnewcliworkingexistingterraforminitialize
Problem
How to use the
terraform init command: Initialize a new or existing Terraform working directory. More information: <https://developer.hashicorp.com/terraform/cli/commands/init>.Solution
terraform init — Initialize a new or existing Terraform working directory. More information: <https://developer.hashicorp.com/terraform/cli/commands/init>.Initialize the current working directory:
terraform initInitialize and upgrade modules and providers to the latest allowed versions:
terraform init -upgradeInitialize and reconfigure the backend, ignoring any saved configuration:
terraform init -reconfigureInitialize and reconfigure the backend, attempting to migrate any existing state:
terraform init -migrate-stateInitialize with additional backend configuration:
terraform init -backend-config '{{key}}={{value}}'Initialize without backend or HCP Terraform initialization:
terraform init -backend=falseInitialize without interactive prompts (useful for automation):
terraform init -input=falseInitialize with the dependency lockfile mode set to readonly:
terraform init -lockfile readonlyCode Snippets
Initialize the current working directory
terraform initInitialize and upgrade modules and providers to the latest allowed versions
terraform init -upgradeInitialize and reconfigure the backend, ignoring any saved configuration
terraform init -reconfigureInitialize and reconfigure the backend, attempting to migrate any existing state
terraform init -migrate-stateInitialize with additional backend configuration
terraform init -backend-config '{{key}}={{value}}'Context
tldr-pages: common/terraform init
Revisions (0)
No revisions yet.