/terraform-registry-module-template

Batteries-included πŸ”‹Terraform module template, based on real-world experience and managing IAC "at scale" πŸš€

Primary LanguageShellOtherNOASSERTION

logo
Terraform Module Golden Template πŸ†

An easy to understand, opinionated terraform composable module with batteries included πŸ”‹.


Unit & Integration tests TerraTest Go Linter Terratest Release Terraform CI Checks Modules Terraform CI Checks Recipes Terraform Plan recipes AWS on PR

[//]: # (// FIXME: Remove, refactor or change. (Template)

About The Module

[//]: # (// FIXME: Remove, refactor or change. (Template) (put high level description here)


Module documentation

The documentation is automatically generated by terraform-docs, and it's available in the module's README.md file.

Capabilities

[//]: # (// FIXME: Remove, refactor or change. (Template)

(put description here)

Getting Started

[//]: # (// FIXME: Remove, refactor or change. (Template)

(put description here)

Roadmap

[//]: # (// FIXME: Remove, refactor or change. (Template)

(put description here)

Module standard structure

The module's relevant components, structure and "skeleton" is described below:

.
β”œβ”€β”€ CONTRIBUTING.md
β”œβ”€β”€ LICENSE
β”œβ”€β”€ Makefile
β”œβ”€β”€ README.md
β”œβ”€β”€ TaskFile.yml
β”œβ”€β”€ default
β”‚   └── unit
β”œβ”€β”€ docs
β”‚   └── contribution_guidelines.md
β”œβ”€β”€ examples
β”‚   β”œβ”€β”€ README.md
β”‚   β”œβ”€β”€ TaskFile.yml
β”‚   └── default
β”‚       └── basic
β”‚           β”œβ”€β”€ README.md
β”‚           β”œβ”€β”€ config
β”‚           β”‚   └── fixtures.tfvars
β”‚           β”œβ”€β”€ main.tf
β”‚           β”œβ”€β”€ outputs.tf
β”‚           β”œβ”€β”€ providers.tf
β”‚           β”œβ”€β”€ variables.tf
β”‚           └── versions.tf
β”œβ”€β”€ modules
β”‚   β”œβ”€β”€ TaskFile.yml
β”‚   └── default
β”‚       β”œβ”€β”€ README.md
β”‚       β”œβ”€β”€ data.tf
β”‚       β”œβ”€β”€ locals.tf
β”‚       β”œβ”€β”€ main.tf
β”‚       β”œβ”€β”€ outputs.tf
β”‚       β”œβ”€β”€ variables.tf
β”‚       └── versions.tf
β”œβ”€β”€ release-please-config.json
β”œβ”€β”€ scripts
β”‚   β”œβ”€β”€ containers
β”‚   β”‚   └── build-and-run.sh
β”‚   β”œβ”€β”€ golang
β”‚   β”‚   └── go_build.sh
β”‚   └── hooks
β”‚       └── pre-commit-init.sh
β”œβ”€β”€ taskfiles
β”‚   β”œβ”€β”€ Taskfile.common.yml
β”‚   β”œβ”€β”€ Taskfile.devex.yml
β”‚   β”œβ”€β”€ Taskfile.precommit.yml
β”‚   β”œβ”€β”€ Taskfile.terraform.yml
β”‚   └── Taskfile.terragrunt.yml
└── tests
    β”œβ”€β”€ README.md
    β”œβ”€β”€ TaskFile.yml
    └── default
        β”œβ”€β”€ integration
        β”‚   β”œβ”€β”€ default_basic_integration_test.go
        β”‚   β”œβ”€β”€ go.mod
        β”‚   β”œβ”€β”€ go.sum
        β”‚   └── target
        β”‚       └── basic
        β”‚           └── main.tf
        └── unit
            β”œβ”€β”€ default_basic_unit_test.go
            β”œβ”€β”€ go.mod
            β”œβ”€β”€ go.sum
            └── target
                └── basic
                    └── main.tf```

Where:

  • ⚑️Modules: refers to the actual module's directory. Where the .tf files reside. Each subdirectory is a module.
  • ⚑️Examples: refers to the examples directory, where the examples recipes lives. These are also used for testing the infrastructure using Terratest. For its specific documentation, query this link
  • ⚑️Tests: refers to the tests directory, where the tests recipes lives. These are also used for testing the infrastructure using Terratest. For its specific documentation, query this link

Developer Experience

Some tools that this repo uses:

  • 🧰 Terraform β€” strongly recommended the latest versions
  • 🧰 Go β€” justified mostly for Terratest
  • 🧰 TaskFile β€” for the automation of the tasks.
  • 🧰 Make β€” for the automation of the tasks.

NOTE: For automation during the development process, I use precommit, which is a framework for managing and maintaining multi-language pre-commit hooks. It's a great tool, and I highly recommend it. All the hooks required are installed by this script. It's recommended though to run it through the TaskFile task pre-commit-init.

To initialize your pre-commit configuration, and ensure all the hooks are installed, run the following command:

# Using taskFiles
task pc-init
# Using make
make pc-init

To run these hooks against all the files, you can use the following Task command:

# Using taskFiles
task pc-run
# Using make
make pc-run

Module Versioning

This Module follows the principles of Semantic Versioning (SemVer).

Given a version number MAJOR.MINOR.PATCH, we increment the:

  1. MAJOR version when we make incompatible changes,
  2. MINOR version when we add functionality in a backwards compatible manner, and
  3. PATCH version when we make backwards compatible bug fixes.

Backwards compatibility in 0.0.z and 0.y.z version

  • Backwards compatibility in versions 0.0.z is not guaranteed when z is increased. (Initial development)
  • Backwards compatibility in versions 0.y.z is not guaranteed when y is increased. (Pre-release)

NOTE: The releases are automatically generated using release-please-action. For more information, please refer to the release-please-action documentation

Contributing

Contributions are always encouraged and welcome! ❀️. For the process of accepting changes, please refer to the CONTRIBUTING.md file, and for a more detailed explanation, please refer to this guideline here.


Roadmap πŸ—Ί

  • Integrate Open Policy Agent for policy as code.
  • Integrate Conftest for policy as code.
  • Integrate (Go) TerraDagger for CI using Dagger.io.
  • Add built-in CLI for boilerplate generation.

License

license

This module is licensed under the Apache License Version 2.0, January 2004. Please see LICENSE for full details.

Contact

made/with ❀️ 🀟