0
0
Terraformcloud~5 mins

Terraform init for initialization - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of the terraform init command?

terraform init sets up your working directory for Terraform. It downloads necessary provider plugins and prepares the backend for storing state.

Click to reveal answer
beginner
When should you run terraform init?

You run terraform init when you start a new Terraform project or after changing backend or provider configurations.

Click to reveal answer
intermediate
What happens if you run terraform init multiple times in the same directory?

Terraform will check and update plugins and backend settings if needed. It is safe to run multiple times to refresh setup.

Click to reveal answer
intermediate
What is a backend in Terraform and how does terraform init relate to it?

A backend stores Terraform state remotely or locally. terraform init configures the backend so Terraform knows where to save state.

Click to reveal answer
beginner
How does terraform init handle provider plugins?

It downloads the required provider plugins specified in your configuration to your local machine so Terraform can communicate with cloud services.

Click to reveal answer
What does terraform init NOT do?
ADownload provider plugins
BApply infrastructure changes
CInitialize backend configuration
DPrepare working directory
When should you run terraform init?
AOnly when destroying infrastructure
BEvery time you want to apply changes
CAfter writing your Terraform files for the first time
DNever, it runs automatically
What does terraform init configure related to state?
AIt configures the backend where state is stored
BIt encrypts the state file
CIt deletes old state files
DIt creates the state file manually
If you add a new provider to your Terraform config, what should you do next?
ARun <code>terraform destroy</code>
BRun <code>terraform apply</code> immediately
CDelete the old provider files manually
DRun <code>terraform init</code> to download the new provider
Can you run terraform init multiple times safely?
AYes, it refreshes plugins and backend
BNo, it will corrupt your state
COnly once per project
DOnly after destroying infrastructure
Explain what terraform init does and why it is important before running other Terraform commands.
Think about setting up your workspace before starting work.
You got /4 concepts.
    Describe when and how you would use terraform init in a new Terraform project.
    Consider the first step after creating your infrastructure code.
    You got /4 concepts.