Terraform Configuration Files and Overrides Quiz
12 Questions
1 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

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?

  • ~/.aws/aws.conf
  • ~/.aws/credentials (correct)
  • ~/.aws/auth
  • ~/.aws/config
  • 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?

    <p>depends_on</p> Signup and view all the answers

    What is the primary purpose of Terraform's terraform show command?

    <p>Display the current state</p> Signup and view all the answers

    In Terraform, what is the significance of using implicit dependencies via interpolation expressions?

    <p>Inform Terraform about resource relationships</p> Signup and view all the answers

    What is the special handling of override files in Terraform?

    <p>Terraform processes override files in lexicographical order</p> Signup and view all the answers

    When does Terraform automatically load files terraform.tfvars or *.auto.tfvars?

    <p>When present in the current directory</p> Signup and view all the answers

    What is the purpose of a.tfvars file in Terraform?

    <p>Assign values to already declared variables</p> Signup and view all the answers

    Which command is used to preview the changes without altering the backend state?

    <p>terraform plan</p> Signup and view all the answers

    What does Terraform search for in its own process environment for variable values?

    <p>Environment variables with TF_VAR_ prefix</p> Signup and view all the answers

    What happens when override files are over-used in Terraform?

    <p>Hurts readability</p> Signup and view all the answers

    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.

    Quiz Team

    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.

    More Like This

    Use Quizgecko on...
    Browser
    Browser