Skip to content

Introduction

Loading...

Code Structure


General Conventions



  1. 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.

  2. Use Snakecase for resource names, data source names, variable names, outputs, etc. This is the most common naming convention in Terraform code.

  3. A variable name cannot start with a number. It can contain numbers, but it must start with a letter.

  4. Variable names are case-sensitive. my_variable is different from My_Variable.

  5. Use descriptive names for resources, data sources, variables, outputs, etc. This makes the code easier to read and understand.


Resources



Modules



Data Sources



Outputs



Variables



Locals



Conditions



Dynamic Blocks