← Back to Quiz Home
Welcome! 🚀
Test your knowledge of state, variables, and modules.
Instructions:
- Select the best answer for each question.
- Your score will be shown at the end.
Which file is automatically loaded by Terraform to populate variable values?
Files named terraform.tfvars or *.auto.tfvars are automatically loaded to set variable values.
What is the purpose of the output block?
Outputs display information on the CLI and allow data to be passed between modules.
If a variable has no default value and is not set via CLI or tfvars, what happens?
Terraform prompts for input interactive when required variables are not set.
Which keyword is used to access values from a Data Source?
You access data sources using data.TYPE.NAME.ATTRIBUTE.
Why is local state not recommended for team environments?
Local state creates a single point of failure and risk of conflicts (race conditions) when multiple people apply changes.
Which command is used to format your Terraform configuration files to a canonical format?
terraform fmt recursively updates files in the current directory for standard formatting.
The working directory where you run Terraform is always the root module.
How do you reference an output called "instance_ip" from a module named "web_server"?
Outputs from a child module are accessed via module.MODULE_NAME.OUTPUT_NAME.
Which backend supports state locking via DynamoDB?
The AWS S3 backend supports state locking and consistency checking via DynamoDB.
What will happen if you delete the terraform.tfstate file locally?
If state is lost, Terraform thinks the resources don't exist and will attempt to create duplicates (which often fails due to name conflicts).
What is the locals block used for?
Local values allow you to assign a name to an expression, so you can use it multiple times within a module.
How can you specify that a variable must pass a specific condition (Validation)?
Terraform variables support a validation block with a condition and error_message.
Which command removes an item from the Terraform state without destroying the real resource?
terraform state rm tells Terraform to stop managing the resource, leaving the real infrastructure functioning.
What does the prevent_destroy lifecycle argument do?
It adds a safety check to cause an error if a plan would destroy the resource.
Which function allows you to select an item from a list safely?
element retrieves a single element from a list, but unlike square brackets, it wraps around (modulo) if index is too large.
What is the purpose of the moved block in Terraform 1.1+?
moved blocks document where a resource was moved from, allowing Terraform to automatically handle the state migration.
What does the Splat expression [*] do?
It allows you to get a list of values from a list of objects, e.g., aws_instance.web[*].private_ip.
How do you assign the dependency of a module explicitly?
Modules support the depends_on meta-argument.
Which command lists all resources in the state file?
terraform state list prints a list of all resources tracked in the state.
What happens if you run terraform apply on a configuration that is already applied and unchanged?
Terraform is idempotent; if the state matches the config, no actions are taken.
Quiz Progress
0 / 0 questions answered
(0%)
0 correct
Quiz Complete!
0%
📚 Study Guides
📬 Weekly DevOps, Cloud & Gen AI quizzes & guides