Skip to content

Template for creating reusable Terraform components for Atmos.

Notifications You must be signed in to change notification settings

infraspecdev/atmos-components-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Terraform Infrastructure Components Template

A template repository for creating reusable Terraform components that are consumed by Atmos stacks. Each component is a self Terraform root module that gets referenced from your stacks repo through source pinning with versioned tags.

Repository Structure

.
├── components/terraform/
│   └── <component-name>/
│       ├── main.tf          # Resource definitions and module calls
│       ├── variables.tf     # Input variable declarations
│       ├── outputs.tf       # Output value declarations
│       ├── versions.tf      # Terraform and provider version constraints
│       ├── provider.tf      # Provider configuration
│       └── data.tf          # Data source lookups
├── .github/workflows/
│   ├── terraform-validate.yaml   # Runs fmt check and validate on PR
│   ├── pr-title-check.yaml       # Enforces conventional commit PR titles
│   └── release-version.yaml      # Semantic versioning on merge to main
├── .gitignore
└── .releaserc.json

How It Works

  1. Each component live under components/terraform/<component-name>/
  2. Stacks repos reference components from this repo using source pinning:
    source:
      uri: github.com/<org>/<this-repo>.git//components/terraform/<component-name>
      version: v1.0.0
  3. When changes are merged to main, semantic-release auto-creates a new version tag based on commit messages

Getting Started

  1. Use this repo as a GitHub template
  2. Remove the sample-component directory
  3. Create your component under components/terraform/<your-component>/ with the standard files (main.tf, variables.tf, outputs.tf, versions.tf, provider.tf, data.tf)
  4. Install pre-commit hooks if applicable
  5. Open a PR with a commit title (e.g., feat: Add s3 component)
  6. On merge, a version tag is automatically created

Adding a New Component

mkdir -p components/terraform/<component-name>
touch components/terraform/<component-name>/{main,variables,outputs,versions,provider,data}.tf

Every component should include these baseline variables:

Variable Description
aws_region AWS region for deployment
environment Environment name (dev, staging, prod)
tags Map of tags applied to all resources
stage Atmos stage name for state management

CI/CD

Workflow Trigger Description
terraform-validate.yaml PR to main Checks formatting and runs terraform validate on each component
pr-title-check.yaml PR opened/edited Validates PR title follows conventional commits (feat:, fix:, chore:, etc.)
release-version.yaml Push to main Creates a semantic version tag via semantic-release

Components

  • sample-component: A template to use as a reference when adding new components

About

Template for creating reusable Terraform components for Atmos.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages