|
| 1 | +# Terraform Shared Modules Repository |
| 2 | + |
| 3 | +## Overview |
| 4 | +This repository contains reusable Terraform modules for provisioning cloud infrastructure. These modules follow best practices for modularization and can be used across multiple projects. |
| 5 | + |
| 6 | +## Directory Structure |
| 7 | +``` |
| 8 | +. |
| 9 | +├── README.md |
| 10 | +├── modules |
| 11 | +│ ├── eks |
| 12 | +│ │ ├── main.tf |
| 13 | +│ │ ├── variables.tf |
| 14 | +│ │ ├── outputs.tf |
| 15 | +│ │ └── README.md |
| 16 | +│ ├── vpc |
| 17 | +│ │ ├── main.tf |
| 18 | +│ │ ├── variables.tf |
| 19 | +│ │ ├── outputs.tf |
| 20 | +│ │ └── README.md |
| 21 | +│ └── other-modules |
| 22 | +│ ├── module-name |
| 23 | +│ ├── ... |
| 24 | +│ └── README.md |
| 25 | +``` |
| 26 | + |
| 27 | +## Usage |
| 28 | +Each module can be used independently in your Terraform configurations. These modules should be sourced from this repository into another Terraform project. |
| 29 | + |
| 30 | +### Example: Using the `eks` Module |
| 31 | +In your separate Terraform repository: |
| 32 | +```hcl |
| 33 | +module "eks" { |
| 34 | + source = "git::https://github.com/your-org/terraform-modules.git//modules/eks?ref=main" |
| 35 | + cluster_name = "my-eks-cluster" |
| 36 | + subnet_ids = ["subnet-abc", "subnet-def"] |
| 37 | +} |
| 38 | +``` |
| 39 | + |
| 40 | +### Example: Using the `vpc` Module |
| 41 | +```hcl |
| 42 | +module "vpc" { |
| 43 | + source = "git::https://github.com/your-org/terraform-modules.git//modules/vpc?ref=main" |
| 44 | + vpc_name = "my-vpc" |
| 45 | + cidr_block = "10.0.0.0/16" |
| 46 | +} |
| 47 | +``` |
| 48 | + |
| 49 | +## Best Practices |
| 50 | +- **Keep modules small and focused** – each module should serve a single purpose. |
| 51 | +- **Use versioning** – tag releases to ensure stability. |
| 52 | +- **Follow Terraform best practices** – maintain proper `variables.tf`, `outputs.tf`, and documentation. |
| 53 | +- **Lint and validate** – use `terraform fmt`, `terraform validate`, and `tflint` to maintain code quality. |
| 54 | + |
| 55 | +## Linting & Validation (GitHub Actions) |
| 56 | +This repository is configured to run Terraform linting and validation using GitHub Actions. |
| 57 | + |
| 58 | +### Running Checks Locally |
| 59 | +Before pushing changes, run: |
| 60 | +```sh |
| 61 | +terraform fmt -recursive |
| 62 | +terraform validate |
| 63 | +terraform plan |
| 64 | +``` |
| 65 | + |
| 66 | +## Contributing |
| 67 | +1. Fork the repository and create a new branch. |
| 68 | +2. Make changes and test them. |
| 69 | +3. Open a pull request with a detailed description. |
| 70 | + |
| 71 | +## License |
| 72 | +NA |
0 commit comments