Podcast
Questions and Answers
What command is used to generate a plan file in Terraform?
What command is used to generate a plan file in Terraform?
- terraform create -out filename
- terraform plan -out filename (correct)
- terraform generate -out filename
- terraform execute -out filename
Where is the location of the AWS Config file that Terraform accesses for credentials on MacOS and Linux?
Where is the location of the AWS Config file that Terraform accesses for credentials on MacOS and Linux?
- ~/.aws/aws.conf
- ~/.aws/credentials (correct)
- ~/.aws/auth
- ~/.aws/config
What is the purpose of the terraform.tfstate file in Terraform?
What is the purpose of the terraform.tfstate file in Terraform?
- Maintains Terraform configurations
- Tracks the IDs of created resources (correct)
- Stores sensitive credentials
- Keeps track of provider binaries
Which attribute is used in Terraform to create explicit dependencies between resources?
Which attribute is used in Terraform to create explicit dependencies between resources?
What is the primary purpose of Terraform's terraform show command?
What is the primary purpose of Terraform's terraform show command?
In Terraform, what is the significance of using implicit dependencies via interpolation expressions?
In Terraform, what is the significance of using implicit dependencies via interpolation expressions?
What is the special handling of override files in Terraform?
What is the special handling of override files in Terraform?
When does Terraform automatically load files terraform.tfvars or *.auto.tfvars?
When does Terraform automatically load files terraform.tfvars or *.auto.tfvars?
What is the purpose of a.tfvars file in Terraform?
What is the purpose of a.tfvars file in Terraform?
Which command is used to preview the changes without altering the backend state?
Which command is used to preview the changes without altering the backend state?
What does Terraform search for in its own process environment for variable values?
What does Terraform search for in its own process environment for variable values?
What happens when override files are over-used in Terraform?
What happens when override files are over-used in Terraform?
Study Notes
Terraform Fundamentals
- Terraform configuration files are often called configuration files.
- Terraform loads all files ending in
.tf
in a directory.
Terraform Plan
terraform plan -out filename
generates a plan file, which is a zip file.- The plan file can be used when applying:
terraform apply "nat.tfplan"
.
Terraform Validate
terraform validate
validates the syntax.
Terraform Plan Options
terraform plan [-destroy]
generates an execution plan for Terraform.
Provider Configuration
- The
profile
attribute refers to the AWS Config File in~/.aws/credentials
on MacOS and Linux or%UserProfile%\.aws\credentials
on a Windows system. - It is recommended not to hardcode credentials into
.tf
configuration files. - The
provider "aws"
block defines the default AWS config profile and region.
Resource Blocks
- A resource block has two strings before opening the block: the resource type and the resource name.
- Each "Provider" is its own encapsulated binary distributed separately from Terraform itself.
- The
terraform init
command will automatically download and install any Provider binary for the providers in use within the configuration.
Terraform State
- Terraform writes data into the
terraform.tfstate
file, which keeps track of the IDs of created resources. - This state file is extremely important and must be saved and distributed to anyone who might run Terraform.
terraform show
can be used to inspect the current state.
Resource Dependencies
- Implicit dependencies via interpolation expressions are the primary way to inform Terraform about relationships.
- The
depends_on
argument is accepted by any resource and accepts a list of resources to create explicit dependencies.
Override Files
- Terraform has special handling of any configuration file whose name ends in
_override.tf
or_override.tf.json
. - Override files are processed in lexicographical order after the initial configuration file.
- Use override files only in special circumstances, as over-use hurts readability.
Variable Definitions
- Terraform searches the environment of its own process for environment variables named
TF_VAR_
followed by the name of a declared variable. - Terraform automatically loads
.tfvars
or*.auto.tfvars
files present in the current directory to populate variables. - A
.tfvars
file is used to assign values to variables, not to declare new variables.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Description
Test your knowledge on Terraform configuration files and overrides. Learn about how Terraform handles files with names ending in _override.tf or _override.tf.json, and how these files are processed in lexicographical order.