Terraform Hashicorp Terraform Associate 003 Practice Test - Set 1
Test your knowledge with this Terraform Hashicorp Terraform Associate 003 mock exam. Get real-world IT questions and prepare for certification success.
Terraform Associate 003: HashiCorp Certified Terraform Associate - Exam Information
2. Which language is used for writing Terraform configuration files?
HCL
YAML
JSON
XML
✅ Correct Answer: HCL
3. What is the primary command to initialize a new Terraform working directory?
terraform init
terraform apply
terraform plan
terraform refresh
✅ Correct Answer: terraform init
4. Which Terraform command is used to preview changes before applying them?
terraform plan
terraform apply
terraform validate
terraform fmt
✅ Correct Answer: terraform plan
5. How does Terraform manage infrastructure state?
Using a state file
By communicating with cloud providers directly
By storing configurations in a database
By using Kubernetes
✅ Correct Answer: Using a state file
6. Which backend type does Terraform support for storing state?
S3
Kafka
Redis
MongoDB
✅ Correct Answer: S3
7. What is the purpose of the "terraform validate" command?
To check for syntax errors in the configuration
To apply the Terraform configuration
To initialize Terraform plugins
To remove unused resources
✅ Correct Answer: To check for syntax errors in the configuration
8. Which file should be ignored in version control when using Terraform?
terraform.tfstate
main.tf
variables.tf
outputs.tf
✅ Correct Answer: terraform.tfstate
9. What is the default provider for Terraform if none is specified?
There is no default provider
AWS
Google Cloud
Azure
✅ Correct Answer: There is no default provider
10. Which Terraform block is used to define reusable infrastructure components?
module
variable
resource
output
✅ Correct Answer: module
11. How does Terraform handle changes in infrastructure?
It plans and applies incremental changes
It destroys everything and recreates from scratch
It updates only new resources, ignoring changes
It requires manual intervention for all changes
✅ Correct Answer: It plans and applies incremental changes
12. Which Terraform command is used to remove infrastructure managed by Terraform?
terraform destroy
terraform apply --destroy
terraform remove
terraform rollback
✅ Correct Answer: terraform destroy
13. How can you pass variables to a Terraform configuration?
Using a .tfvars file
By embedding values in main.tf
By modifying the terraform binary
By writing values in terraform.tfstate
✅ Correct Answer: Using a .tfvars file
14. What is the main benefit of using remote state storage in Terraform?
Collaboration and consistency across teams
Faster execution of Terraform plans
Improved debugging
Reduced Terraform file size
✅ Correct Answer: Collaboration and consistency across teams
15. What is a provider in Terraform?
A plugin that interacts with APIs to manage resources
A configuration file
A security mechanism
A storage backend
✅ Correct Answer: A plugin that interacts with APIs to manage resources
16. What is the purpose of the Terraform "output" block?
To display values from Terraform configurations
To define external dependencies
To store intermediate data
To override variable values
✅ Correct Answer: To display values from Terraform configurations
17. Which command is used to install required providers and modules in Terraform?
terraform init
terraform get
terraform fetch
terraform install
✅ Correct Answer: terraform init
18. What happens if you run "terraform apply" without running "terraform plan" first?
Terraform will apply changes directly
Terraform will fail
Terraform will always ask for confirmation
Terraform will rollback previous changes
✅ Correct Answer: Terraform will apply changes directly
19. How does Terraform handle dependencies between resources?
By automatically determining dependencies
By requiring explicit dependency declarations
By always creating resources in parallel
By running a manual dependency check
✅ Correct Answer: By automatically determining dependencies
20. What does Terraform use to store its state file when working with remote backends?
A remote storage service like S3 or Azure Blob Storage
A local SQLite database
A temporary in-memory cache
A dedicated Terraform server
✅ Correct Answer: A remote storage service like S3 or Azure Blob Storage
21. What is the purpose of the "terraform fmt" command?
To format Terraform configuration files consistently
To initialize a new Terraform workspace
To validate Terraform syntax
To apply infrastructure changes
✅ Correct Answer: To format Terraform configuration files consistently
22. What does "terraform refresh" do?
Updates the state file with real infrastructure
Restarts Terraform services
Clears the Terraform cache
Downloads new provider versions
✅ Correct Answer: Updates the state file with real infrastructure
23. Which of these is NOT a valid Terraform workspace command?
terraform workspace create
terraform workspace delete
terraform workspace switch
terraform workspace list
✅ Correct Answer: terraform workspace switch
24. What is the purpose of the "depends_on" meta-argument?
To explicitly define resource dependencies
To mark resources for deletion
To specify provider requirements
To control parallel resource creation
✅ Correct Answer: To explicitly define resource dependencies
25. Which command shows currently installed Terraform providers?
terraform providers
terraform show providers
terraform list providers
terraform get providers
✅ Correct Answer: terraform providers
26. What is the purpose of the "count" meta-argument?
To create multiple resource instances
To limit the number of resources created
To count existing resources
To track resource versions
✅ Correct Answer: To create multiple resource instances
27. Which file extension is commonly used for Terraform variable files?
.tfvars
.tfvar
.tvar
.terraformvars
✅ Correct Answer: .tfvars
28. What does the "terraform state list" command do?
Lists resources in the state file
Shows available state backends
Lists previous state versions
Displays state file location
✅ Correct Answer: Lists resources in the state file
29. Which of these is a valid way to set a variable in Terraform?
All of these
Command line flag
Environment variable
terraform.tfvars file
✅ Correct Answer: All of these
30. What is the purpose of the "lifecycle" meta-argument?
To control resource creation/destruction behavior
To set resource expiration dates
To manage resource dependencies
To track resource age
✅ Correct Answer: To control resource creation/destruction behavior
31. Which command imports existing infrastructure into Terraform state?
terraform import
terraform state import
terraform get --import
terraform apply --import
✅ Correct Answer: terraform import
32. What is the purpose of the "backend" block in Terraform?
To configure state storage
To define provider settings
To specify resource dependencies
To configure remote operations
✅ Correct Answer: To configure state storage
33. Which of these is NOT a built-in Terraform function?
to_yaml
merge
lookup
element
✅ Correct Answer: to_yaml
34. What does the "terraform taint" command do?
Marks a resource for recreation
Removes a resource from state
Shows problematic resources
Validates resource configuration
✅ Correct Answer: Marks a resource for recreation
35. Which meta-argument is used to conditionally create resources?
count
for_each
depends_on
Both count and for_each
✅ Correct Answer: Both count and for_each
36. What is the purpose of the "locals" block?
To define local variables
To specify resource locations
To configure provider regions
To limit resource scope
✅ Correct Answer: To define local variables
37. Which command shows the execution plan from a saved plan file?
terraform show
terraform plan --show
terraform display
terraform output plan
✅ Correct Answer: terraform show
38. What is the purpose of the "required_version" setting?
To specify Terraform version constraints
To set the minimum resource version
To force provider updates
To declare module versions
✅ Correct Answer: To specify Terraform version constraints
39. Which of these is a valid state manipulation command?
terraform state mv
terraform modify state
terraform update state
terraform state edit
✅ Correct Answer: terraform state mv
40. What does the "ignore_changes" lifecycle argument do?
Prevents certain attributes from triggering updates
Skips resource validation
Disables state tracking
Ignores dependency changes
✅ Correct Answer: Prevents certain attributes from triggering updates
41. Which command upgrades modules and providers?
terraform init -upgrade
terraform upgrade
terraform get -update
terraform update
✅ Correct Answer: terraform init -upgrade
42. What is the purpose of the "terraform_remote_state" data source?
To access outputs from other state files
To manage remote backends
To sync state files
To validate remote configurations
✅ Correct Answer: To access outputs from other state files
43. Which meta-argument is used to create multiple similar resources?
for_each
multiple
replicate
with_items
✅ Correct Answer: for_each
44. What is the purpose of the "prevent_destroy" lifecycle argument?
To safeguard critical resources from deletion
To stop all destroy operations
To require manual confirmation for destroys
To log destruction attempts
✅ Correct Answer: To safeguard critical resources from deletion
45. Which command removes items from the state file?
terraform state rm
terraform remove
terraform delete
terraform state delete
✅ Correct Answer: terraform state rm
46. What is the purpose of the "sensitive" argument for variables?
To hide values in CLI output
To encrypt variable values
To restrict variable usage
To mark variables as required
✅ Correct Answer: To hide values in CLI output
47. Which command saves a plan to a file?
terraform plan -out=filename
terraform save-plan filename
terraform plan --save filename
terraform export plan filename
✅ Correct Answer: terraform plan -out=filename
48. What is the purpose of the "dynamic" block?
To generate multiple nested blocks dynamically
To create resources that change over time
To handle variable resource counts
To manage state transitions
✅ Correct Answer: To generate multiple nested blocks dynamically
49. Which command applies a saved plan file?
terraform apply planfile
terraform plan --apply planfile
terraform execute planfile
terraform run planfile
✅ Correct Answer: terraform apply planfile
50. What is the purpose of the "replace" option in terraform plan?
To force replacement of specific resources
To update resource dependencies
To swap module versions
To change state backends
✅ Correct Answer: To force replacement of specific resources
51. Which file is used to lock provider versions?
.terraform.lock.hcl
providers.lock
versions.tf
terraform.lock
✅ Correct Answer: .terraform.lock.hcl
52. What is the purpose of the "null_resource"?
To run provisioners without a real resource
To represent empty values
To skip resource creation
To test Terraform configurations
✅ Correct Answer: To run provisioners without a real resource
53. Which command shows resource attributes from state?
terraform state show
terraform show state
terraform inspect
terraform attributes
✅ Correct Answer: terraform state show
54. What is the purpose of the "templatefile" function?
To render files with template syntax
To generate configuration files
To manage file templates
To create module templates
✅ Correct Answer: To render files with template syntax
55. Which of these is a valid provisioner?
local-exec
shell-run
command-exec
remote-cmd
✅ Correct Answer: local-exec
56. What is the purpose of the "timeouts" block?
To configure operation time limits
To schedule resource creation
To delay resource provisioning
To track resource duration
✅ Correct Answer: To configure operation time limits
57. Which command shows the current workspace?
terraform workspace show
terraform show workspace
terraform current-workspace
terraform workspace current
✅ Correct Answer: terraform workspace show
58. What is the purpose of the "external" data source?
To integrate with external programs
To reference outside infrastructure
To import external configurations
To manage cross-account resources
✅ Correct Answer: To integrate with external programs
59. Which meta-argument controls resource creation order?
depends_on
create_order
sequence
before
✅ Correct Answer: depends_on
60. What is the purpose of the "terraform graph" command?
To visualize resource dependencies
To show provider relationships
To display module hierarchy
To map workspace connections
✅ Correct Answer: To visualize resource dependencies
The Terraform Hashicorp Terraform Associate 003 certification is a globally recognized credential for IT professionals.
This practice test helps you prepare by covering key topics like hardware, networking, troubleshooting, and security.
Want more practice? Check out our other mock exams: