Replies: 15 comments
-
cc: @PatMyron could you add some comments? |
Beta Was this translation helpful? Give feedback.
-
Hi @wata727 , we've tried to implement such rule for |
Beta Was this translation helpful? Give feedback.
-
You can see their order from |
Beta Was this translation helpful? Give feedback.
-
Hi folks, we're developing two new plugins for your Terraform Module repos: For now we're still consider them as beta version and we're adding more rules to them. If we can have @wata727 's permission we'll be happy to contribute these rules to this plugin. |
Beta Was this translation helpful? Give feedback.
-
Interesting. If you open a pull request, I'd be happy to review it. Please open a pull request per rule. |
Beta Was this translation helpful? Give feedback.
-
Great! Will do. |
Beta Was this translation helpful? Give feedback.
-
Spotted #27 and #29, I'm concerned about the logic and positioning of these rules.
These are personal opinions. They are not official best practices (i.e. described/mentioned in the Terraform docs), which is the standard I'd recommend for this ruleset. They are also not generally accepted community conventions (which, FWIW, I still would not recommend including). It is far more common in my experience to organize locals and variables according to topic/function, grouping related entries together. I'm not disagreeing with these opinions, every module/project/organization is free to make these stylistic and organizational choices that Terraform leaves open. But for TFLint to have its own opinion on what is "proper" in an official/core ruleset, is decidedly wrong to me. I don't consider enforcement of personal/org stylistic preferences a priority that merits inclusion in an official ruleset, but if they were included I'd suggest a rename:
Again, I don't think it's TFLint's job to offer tools to enforce personal style preferences in this ruleset, but if it's going to offer to enforce this it should be without bias. |
Beta Was this translation helpful? Give feedback.
-
Thank you for pointing it out. I think this concern is worth considering. Personally, I'm not a fan of sorting definitions alphabetically. The order of definitions should be carefully designed to reflect the intent of the module designer. However, if alphabetical ordering is the best way to express the intent of the module designer, I think there is some value in enforcing this rule. The issue is whether to add this rule to this ruleset. I haven't been very opposed to including personal rules that might be shared between several people, except the recommended preset. However, if there is a possibility that this rule is misunderstood by users as TFLint's recommended rule, I think it should be carefully designed to prevent this from happening. I think there are several ways:
In my opinion, I believe the last option is the most flexible and may solve many problems. |
Beta Was this translation helpful? Give feedback.
-
I think we should make a new plugin This plugin focuses on enforcing organization-specific policies, such as definitions order, banned resources, etc. The In the future, tflint-ruleset-policy will provide a policy definition in Rego, allowing users to enforce their own policies with less code. Until then, we'll provide some generic rules to give you the flexibility to define policies through configuration. The ordered rules should also be able to be included in this plugin. @bendrucker @lonegunmanb What do you think? |
Beta Was this translation helpful? Give feedback.
-
@wata727 I have two questions. As different organization may has different poilcies, how do we determine which rule should be added into this new plugin? We can add them all and make them turn off by default, let the users choose the rules they want, then why don't we do the same thing in this plugin? If we decide to create this new plugin, then we need a triage procedure, any new rule should descibe their intension, let the community to decide whether we'll accept it, or this rule should be committed to this new plugin before someone start the coding work, or his contribution might be rejected. For the rules I've contributed to this repo, I'm ok if we decide to move them into this new plugin because I've already implemented them in our own plugins and we're using them now. As for the Rego policy, the community now have some mature tools based on Rego, such as ConfTest、Opa Terraform or even TfSec. I choose TFLint because it is capable to analyze my code in AST level, or even in token stream level, I can write policy that is hard to express in Rego. Why don't we leave these Rego policies to these tools? Could TFLint with Rego policy provide any extra values that these tools cannot provide? Just a personal thought, anyway the TFLint is the best choice I've made for my module projects. One more thing, I know that there's a code style guidance drafted by HashiCorp, but they havn't pulished it yet. We have implemented some of them in our own plugins. We'll be happy to contribute them to this plugin once the official guidance is published. |
Beta Was this translation helpful? Give feedback.
-
Community members can comment on which plugins to add rules to, but the final decision rests with the maintainers.
I used to have this same opinion. But lately I've been leaning towards the idea that tflint-ruleset-terraform should only contain minimal best practices and error-prune. The tflint-ruleset-terraform is used by almost all TFLint users, and I know from experience that some of them try to mechanically follow all the rules as much as possible. In that case, I believe it makes some sense to clearly separate policies that the maintainers cannot agree with into another plugin.
This is still the case today. We cannot accept all rules in tflint-ruleset-terraform.
Unlike Conftest and OPA, TFLint does not require to run
Interesting. I'm personally not that interested in enforcing code style, but if it's widely accepted it might be worth including in tflint-ruleset-terraform. Finally, thank you for participating in this discussion. I believe that this discussion was born from your contributions and that it has inspired the project to move forward. |
Beta Was this translation helpful? Give feedback.
-
I fully understand the challenges that TFLint meets now so I'm ok no matter how things go. It's me who owes you and the TFLint community a big thanks, without your magnificent work it'll be impossible for us to manage hundreds of Terraform modules in the future. I found one big difference between the general programming language's function and Terraform module, that is most of Terraform modules are scenario specified. For example, an organzation may have multiple modules which provision vpc and subnets, it's very common for this organzation to maintain hunndreds of modules, in that case it'll be very hard for teams to maintain them while preserving personal style. In that case maybe it'll be better to enforce a strict code style policy to keep consistence among these modules. Anyway I agree with you that we might leave this choice to our users. |
Beta Was this translation helpful? Give feedback.
-
Having a I certainly agree that style enforcement in increasing detail is valuable in an organization trying to maintain lots of modules. I just think the natural starting solution is for each organization to maintain their own ruleset plugin with their organization-specific styles. If a few organizations had these and published them publicly, either:
|
Beta Was this translation helpful? Give feedback.
-
Thank you for your comments. I think we need some more time to think about this issue. For now, revert the I'm still not sure if such a rule should be in the First of all, I'm thinking of trying the possibility of Policy as Code by Rego. |
Beta Was this translation helpful? Give feedback.
-
Thanks, I think it's the right move for now to not focus energy on style guidelines. The idea of generic rules based on something like Rego is interesting. But even that is focused on data and not syntax. Enforcing non-behavioral style rules will require HCL-level logic. |
Beta Was this translation helpful? Give feedback.
-
It would be nice if we can create a linting rule to enforce the order of arguments for vars, outputs, and modules
terraform_module_argument_order
This would work
This would fail
terraform_variable_argument_order
This would work
This would fail
terraform_output_argument_order
This would work
This would fail
Beta Was this translation helpful? Give feedback.
All reactions