Skip to content
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

Adding rule for terraform_required_version #725

Merged

Conversation

mveitas
Copy link
Contributor

@mveitas mveitas commented Apr 23, 2020

This rule will enforce that a required_version constraint be applied to the terraform block

@mveitas mveitas changed the title Adding rule for terraform_version_constraint Adding rule for terraform_required_version Apr 24, 2020
@wata727
Copy link
Member

wata727 commented Apr 25, 2020

I'm not sure it would be useful to be able to enforce version constraints by this rule.
What kind of situations do you expect to be useful? In most cases, I think it is good enough to edit required_version directly. Thank you for your contribution.

@mveitas
Copy link
Contributor Author

mveitas commented Apr 25, 2020

Originally the intent was to just enforce that the required_version existed, but as mentioned in #711, someone had a use case to enforce which version was specified.

@wata727
Copy link
Member

wata727 commented Apr 25, 2020

Oops, I may have misunderstood.
I have thought this issue mentioned a rule that enforces the Terraform version constraints that TFLint works.

@DWSR Does this rule meet your needs? Also, please tell us under what situations you find this rule useful. Thank you.

@mveitas
Copy link
Contributor Author

mveitas commented Apr 25, 2020

@wata727 Do you find that this is a valid rule to add to enforce that the required_version exists? I could see if an organization had a number of repos that contain modules, they might share a common configuration which makes it easier to enforce this sort of constraint on a specific matching version

Our use case is that we have defined a number of standards when building our TF modules, and ensuring that a version is defined is something we want automate rather than relying on humans to enforce this.

@wata727
Copy link
Member

wata727 commented Apr 25, 2020

Yes, a rule that simply enforces the presence of required_version makes a lot of sense.
I'm wondering if it's worth enforcing the contents of the constraint. Is there a case where we want to impose the same constraints on all modules ...?

@mveitas
Copy link
Contributor Author

mveitas commented Apr 25, 2020

Let me change the rule to just do enforcement of the attribute as a starting point and keep this simple. We can continue the discussion of validating the contents on the attribute in #711

@wata727 wata727 merged commit b3da055 into terraform-linters:master Apr 25, 2020
@wata727
Copy link
Member

wata727 commented Apr 25, 2020

👍

@mveitas mveitas deleted the terraform_version_constraint branch April 25, 2020 17:36
@mveitas
Copy link
Contributor Author

mveitas commented Apr 25, 2020

@wata727 Do you think a release could be cut with the last two rules so they could start to be used? Not sure what the cadence is for doing a release.

@wata727
Copy link
Member

wata727 commented Apr 25, 2020

I just released v0.15.5. Please try it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants