-
Notifications
You must be signed in to change notification settings - Fork 9.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
terraform: support version requirement in configuration #10080
Conversation
(Test failures unrelated and fixed by #10068, but I'm kicking the builds to get them green from races) |
@mitchellh Could this config syntax be extended to support storing 'remote state' config in TF files? As that would massively simplify the workflow when working with multiple TF projects - Different env's for example :) |
@fatmcgav Its possible, yes, but out of scope of course for this PR. |
@mitchellh Of course :) Was more of a 'would it be a useful addition' question, and sounds like the answer is "Yes" 👍 |
@mitchellh Do you think interpolation would be possible in this very specific case? I was thinking about having a global var that I get and use in many different places. It would allow me to update in one place and change everywhere else, for instance when upgrading major versions. Do you think this is an acceptable use-case? |
This awk monstrosity (that I introduced in 50bb83f) was not working with gawk 3.1.8 or mawk 1.3.3 (as available on Ubuntu Precise). It turns out that the regex interval expressions (`{1,4}` etc) only work with gawk 3 if you specify the --posix flag. They're enabled by default with gawk 4+. Instead of attempting to resolve this in a portable way, we can use the new feature in Terraform[1] to specify constraints on the version required. This was introduced in Terraform 0.8.0. Versions earlier than this will error with "* Unknown root level key: terraform" [1]hashicorp/terraform#10080
This awk monstrosity (that I introduced in 50bb83f) was not working with gawk 3.1.8 or mawk 1.3.3 (as available on Ubuntu Precise). It turns out that the regex interval expressions (`{1,4}` etc) only work with gawk 3 if you specify the --posix flag. They're enabled by default with gawk 4+. Instead of attempting to resolve this in a portable way, we can use the new feature in Terraform[1] to specify constraints on the version required. This was introduced in Terraform 0.8.0. Versions earlier than this will error with "* Unknown root level key: terraform" [1]hashicorp/terraform#10080
This awk monstrosity (that I introduced in 50bb83f) was not working with gawk 3.1.8 or mawk 1.3.3 (as available on Ubuntu Precise). It turns out that the regex interval expressions (`{1,4}` etc) only work with gawk 3 if you specify the --posix flag. They're enabled by default with gawk 4+. Instead of attempting to resolve this in a portable way, we can use the new feature in Terraform[1] to specify constraints on the version required. This was introduced in Terraform 0.8.0. Versions earlier than this will error with "* Unknown root level key: terraform" I considered adding the version constraint to globals.tf, but that's not used by all our configs, so I thought it better to introduce a new file that can be symlinked into every config dir. [1]hashicorp/terraform#10080
This awk monstrosity (that I introduced in 50bb83f) was not working with gawk 3.1.8 or mawk 1.3.3 (as available on Ubuntu Precise). It turns out that the regex interval expressions (`{1,4}` etc) only work with gawk 3 if you specify the --posix flag. They're enabled by default with gawk 4+. Instead of attempting to resolve this in a portable way, we can use the new feature in Terraform[1] to specify constraints on the version required. This was introduced in Terraform 0.8.0. Versions earlier than this will error with "* Unknown root level key: terraform" I considered adding the version constraint to globals.tf, but that's not used by all our configs, so I thought it better to introduce a new file that can be symlinked into every config dir. [1]hashicorp/terraform#10080
This awk monstrosity (that I introduced in 50bb83f) was not working with gawk 3.1.8 or mawk 1.3.3 (as available on Ubuntu Precise). It turns out that the regex interval expressions (`{1,4}` etc) only work with gawk 3 if you specify the --posix flag. They're enabled by default with gawk 4+. Instead of attempting to resolve this in a portable way, we can use the new feature in Terraform[1] to specify constraints on the version required. This was introduced in Terraform 0.8.0. Versions earlier than this will error with "* Unknown root level key: terraform" I considered adding the version constraint to globals.tf, but that's not used by all our configs, so I thought it better to introduce a new file that can be symlinked into every config dir. [1]hashicorp/terraform#10080
This awk monstrosity (that I introduced in 50bb83f) was not working with gawk 3.1.8 or mawk 1.3.3 (as available on Ubuntu Precise). It turns out that the regex interval expressions (`{1,4}` etc) only work with gawk 3 if you specify the --posix flag. They're enabled by default with gawk 4+. Instead of attempting to resolve this in a portable way, we can use the new feature in Terraform[1] to specify constraints on the version required. This was introduced in Terraform 0.8.0. Versions earlier than this will error with "* Unknown root level key: terraform" I considered adding the version constraint to globals.tf, but that's not used by all our configs, so I thought it better to introduce a new file that can be symlinked into every config dir. [1]hashicorp/terraform#10080
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Fixes #1400
This adds a new configuration to constrain the Terraform version that can perform operations on a given configuration.
Configuration
This introduces a new configuration block
terraform
which will be used now and in the future for meta-configuration (configuration that configures Terraform itself). For now, we introduce only a single configurationrequired_version
:The
required_version
value can be a comma-separated list of version constraints. This flexibility allows the user to be as strict as they'd like for version requirements. The constraints are all of those accepted by https://github.com/hashicorp/go-version but we'll document this in the website.Execution
The required version is validated immediately upon loading Terraform in order to prevent any potential side effects (state change for example) as well.
If a module has a version requirement, then that will also be validated. The entire module tree must have satisfied Terraform version constraints.
There is no way to "force" execution even if a required version is not met. There is a flag internally that allows this, but we don't currently expose it to the end user. I'm not sure there is a reason for doing this yet...
Here is what the error looks like: