← Back to Quiz Home
Welcome! 🚀
Test your expertise with advanced Terraform concepts.
Instructions:
- Select the best answer for each question.
- Your score will be shown at the end.
Which meta-argument creates multiple resource instances based on a map or set of strings?
for_each iterates over a map or set, using the key as the instance identifier, which is generally safer than count (index-based).
What command helps you to manipulate the state file, such as renaming a resource without destroying it?
terraform state mv moves an item in the state, effectively renaming it without infrastructure changes.
What is "Drift" in the context of Terraform?
Drift occurs when infrastructure is modified outside of Terraform (e.g., manually via console).
Which block is used to configure settings for Terraform itself, such as the required version or backend?
The terraform { ... } block configures backend, required providers, and version constraints.
What is the purpose of terraform taint?
Tainting a resource forces Terraform to destroy and recreate it during the next apply.
Why should you prefer user_data over provisioners (local-exec/remote-exec)?
HashiCorp considers provisioners a "last resort" because they are difficult to model, don't track state, and make error recovery hard.
Which built-in function is used to create a subnet CIDR from a VPC CIDR?
cidrsubnet(prefix, newbits, netnum) calculates a subnet address within a given IP network address prefix.
What is a Terraform Workspace used for?
Workspaces allow independent state files for the same config, useful for identical environments.
How can you import an existing AWS EC2 instance into Terraform state?
terraform import maps an existing resource to the Terraform state.
Which feature allows you to generate nested blocks (like ingress rules) dynamically?
A dynamic block generates nested configuration blocks based on a collection.
What is the purpose of the .terraform.lock.hcl file?
This dependency lock file records the exact version and checksums of the providers used, ensuring every init uses exactly the same code.
How do you interactively evaluate Terraform expressions?
terraform console opens an interactive shell to test interpolations and built-in functions.
What environment variable enables detailed logging?
Setting TF_LOG to TRACE, DEBUG, INFO, WARN or ERROR enables logging.
How do you manage resources in multiple regions within the same configuration?
You define multiple provider blocks with alias (e.g., provider "aws" { alias = "west" ... }) and reference them in resources.
Which function allows reading a file and replacing template variables?
templatefile(path, vars) reads a file and renders it as a template using the supplied variables.
What is create_before_destroy?
Useful for zero-downtime upgrades, ensuring the new resource is ready before the old one is removed.
Which command force-unlocks a stuck state lock?
If Terraform crashes, the state lock might remain. force-unlock removes it (use with caution!).
What is a generic way to mark a variable as sensitive?
Setting sensitive = true prevents Terraform from showing its value in the plan or apply output.
How do you decode a YAML string into a map/object?
yamldecode parses a string containing YAML and returns the Terraform structure.
What is null_resource used for?
It's a resource that does nothing but has a lifecycle, often used to bridge gaps or trigger provisioners based on triggers.
Quiz Progress
0 / 0 questions answered
(0%)
0 correct
Quiz Complete!
0%
📚 Study Guides
📬 Weekly DevOps, Cloud & Gen AI quizzes & guides