This Cookiecutter
template provides a scaffold to implement good practices
for Terraform modules and can be used to create new modules.
- Each module should be maintained inside a dedicated Git repository
- Module repositories must use this three-part name format:
terraform-<PROVIDER>-<NAME>
whereNAME
reflects the type of infrastructure the module manages andPROVIDER
is the main provider where it creates that infrastructure. TheNAME
segment can contain additional hyphens. Examples: terraform-azuread-application. - The module must adhere to the standard module structure. This allows the registry to inspect your module and generate documentation, track resource usage, parse submodules and examples, and more.
- Modules should be tagged using semantic version. Example,
v1.0.0
andv0.1.1
. Don't forget to usev
as a prefix. - The provided
tflint
rules should not be changed (adding new ones is OK). - The provided
pre-commit
hooks should be used.
- We recommend using the Gitflow Workflow or Trunk-based development.
- We recommend the use of Visual Studio Code, due to the extensions and the customizability.
- We recommend using KICS and/or Checkov for static code analysis of Infrastructure as Code.
- ...
Writing tests is not required, but can be done with Terraform tests
in Terraform v1.6.0 and later.
See https://developer.hashicorp.com/terraform/language/tests
Please follow these steps to instantiate a new module:
- Install cookiecutter
- Run cookiecutter:
cookiecutter \
https://github.com/win-runner/terraform-module-template/ \
-o /path/to/your/new/module/root
Note: You can find additional documentation how to work with your newly created module in the modules README.md file.