This repository serves as a template for creating Terraform modules. It provides a structured approach to organizing and maintaining Terraform code, along with examples and best practices.
Before you begin, ensure you have met the following requirements:
- install terraform
- install pre-commit
- configure pre-commit:
pre-commit install - install required tools
To use this template, clone the repository and customize it according to your module's requirements. Below is a quick start guide:
-
Clone the repository:
git clone https://github.com/your-username/terraform-module-template.git cd terraform-module-template -
Customize the module:
- Update
main.tf,variables.tf,outputs.tf, andversions.tffiles as needed. - Add your own resources and logic.
- Update
-
Run Terraform commands:
terraform init terraform plan terraform apply
This repository includes example configurations to help you understand how to use the module:
-
Complete Example: Located in
examples/complete- Demonstrates a full-featured usage of the module.
cd examples/complete terraform init terraform apply -
Minimal Example: Located in
examples/minimal- Shows a minimal configuration for using the module.
cd examples/minimal terraform init terraform apply
The repository is organized as follows:
.
├── .editorconfig
├── examples
│ ├── complete
│ │ ├── main.tf
│ │ ├── outputs.tf
│ │ ├── provider.tf
│ │ ├── README.md
│ │ ├── variables.tf
│ │ └── versions.tf
│ └── minimal
│ ├── main.tf
│ ├── outputs.tf
│ ├── provider.tf
│ ├── README.md
│ ├── variables.tf
│ └── versions.tf
├── .github
│ └── workflows
│ ├── documentation.yaml
│ ├── pre-commit.yaml
│ └── pr-title.yaml
├── .gitignore
├── main.tf
├── modules
│ └── sample-resource
│ ├── main.tf
│ ├── outputs.tf
│ ├── variables.tf
│ └── version.tf
├── outputs.tf
├── .pre-commit-config.yaml
├── README.md
├── .terraform-docs.yml
├── tests
│ ├── examples_minimal.tftest.hcl
│ └── unit_tests.tftest.hcl
├── .tflint.hcl
├── variables.tf
└── versions.tf
Reference Getoutline Document for Conventions to follow in your module
| Name | Version |
|---|---|
| terraform | >= 1.8.4 |
No providers.
No modules.
No resources.
No inputs.
No outputs.