-
Notifications
You must be signed in to change notification settings - Fork 7
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
Sort variables based on the order in the code files #35
Comments
@sfenman I appreciate your idea and recognize the effort it would take to bring it to fruition. |
I have come across a similar challenge, so to address this, I implemented a consistent naming convention for variables that inherently groups them by provider, resource type, and logical grouping, mirroring their appearance in the Terraform code. Proposed Naming ConventionThe naming convention I used, and found highly effective, is:
This structure creates a natural grouping and sorting of variables, making navigation intuitive without needing changes to any tools. Example: Here’s how this convention could look for AWS IAM and S3 resources: variable "aws_iam_role_name" {
description = "The name of the IAM role"
type = string
}
variable "aws_iam_policy_arn" {
description = "The ARN of the IAM policy"
type = string
}
variable "aws_storage_s3_bucket_name" {
description = "The name of the S3 bucket"
type = string
}
variable "aws_storage_s3_bucket_acl" {
description = "The ACL to apply to the S3 bucket"
type = string
default = "private"
} Here’s why this works well:
Why Naming Conventions HelpThis naming convention eliminates the need for additional tools or features while achieving the same result:
Hope that helps! |
Hello,
Thanks for this tool, it really helps. What I would like to see as a feature is to be able to sort variables based on the order they are found in the code files eg. in the
main.tf
. There are sometimes where I want to "group" variables based on the resource type.For example let's assume that I have an AWS S3 module. I might have a logical block inside
main.tf
that defines all IAM resources before the actual AWS S3 resource. Sorting variables in this order enhances navigation in thevariables.tf
file especially when you have multiple types of Terraform resources.I understand this is a huge and time consuming implementation but if you think there is a fit in this project, I could help with that.
The text was updated successfully, but these errors were encountered: