An AWS Terraform Starter Kit that includes predefined Terraform configurations, secure state management, and development tools, along with CI/CD pipelines optimized for GitHub Actions, enabling you to quickly and securely deploy scalable AWS infrastructure on your account.
- Complete Terraform Setup: Pre-configured Terraform files with AWS provider
- Secure State Management: S3 backend with DynamoDB locking for state files
- Dummy Resource Deployment: S3 bucket with security best practices as demo
- Development Tools: Makefile and shell scripts for common operations
- CI/CD Pipeline: GitHub Actions workflow for automated deployments
- Security Best Practices: Encrypted storage, public access blocks, and proper IAM
- Comprehensive Documentation: Step-by-step guides and examples
Before you begin, ensure you have the following installed:
git clone https://github.com/towardsthecloud/aws-terraform-starter-kit.git
cd aws-terraform-starter-kitConfigure your AWS credentials using one of these methods:
Option A: AWS CLI
aws configureOption B: Environment Variables
export AWS_ACCESS_KEY_ID="your-access-key"
export AWS_SECRET_ACCESS_KEY="your-secret-key"
export AWS_DEFAULT_REGION="us-east-1"Option C: IAM Role (for EC2/ECS/Lambda) Attach an appropriate IAM role to your compute resource.
Quick Setup (using scripts):
./scripts/setup.sh
./scripts/deploy.shManual Setup (using Makefile):
make setup # Copy example files
make deploy # Full deployment workflowStep-by-step Setup:
# Copy and edit configuration
cp terraform.tfvars.example terraform.tfvars
# Edit terraform.tfvars with your values
# Initialize and deploy
terraform init
terraform plan
terraform applyβββ main.tf # Main Terraform configuration
βββ variables.tf # Input variables
βββ outputs.tf # Output values
βββ terraform.tf # Terraform and provider configuration
βββ backend.tf # Remote state backend configuration
βββ terraform.tfvars.example # Example variables file
βββ Makefile # Common operations
βββ scripts/
β βββ setup.sh # Setup script
β βββ deploy.sh # Deployment script
β βββ cleanup.sh # Cleanup script
βββ .github/workflows/
β βββ terraform.yml # GitHub Actions CI/CD
βββ README.md # This file
make help # Show available commands
make setup # Initial setup (copy example files)
make init # Initialize Terraform
make validate # Validate configuration
make format # Format Terraform files
make plan # Create execution plan
make apply # Apply changes
make destroy # Destroy resources
make clean # Clean local files
make deploy # Full deployment workflow
make check # Check tool versions./scripts/setup.sh # Interactive setup
./scripts/deploy.sh # Interactive deployment
./scripts/cleanup.sh # Interactive cleanupEdit terraform.tfvars to customize your deployment:
# AWS region for resources
aws_region = "us-east-1"
# Environment name
environment = "dev"
# Project name
project_name = "my-awesome-project"
# S3 bucket name (optional, auto-generated if empty)
bucket_name = ""
# Common tags
tags = {
Terraform = "true"
Environment = "dev"
Project = "my-awesome-project"
Owner = "your-name"
Department = "engineering"
}After the initial deployment, you can migrate to remote state:
- Note the state bucket and DynamoDB table names from outputs
- Uncomment the backend configuration in
terraform.tf - Update the bucket and table names
- Run
terraform initto migrate state
backend "s3" {
bucket = "your-project-terraform-state-xxxxx"
key = "terraform/state.tfstate"
region = "us-east-1"
dynamodb_table = "your-project-terraform-state-lock"
encrypt = true
}- S3 Bucket Encryption: Server-side encryption enabled
- S3 Public Access Block: Prevents accidental public access
- S3 Versioning: Enabled for data protection
- DynamoDB State Locking: Prevents concurrent modifications
- IAM Best Practices: Minimal required permissions
- Encrypted State Storage: State files encrypted at rest
The included GitHub Actions workflow provides:
- Terraform Validation: Format and syntax checking
- Security Scanning: Basic security checks
- Plan Generation: For pull requests
- Automated Deployment: For main branch pushes
-
Add AWS credentials to GitHub Secrets:
AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEY
-
Update workflow file if needed:
- Modify AWS region
- Adjust branch names
- Add environment protection rules
This starter kit deploys:
- Demo S3 Bucket: A secure S3 bucket with best practices
- Demo S3 Object: A sample text file in the bucket
- State Management: S3 bucket and DynamoDB table for Terraform state
- Security Settings: Encryption, versioning, and access controls
To remove all resources:
# Using script (interactive)
./scripts/cleanup.sh
# Using Makefile
make destroy
# Using Terraform directly
terraform destroy- Add new resources to
main.tfor create new.tffiles - Add required variables to
variables.tf - Add outputs to
outputs.tf - Update
terraform.tfvars.examplewith new variables
Replace the S3 bucket with your preferred demo resource:
- EC2 instances
- RDS databases
- Lambda functions
- VPC networking
- Terraform Documentation
- AWS Provider Documentation
- Terraform Best Practices
- AWS Well-Architected Framework
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
If you encounter any issues:
- Check the GitHub Issues
- Review the Terraform and AWS documentation
- Ensure your AWS credentials and permissions are correct
- Verify all prerequisites are installed
After successful deployment:
- Explore Outputs: Review the deployed resources
- Customize Configuration: Modify variables and add resources
- Setup Remote State: Migrate to S3 backend for team collaboration
- Implement CI/CD: Configure GitHub Actions for your workflow
- Add Monitoring: Implement CloudWatch, alerting, and logging
- Scale Up: Add more complex AWS resources and modules
Happy Terraforming! π