Hashicorp Certified Terraform Associate 003 · Free Practice Question Medium
Question 28
Why might a user opt to include the following snippet in their configuration file?
- terraform {
- required_version = ">= 1.10.2"
- }
-
A
The user wants to ensure that the application being deployed is a minimum version of 1.9.2
-
B
versions before Terraform 1.9.2 were not approved by HashiCorp to be used in production
-
C
this ensures that all Terraform providers are above a certain version to match the application being deployed
-
D
The user wants to specify the minimum version of Terraform that is required to run the configuration
Reveal correct answer
Correct answer: D
Explanation
The required_version parameter in a terraform block is used to specify the minimum version of Terraform that is required to run the configuration. This parameter is optional, but it can be useful for ensuring that a Terraform configuration is only run with a version of Terraform that is known to be compatible.
For example, if your Terraform configuration uses features that were introduced in Terraform 1.9.2, you could include the following terraform block in your configuration to ensure that Terraform 1.9.2 or later is used:
- terraform {
- required_version = ">= 1.9.2"
- }
When you run Terraform, it will check the version of Terraform that is being used against the required_version parameter and it will raise an error if the version is lower than the required version.
This can be especially useful in larger organizations or projects where multiple people are working on the same Terraform code, as it helps to ensure that everyone is using the same version of Terraform and reduces the risk of encountering unexpected behavior or bugs due to differences in Terraform versions.
https://developer.hashicorp.com/terraform/language/settings#specifying-a-required-terraform-version
A. This choice is incorrect because the snippet is actually specifying the minimum version of Terraform required, not the version of the application being deployed.
B. This choice is incorrect because the snippet is focused on specifying the minimum required version of Terraform, not on the approval status of older versions by HashiCorp for production use.
C. This choice is incorrect as the snippet specifically targets the Terraform version required to run the configuration, not the versions of Terraform providers.
D. The snippet specifies the minimum version of Terraform required to run the configuration, ensuring compatibility and preventing potential issues that may arise from using older versions.
Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
