Terraform-Associate Flashcards
How would you describe a Terraform workflow?
Write > Plan > Apply
What does terraform init command do?
It initializes and sets up the working directory containing your Terraform code.
variable "replicas" { type = number default = 5 } What will be passed into the code for the variable replicas when given the following command?
terraform apply -var replicas=1
1
While the default number of replicas in the Terraform source code is 5, the code being passed is explicitly providing a replicas variable value of 1 at execution.
How can Terraform input variables be defined?
They can be predetermined in a file.
They can be pulled down from Terraform Cloud and referenced in your code.
They can be included in the command-line options.
Which of the following best describes Terraform providers?
A plugin that enables Terraform to interface with the API layer of various cloud platforms and environments.
What is the default name of the file where Terraform state is stored when working locally?
terraform.tfstate
What format is the Terraform state file stored in?
JSON
Which are the uses of the Terraform output variables?
A root “module” can use outputs to print certain values in the CLI output after running terraform apply.
A child “module” can use outputs to expose a subset of its resource attributes to a parent module.
When using a remote state, “root module” outputs can be accessed by other configurations via a “terraform_remote_state” data source.
How can Terraform Providers be sourced in Terraform?
You can reference providers from an internal registry in your Terraform code.
You can reference providers locally in your Terraform configuration.
By default, Terraform looks for providers in the Terraform provider registry.
True or False? Terraform provisioners help bootstrap custom commands onto the resources being deployed via Terraform.
Terraform provisioners can help execute custom scripts and commands on resources. The best practice is to avoid using them if a built-in mechanism is provided by the resource API itself.
Where in Terraform code can you configure where the state file is stored?
In the terraform block, using the backend attribute.
Which command would you use to see all the resources that have been created and are being tracked by the Terraform state file?
terraform state list
What benefits does storing Terraform state remotely offer?
It provides granular:
- access
- integrity
- security
- availability
- collaboration.
What does the terraform state mechanism do?
It maps real-world resources to Terraform configuration/code.
How does Terraform handle dependencies in your infrastructure when deploying or destroying resources?
It handles them via the Terraform state file.
In what file is your Terraform state stored locally?
terraform.tfstate
How can Terraform module code return outputs to be used by the main Terraform code invoking it?
By using output block resources in the Terraform module code.
Where can Terraform find and download modules referenced in code?
- Local system
- Terraform Registry
Given the following snippet of Terraform code:
module "my-test-module" { source = "./testm" version = "0.0.5" region = var.datacenter } Which of the attributes in the above snippet is an input being provided to the module?
region
What is one of the main purposes of Terraform modules?
To make code reusable elsewhere and avoid reinventing the wheel.=
What is the command used in Terraform to format the code?
terraform fmt
What is the flag that can be used to bypass approval entry?
–auto-approve
Which of the following data types represent a primitive type value in Terraform?
Number, String, Boolean
The dynamic blocks feature in Terraform cannot be used with which of the following types of resources?
lifecycle blocks