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

Terraform fmt - is there any scope for tailoring it? #22183

Closed
gtmtech opened this issue Jul 23, 2019 · 3 comments
Closed

Terraform fmt - is there any scope for tailoring it? #22183

gtmtech opened this issue Jul 23, 2019 · 3 comments

Comments

@gtmtech
Copy link

gtmtech commented Jul 23, 2019

Terraform fmt does lots of things I consider making code harder to read

example: variables.tf from:

variable "access_var1"    { type = "string" }
variable "access_var2"    { type = "string" }
variable "access_var3"    { type = "string" }
variable "common_config"  { type = "map" }
variable "input_var1"     { type = "string" }

to

variable "access_var1" {
    type = "string"
}

variable "access_var2" {
    type = "string"
}

variable "access_var3" {
    type = "string"
}

variable "common_config" {
    type = "map"
}

variable "input_var1" {
    type = "string"
}

etc. - first one - easy to read, easy to see types, easy to diff, all probably fits on a single page
last one , wordy verbose, too many lines, difficult to diff and frequently goes off the page.

Is it possible to switch on different features of terraform fmt to tailor what it does? Some of the decisions it makes are questionable.

Thanks!

@pselle
Copy link
Contributor

pselle commented Jul 23, 2019

Hi @gtmtech!

fmt does not currently support granular configuration, or defining an alternative style, and the following is a reason why:

Other Terraform commands that generate Terraform configuration will produce configuration files that conform to the style imposed by terraform fmt, so using this style in your own files will ensure consistency.

The response above is meant to answer your question, but are you requesting this as a feature? That is, the ability to define a preference for how Terraform formats files?

@pselle
Copy link
Contributor

pselle commented Jul 23, 2019

On further research and reflection, I'll close this question, and the larger "can I customize how fmt works?" is responded to in this comment: #20910 (comment) and can be the place for any further discussion (or closure, if a firm decision is made).

@pselle pselle closed this as completed Jul 23, 2019
@ghost
Copy link

ghost commented Aug 23, 2019

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.

@ghost ghost locked and limited conversation to collaborators Aug 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants