Initialize a Terraform Working Directory
Understand how to use the terraform init command to prepare your working directory by configuring state back-ends, downloading modules, and retrieving provider plugins. This lesson helps you grasp the initialization process critical for managing Terraform infrastructure effectively.
We'll cover the following...
The command terraform init is used to initialize the directory containing a Terraform configuration. Once we’ve written a configuration or cloned one from source control, this is the first command we run.
Operations of the terraform init command
The terraform init command performs operations to prepare the directory holding the configuration for use. In general, they’re as follows:
-
Prepare the state storage: Whether we’re using a local or remote back-end,
terraform initprepares that back-end for use by Terraform’s state. -
Retrieve modules: The
terraform initprocess checks for any modules being used, retrieves the modules from their source location, and places them in the config directory. -
Retrieve plugins: The
terraform initprocess looks for all references, direct and indirect, to providers and provisioners and then retrieves the plugins from the desired location. ...