TA-002-P · Question #181
You have created a terraform script that uses a lot of new constructs that have been introduced in terraform v0.12. However, many developers who are cloning the script from your git repo, are using…
The correct answer is A. Force developer to use v0.12 by using terraform setting `required_version' and set it. The required_version setting in the terraform block enforces a minimum Terraform version at runtime, preventing developers from running v0.12-specific configurations with an incompatible older version.
Question
You have created a terraform script that uses a lot of new constructs that have been introduced in terraform v0.12. However, many developers who are cloning the script from your git repo, are using v0.11, and getting errors. What can be done from your end to solve this problem?
Options
- AForce developer to use v0.12 by using terraform setting `required_version' and set it
- BRefactor the code to support both v0.11, and v0.12. It might be a difficult process, but
- CAdd a condition in front of each such specific construct, to check whether the running
- DAdd comments in your code to tell developers to use v0.12 . If they use v0.11 , that
How the community answered
(25 responses)- A80% (20)
- B4% (1)
- C4% (1)
- D12% (3)
Why each option
The required_version setting in the terraform block enforces a minimum Terraform version at runtime, preventing developers from running v0.12-specific configurations with an incompatible older version.
By specifying required_version = ">= 0.12" in the terraform configuration block, Terraform immediately exits with a clear, actionable error message if any developer attempts to run the configuration with v0.11 or earlier, enforcing compatibility at the toolchain level.
Refactoring to support both v0.11 and v0.12 simultaneously is a significant effort and is unnecessary when required_version provides a clean, low-effort enforcement mechanism.
Terraform has no built-in mechanism to conditionally enable or disable language constructs based on the running version; version branching logic does not exist in HCL.
Comments are advisory only and cannot prevent developers from running the script with an incompatible version, leaving them to encounter confusing syntax errors.
Concept tested: Terraform required_version setting for enforcing CLI compatibility
Source: https://developer.hashicorp.com/terraform/language/settings
Topics
Community Discussion
No community discussion yet for this question.