Navigate Terraform workflow Flashcards
What is the Core Terraform workflow?
The core Terraform workflow has three steps:
- Write - Author infrastructure as code.
- Plan - Preview changes before applying.
- Apply - Provision reproducible infrastructure.
What is the workflow when you work as an Individual Practitioner?
https://www.terraform.io/guides/core-workflow.html#working-as-an-individual-practitioner
What is the workflow when you work as a team?
https://www.terraform.io/guides/core-workflow.html#working-as-a-team
What is the workflow when you work as a large organization?
https://www.terraform.io/guides/core-workflow.html#the-core-workflow-
enhanced-by-terraform-cloud
What is the command init?
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.
It is safe to run this command multiple times.
You recently joined a team and you cloned a terraform configuration files from
the version control system. What is the first command you should use?
terraform init
This command performs several different initialization steps in order
to prepare a working directory for use.
This command is always safe to run multiple times, to bring the
working directory up to date with changes in the configuration.Though subsequent runs may give errors, this command will never
delete your existing configuration or state.
If no arguments are given, the configuration in the current working
directory is initialized. It is recommended to run Terraform with the
current working directory set to the root directory of the
configuration, and omit the DIR argument.
https://www.terraform.io/docs/commands/init.html
What is the flag you should use to upgrade modules and plugins a part of their
respective installation steps?
upgrade
terraform init -upgrade
When you are doing initialization with terraform init, you want to skip backend
initialization. What should you do?
terraform init -backend=false
When you are doing initialization with terraform init, you want to skip child module installation. What should you do?
terraform init -get=false
When you are doing initialization where do all the plugins stored?
On most operationg systems
~/.terraform.d/plugins
on Windows
%APPDATA%\terraform.d\plugins
When you are doing initialization with terraform init, you want to skip plugin
installation. What should you do?
terraform init -get-plugins=false
Skips plugin installation. Terraform will use plugins installed in
the user plugins directory, and any plugins already installed for the
current working directory. If the installed plugins aren’t sufficient
for the configuration, init fails.
What does the command terraform validate does?
The terraform validate command validates the configuration files in a
directory, referring only to the configuration and not accessing any
remote services such as remote state, provider APIs, etc.
Validate runs checks that verify whether a configuration is
syntactically valid and internally consistent, regardless of any
provided variables or existing state.
It is thus primarily useful for general verification of reusable
modules, including correctness of attribute names and value types.
https://www.terraform.io/docs/commands/validate.html
What does the command plan do?
The terraform plan command is used to create an execution plan.
Terraform performs a refresh, unless explicitly disabled, and then
determines what actions are necessary to achieve the desired state
specified in the configuration files.
What does the command apply do?
The terraform apply command is used to apply the changes required to
reach the desired state of the configuration, or the pre-determined
set of actions generated by a terraform plan execution plan.
You are applying the infrastructure with the command apply and you don’t want
to do interactive approval. Which flag should you use?
terraform apply -auto-approve
https://www.terraform.io/docs/commands/apply.html