Closed Gowiem closed 4 years ago
Thanks for asking and opening this issue here.
You are right that they are optional in Terraform, and quotes were always optional in any version of Terraform, actually.
I think that the main reason why quotes are still used are:
" "
). At least for me.-
(hyphen, minus) in quotes to prevent math expression evaluation in names. Not so big issue anymore, but still happens sometimes to some people.@antonbabenko Ah thanks for the quick response. Thanks for pointing out that it was not tied to a particular version of Terraform -- I had guessed it was, but good to know it just is a community norm.
Those are legitimate arguments against though I feel like they're surmountable problems. What is you personal opinion on the longevity of this practice? Do you think quoting these labels will continue to be the path forward or do you think it will one day fade away?
I personally like to keep them quoted mostly for the reasons of consistency (number 1 in the list above), most of my private code looks 99.9% the same as my code in public repos (styling, naming, patterns, docs...).
I usually see people who are very new to programming and especially tools that advocate "as-code"-principle and big public cloud providers, tend to save 2 bytes by not enquoting these. This is just my observation from some of my training.
@antonbabenko gotcha, that's reasonable and I definitely get it. I personally was liking the consistency of the block type not being quoted and the labels not being quoted as well, but I understand that breaks consistency elsewhere.
I'll close out this issue. Seems I'm trying to push an idea that nobody really cares about. You are correct that trying to save 2 bytes to be more terse in syntax is not truly a huge win. Anyway, thanks for the discussion!
Is your feature request related to a problem? Please describe.
I'd like the book to discuss putting quotes around block labels. It's not required but they're typically quoted in documentation and the majority of modules. I believe this was cary over from a previous version of HCL that required them, but no longer does.
Terraform fmt and terraform validate do not raise no quotes as an error.
It doesn't seem like these quotes should be necessary and I'd love to see a discussion here or else where on this topic. IMO, the eventual goal should be that labels are no longer being quoted as the norm within the community.
Describe the solution you'd like
I'm referring to no longer quoting resources, modules, or provider "labels" like so:
GOOD
BAD