Intermediate Terraform test (Intermediate)
30 questions · 35 minutes · Free
Modules, remote state, workspaces and data sources.
Take the Intermediate Terraform test
What it covers
- Modules
- Remote state and locking
- Workspaces
- Data sources
- count and for_each
Interview format
- Questions: 30 questions — 18 multiple choice, 12 multi-answer
- Time: 35 minutes, timed from the first question
- Difficulty: Intermediate
- Skill area: DevOps & cloud
- Price: Free
Earn a certificate
The Intermediate Terraform test is one of the 8 tests of the DevOps Engineer: Intermediate learning path. Pass it and the other 7 tests at 70% or more and readyforhires issues you a verifiable certificate in your name, with its own code and verify link to share or add to LinkedIn.
Sample questions
5 sample questions from the Intermediate Terraform test, with the answers. Samples are taken out of the live test, so you will not meet these when you sit it.
Which of the following is the correct way to reference a data source for tags in Terraform?
- data.aws_tag.example.tags
- data.aws_tagging.example.tags
- data.aws_tags.example.tags
- data.aws_resource_tag.example.tags
Answer: A. data.aws_tag.example.tags
The correct way to reference a data source for tags in Terraform is using `data.aws_tag.example.tags`, where `aws_tag` is the provider, `example` is the name of the data source, and `tags` is the attribute being accessed. Other options are either incorrect syntax or not valid data source attributes for tags.
Which of the following statements correctly describes the difference between 'count' and 'for_each' in Terraform?
- 'for_each' is not supported in Terraform versions prior to 0.13, while 'count' has been available since the early versions.
- Both 'count' and 'for_each' can be used with any data type, including maps and lists.
- 'count' is more flexible than 'for_each' when handling dynamic data structures.
- The 'for_each' argument allows iteration over complex data structures such as maps and lists, while 'count' only supports integer values.
Answer: D. The 'for_each' argument allows iteration over complex data structures such as maps and lists, while 'count' only supports integer values.
'for_each' supports iteration over maps and lists, making it more flexible for handling dynamic and complex data structures. 'count' only allows integer values and is used for simple repetition of resources.
Which of the following statements correctly describes the behavior of AzureRM data sources in Terraform?
- AzureRM data sources are used to update Azure resources.
- AzureRM data sources return read-only information and cannot be used to create or modify resources.
- AzureRM data sources can be used to create new Azure resources.
- AzureRM data sources are used to delete Azure resources.
Answer: B. AzureRM data sources return read-only information and cannot be used to create or modify resources.
AzureRM data sources are used to retrieve information about existing Azure resources, but they are not used to create or modify resources. This is a common misconception, as data sources are often confused with resource blocks. The other options incorrectly describe the behavior of AzureRM data sources.
Which of the following is the correct choice when iterating over a list of objects with unique identifiers in Terraform?
- Neither Count nor for_each can be used for iterating over a list of objects with unique identifiers.
- for_each is the correct choice when iterating over a list of objects with unique identifiers.
- Both Count and for_each are equally suitable for iterating over a list of objects with unique identifiers.
- Count is the correct choice when iterating over a list of objects with unique identifiers.
Answer: B. for_each is the correct choice when iterating over a list of objects with unique identifiers.
for_each is designed for iterating over collections of objects where each item has a unique identifier, making it more suitable for dynamic values. Count is used for simple numeric iteration and does not support complex data structures as effectively.
What is the behavior of Terraform Cloud regarding remote state locking during a run?
- Terraform Cloud does not support state locking and relies on manual intervention.
- Terraform Cloud automatically locks the state file when a run is in progress, preventing concurrent modifications.
- Terraform Cloud locks the state file only after the run completes successfully.
- State locking in Terraform Cloud is optional and only enabled by default in specific environments.
Answer: B. Terraform Cloud automatically locks the state file when a run is in progress, preventing concurrent modifications.
Terraform Cloud manages state locking automatically during runs to prevent conflicts. This ensures that only one Terraform process can modify the state at a time. Other options may describe incorrect behaviors, such as manual locking or lack of automatic locking.
Frequently asked questions
- How many questions are in the Intermediate Terraform test?
- 30 questions (18 multiple choice, 12 multi-answer), with 35 minutes to answer them.
- What does the Intermediate Terraform test cover?
- Modules, Remote state and locking, Workspaces, Data sources, count and for_each.
- Is the Intermediate Terraform test free?
- Yes. It is free to take with a readyforhires account.
- What level is the Intermediate Terraform test?
- Intermediate, in DevOps & cloud.