https://github.com/Azure-Terraform/coding-standards
Terraform Coding Standards & Guidelines
https://github.com/Azure-Terraform/coding-standards
Last synced: 6 months ago
JSON representation
Terraform Coding Standards & Guidelines
- Host: GitHub
- URL: https://github.com/Azure-Terraform/coding-standards
- Owner: Azure-Terraform
- License: mit
- Created: 2020-05-13T09:53:11.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-05-22T09:42:48.000Z (about 5 years ago)
- Last Synced: 2024-08-09T02:18:52.072Z (10 months ago)
- Homepage:
- Size: 3.91 KB
- Stars: 4
- Watchers: 7
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- jimsghstars - Azure-Terraform/coding-standards - Terraform Coding Standards & Guidelines (Others)
README
# Best Practice for Terraform Module Creation
The aim of this document is to provide a best-practice framework for creating Terraform Modules.
This will help ensure all terraform modules follow a consistent format and structure.#### Repository Structure
* README.md - Documentation and example usage
* versions.tf - Provider version locking
* variables.tf - Input variables
* output.tf
* main.tf#### Module Usage
When consuming a Terraform module the source should always be versioned.
Where possible all code should be locked to a version to prevent issues in future.
A conscious effort should be made to bring these versions up-to date on a regular basis.#### Resource Tagging
If a resource accepts tag values these must be used.
Please reference the tagging policy for the relevant cloud to ensure you are compliant.#### Comments and Readability
All comments should use a single hash, space followed by the comment
Example Usage:
> \# Example commentIf count is specified it should always be the first variable.
Tags should be the last variable to ensure code is readable.Example Usage:
> resource "example_resource" "example_name" {
> count = x
>
> name = "example-resource"
> ....
> tags = ['example']
>}#### Input Variables
All input variables must have description and type.
The structure for inputs is:
- Description
- Type
- Default (if defined)Example Usage:
>variable "example_input_variable" {
> description = "This is an example input variable"
> type = string
> default = "example"
>}#### Providers
Terraform providers should not be specified within a module.
Instead use the required_provider option, all providers should also include a minimum version.Example Usage:
>terraform {
> required_version = ">= 0.12.20"
>
> required_providers {
> azurerm = ">= 2.0.0"
> }
>
>}