Introduction
Loading...
Code Structure
General Conventions
-
Use
_(underscore) as a word separator instead of-(dash) or.(dot). Terraform uses-(dash) as a separator for nested resources and.(dot) as a separator for nested attributes. Apply this consistently in resource names, data source names, variable names, outputs, etc. -
Use Snakecase for resource names, data source names, variable names, outputs, etc. This is the most common naming convention in Terraform code.
-
A variable name cannot start with a number. It can contain numbers, but it must start with a letter.
-
Variable names are case-sensitive.
my_variableis different fromMy_Variable. -
Use descriptive names for resources, data sources, variables, outputs, etc. This makes the code easier to read and understand.
Resources
Resource Naming Conventions Learn about the naming conventions for resources.
Resource Naming Conventions Example Learn about the naming conventions for resources with examples.
Modules
Module Naming Conventions Learn about the naming conventions for modules.
Module Naming Conventions Example Learn about the naming conventions for modules with examples.
Data Sources
Data Source Naming Conventions Learn about the naming conventions for data sources.
Data Source Naming Conventions Example Learn about the naming conventions for data sources with examples.
Outputs
Output Naming Conventions Learn about the naming conventions for outputs.
Output Naming Conventions Example Learn about the naming conventions for outputs with examples.
Variables
Variable Naming Conventions Learn about the naming conventions for variables.
Variable Naming Conventions Example Learn about the naming conventions for variables with examples.
Locals
Local Naming Conventions Learn about the naming conventions for locals.
Local Naming Conventions Example Learn about the naming conventions for locals with examples.
Conditions
Condition Naming Conventions Learn about the naming conventions for conditions.
Condition Naming Conventions Example Learn about the naming conventions for conditions with examples.
Dynamic Blocks
Dynamic Block Naming Conventions Learn about the naming conventions for dynamic blocks.
Dynamic Block Naming Conventions Example Learn about the naming conventions for dynamic blocks with examples.