Terraform Associate Exam Flashcards
What is the typical name of the configuration file in Terraform?
main.tf
What is the command to plan out your Terraform changes?
terraform plan
What is the command to apply your Terraform changes?
terraform apply
What is the command to initialize your Terraform directory?
terraform init
What is the command to destroy your Terraform resources?
terraform destroy
What is the command to check the syntax and validity of your Terraform configuration files before applying changes with them?
terraform validate
What is the command used to download modules referenced in your Terraform config files?
terraform get
What is the command used to show the current state of your infrastructure?
terraform show
What is the command used to show the current version of Terraform?
terraform version
What file describes the values you want to be displayed after Terraform changes are applied?
outputs.tf
What are lifecycle rules used for in Terraform?
Lifecycle rules in Terraform are used to define when and how resources should be created, updated, or deleted during the execution of Terraform operations. Ex - you can set the ‘prevent_destroy’ attribute to prevent a resource from being destroyed.
List the 7 common types of Terraform variables:
String, Number, Boolean, List, Map, Object, Tuple
What is the ‘data’ codeblock used for in Terraform?
used to retrieve and access information from data sources, external systems, or remote resources that are not directly managed by Terraform
Ex - Getting the latest AMI ID from AWS for an Ubuntu system image
What is the default behavior if a variable is not defined when ‘terraform’ commands are run?
The user running the terraform command will be asked to input a value for the variable.
What are dynamic blocks used for in Terraform?
used for generating multiple blocks of configuration with the same structure but different values
What is a tuple in Terraform?
Tuples are lists that can support multiple data types.
Ex - variable “my_tuple” {
type = tuple
default = [“apple”, 42, true]
}
^ notice the different data types all in the same variable
What is a map in Terraform?
a data structure used to store a collection of key-value pairs where each key is unique within the map
Ex - variable “my_map” {
type = map(string)
default = {
key1 = “value1”
key2 = “value2”
}
T/F: A Terraform local value can reference other Terraform local values?
True
Which value provides the most verbose logging to assist with troubleshooting?
TRACE
List the order of variable assignment in TF (there are 4)
- -var flag through the CLI.
- terraform.tfvars file (this resides near the state file)
- Variables set as environment variables, such as TF_VAR_<variable_name>.</variable_name>
- Default variables declared within the config (variables.tf)
What is HashiCorp Sentinel?
a policy as code framework used for defining and enforcing compliance and security policies across infrastructure provisioning and deployment workflows.
What Terraform feature is most applicable for managing small differences between different environments, for example development and production?
Terraform Workspaces
Where are Terraform Workspace local state files stored?
A directory called terraform.tfstate.d
What command creates a new workspace for Terraform?
Terraform workspace new (workspace name)
What is an object in Terraform?
an object structural type is used to define a structured data type with named attributes, each having its own data type
Ex - variable “person” {
type = object({
name = string
age = number
enabled = bool
})
default = {
name = “John Doe”
age = 30
enabled = true
}
What are the types of dependencies used in Terraform? There are 2.
Implicit dependencies & Explicit Dependencies
Describe an implicit dependency.
Dependencies that do not call explicitly to a specific resource name like an explicit dependency. Rather, Terraform is smart enough to understand how resources interact with each other and should be created. For example, Terraform will know to create an EC2 instance with the name specified before attaching an elastic IP.