antonbabenko / terraform-best-practices

Terraform Best Practices free ebook translated into 🇬🇧🇦🇪🇧🇦🇧🇷🇫🇷🇬🇪🇩🇪🇬🇷🇮🇱🇮🇳🇮🇩🇮🇹🇯🇵🇰🇷🇵🇱🇷🇴🇨🇳🇪🇸🇹🇷🇺🇦🇵🇰
https://www.terraform-best-practices.com/
Other
2.07k stars 431 forks source link

Docs: What is the type in naming variables? #51

Closed mikalai-hryb closed 10 months ago

mikalai-hryb commented 10 months ago

When I was reading about the naming convention I faced this line

Good structure for the name of output looks like {name}_{type}_{attribute} , where:

  1. {name} is a resource or data source name without a provider prefix. {name} for aws_subnet is subnet, foraws_vpc it is vpc.
  2. {type} is a type of a resource sources
  3. {attribute} is an attribute returned by the output
  4. See examples.

It's not clear what type is and how it can look. I was not able to understand it from the examples https://www.terraform-best-practices.com/naming#code-examples-of-output

It seems the examples use {name}_{attribute} pattern

Can someone please explain to me what type is?

antonbabenko commented 10 months ago

name of the resource is this, so it should be omitted:

  1. If the output is returning a value with interpolation functions and multiple resources, {name} and {type} there should be as generic as possible (this as prefix should be omitted).

Not good: this_security_group_id Good: security_group_id