This repository provides a structured template for Terraform projects, enabling consistent and scalable infrastructure deployments. The template has best practices, CI/CD integration, and environment-specific configurations to streamline infrastructure management.
.
βββ backend.tf # π§ Defines the backend configuration for Terraform
βββ CHANGELOG.md # π Change log of the project
βββ .checkov.yml # π Configuration file for Checkov security scanner
βββ CODEOWNERS # π₯ Defines the code owners for the repository
βββ .devcontainer # π³ Development container configuration
β βββ devcontainer.json # π¦ Devcontainer configuration file
β βββ Dockerfile # π Dockerfile for the dev environment
βββ .editorconfig # ποΈ Configuration for consistent coding styles
βββ environments # π Holds environment-specific variables
β βββ dev
β β βββ dev.tfvars # π οΈ Development environment variables
β βββ prod
β β βββ prod.tfvars # π Production environment variables
β βββ qa
β βββ qa.tfvars # π QA environment variables
βββ .github # π οΈ GitHub-specific configurations
β βββ dependabot.yml # π€ Dependabot configuration
β βββ ISSUE_TEMPLATE # π GitHub issue template
β β βββ issue_template.md # π Issue template file
β βββ pull_request_template.md # π Pull request template
β βββ workflows # βοΈ GitHub Actions workflows
β βββ lint-pr.yaml # π§Ή Linting workflow for pull requests
β βββ pre-commit-auto-update.yaml # π Pre-commit hook auto-update workflow
β βββ release.yaml # π Release workflow
β βββ stale.yaml # β³ Stale issue management workflow
β βββ template-repo-sync.yaml # π Template repository sync workflow
β βββ terraform-aws.yml # βοΈ Terraform AWS workflow
βββ .gitignore # π« Files and directories to be ignored by Git
βββ LICENSE # βοΈ License for the project
βββ locals.tf # π οΈ Local variables for Terraform
βββ main.tf # π Main Terraform configuration
βββ modules # π¦ Custom Terraform modules
β βββ s3-bucket
β βββ main.tf # π Main configuration for s3-bucket
β βββ outputs.tf # π€ Output definitions for s3-bucket
β βββ variables.tf # π₯ Input variables for s3-bucket
βββ .pre-commit-config.yaml # π οΈ Pre-commit hooks configuration
βββ providers.tf # βοΈ Provider configurations for Terraform
βββ README.md # π Project documentation (this file)
βββ .releaserc.json # π Semantic release configuration
βββ .terraform.lock.hcl # π Terraform lock file
βββ .tflint.hcl # π οΈ Terraform linting configuration
βββ variables.tf # π₯ Input variables for the project
βββ .vscode # π₯οΈ VSCode-specific configurations
βββ extensions.json # π οΈ Recommended extensions for VSCode- Terraform: Ensure you have Terraform installed.
- Docker: Required for the development container setup.
- VSCode: Recommended for development, with the Dev Containers extension.
To get started with development, you can use the pre-configured development container:
- Open in VSCode:
- Install the Dev Containers extension.
- Open the repository in VSCode.
- You should see a prompt to reopen the project in the dev container.
- Build and Run:
- The dev container is pre-configured with all the necessary tools and extensions.
- You can start writing and testing your Terraform configurations immediately.
- Backend Configuration: The
backend.tffile configures the remote state storage for Terraform. - Environment Variables: The
environments/directory contains environment-specific variable files (.tfvars). - Modules: Reusable Terraform modules are stored in the
modules/directory.
Pre-commit hooks are set up to ensure code quality and consistency. To install the pre-commit hooks:
pre-commit installThis project uses Semantic Commit Messages to ensure meaningful and consistent commit history. The format is as follows:
<type>(<scope>): <subject>feat: A new feature (e.g.,feat: add login functionality).fix: A bug fix (e.g.,fix: resolve login button issue).docs: Documentation changes (e.g.,docs: update API documentation).style: Code style changes (formatting, missing semi-colons, etc.) without changing logic (e.g.,style: fix indentation).refactor: Code changes that neither fix a bug nor add a feature (e.g.,refactor: update user controller structure).test: Adding or updating tests (e.g.,test: add unit tests for login service).chore: Changes to build process, auxiliary tools, or libraries (e.g.,chore: update dependencies).
Optional: The part of the codebase affected by the change (e.g., feat(auth): add OAuth support)
A brief description of the change, using the imperative mood (e.g., fix: resolve issue with user authentication).
This project is configured with Semantic Release to automate the release process based on your commit messages.
- Analyze commits: Semantic Release inspects commit messages to determine the type of changes in the codebase.
- Generate release version: Based on the commit type, it will automatically bump the version following semantic versioning:
- fix β Patch release (e.g., 1.0.1)
- feat β Minor release (e.g., 1.1.0)
- BREAKING CHANGE β Major release (e.g., 2.0.0)
- Create release notes: It generates a changelog from the commit messages and includes it in the release.
- Publish: It automatically publishes the new version to the repository (and any other configured registries, e.g., npm).
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Submit a pull request with a detailed description of the changes.
This project is licensed under the MIT License.
| Name | Version |
|---|---|
| terraform | >= 1.0 |
| aws | ~> 5.0 |
| Name | Version |
|---|---|
| aws | 5.95.0 |
No modules.
| Name | Type |
|---|---|
| aws_caller_identity.current | data source |
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| env | The environment to deploy the resources | string |
n/a | yes |
| prefix | The prefix for all resource's names | string |
"dev" |
no |
| region | The region to deploy the resources | string |
"ap-southeast-1" |
no |
| Name | Description |
|---|---|
| environment | The environment name |
| region | The AWS region where resources are deployed |
| resource_prefix | The prefix used for resource naming |