question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Omit Quotes In Terraform Resource Type And Name

See original GitHub issue

Feature Request

Terraform 0.12+ allows to omit redundant quotes around resource type and name. Please could you make it configurable in “Editor –> Code Style –> Terraform Config”?

Terraform Configuration Example

resource aws_sns_topic opsgenie_service_health {
  name = "opsgenie-service-health"
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:14
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Tenshocommented, Jan 13, 2021

@VladRassokhin Thank you for the patience 🙇

1reaction
Tenshocommented, Jan 13, 2021

This is not more relevant. Here is a comment from HashiCorp representative:

For the real reasoning, I think it has to do with whether or not the token represents a configuration language keyword or expression, which in this case it doesn’t since it is intended as a label (and can potentially have characters outside that of an expression). I believe the allowance of non-quotes there was incidental more than intentional and the quotes being idiomatic is there for the consistency of those labels which might require the quotes. In the future, the SDK may support block syntax like this:

resource "example_thing" "example" {
  some_block "label1" {
    # nested attributes
  }
  some_block "label2" {
    # nested attributes
  }
}

Which will likely have the quoting requirement for “label1” and “label2” for similar reasons.

and further MR making formatter not happy with unquoted labels.

References

Read more comments on GitHub >

github_iconTop Results From Across the Web

Quoting types and identifiers - Terraform - HashiCorp Discuss
Working on a configuration recently, I created a resource but forgot to quote the type and name. Eg instead of: resource "null_resource" " ......
Read more >
How to remove Terraform double quotes? - Stack Overflow
I solved by adding --raw parameter to terraform output. WebAppNameDev=$(terraform output --raw appservice_name_dev).
Read more >
Naming conventions - Terraform Best Practices
The conventions in this book refer to Terraform names themselves. ... Do not repeat resource type in resource name (not partially, nor completely):....
Read more >
aws_ecs_task_definition | Resources | hashicorp/aws
If directly setting the JSON, they should be escaped as \" in the JSON, e.g., "value": "I \"love\" escaped quotes" . If using...
Read more >
Best practices for using Terraform | Google Cloud
Name all configuration objects using underscores to delimit multiple words. This practice ensures consistency with the naming convention for resource types, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found