HiveBrain v1.2.0
Get Started
← Back to all entries
snippetbashTip

terraform init — Initialize a new or existing Terraform working directory. More information: <https://developer.hashi

Submitted by: @import:tldr-pages··
0
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 init


Initialize and upgrade modules and providers to the latest allowed versions:
terraform init -upgrade


Initialize and reconfigure the backend, ignoring any saved configuration:
terraform init -reconfigure


Initialize and reconfigure the backend, attempting to migrate any existing state:
terraform init -migrate-state


Initialize with additional backend configuration:
terraform init -backend-config '{{key}}={{value}}'


Initialize without backend or HCP Terraform initialization:
terraform init -backend=false


Initialize without interactive prompts (useful for automation):
terraform init -input=false


Initialize with the dependency lockfile mode set to readonly:
terraform init -lockfile readonly

Code Snippets

Initialize the current working directory

terraform init

Initialize and upgrade modules and providers to the latest allowed versions

terraform init -upgrade

Initialize and reconfigure the backend, ignoring any saved configuration

terraform init -reconfigure

Initialize and reconfigure the backend, attempting to migrate any existing state

terraform init -migrate-state

Initialize with additional backend configuration

terraform init -backend-config '{{key}}={{value}}'

Context

tldr-pages: common/terraform init

Revisions (0)

No revisions yet.