Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

How does terraform init and terraform apply work?


Asked by Kaysen Ray on Dec 13, 2021 FAQ



1. Terraform init initializes the (local) Terraform environment. Usually executed only once per session. 2. Terraform plan compares the Terraform state with the as-is state in the cloud, build and display an execution plan. This does not change the deployment (read-only). 3. Terraform apply executes the plan.
In addition,
The terraform init command is used to initialize a working directory containing Terraform configuration files. This is the first command that should be run after writing a new Terraform configuration or cloning an existing one from version control.
Accordingly, Because terraform apply will display a plan for confirmation before proceeding to change any infrastructure, that's the command you run for final review. $ terraform apply An execution plan has been generated and is shown below. # ... After one last check, you are ready to tell Terraform to provision real infrastructure.
In fact,
Terraform can use GraphViz to generate a visual representation of either a configuration or execution plan. The Azure Terraform Visual Studio Code extension implements this feature via the visualize command. From the menu bar, select View > Command Palette > Azure Terraform: Visualize. Run Terraform plan command
Also Know,
Terraform lifecycle consists of – init, plan, apply, and destroy. Terraform init initializes the working directory which consists of all the configuration files Terraform plan is used to create an execution plan to reach a desired state of the infrastructure. Changes in the configuration files are done in order to achieve the desired state.