- Overview
- Requirements
- Setup Instructions
- Infrastructure Architecture
- Deployment Process
- Environment Variables
- Directory Structure
This repository contains Terraform and Ansible configurations for automated provisioning and deployment of the Microservices TODO Application. The infrastructure-as-code implementation enables single-command deployment of cloud infrastructure and application services.
- Terraform >= 1.5.0
- Ansible >= 2.12.0
- Cloud Provider CLI (AWS/Azure/GCP)
- SSH Key Pair (public/private)
- Active cloud provider account
- IAM credentials with provisioning permissions
- Registered domain name for SSL configuration
- Clone Repository
git clone https://github.com/favy12/ToDo-Infra.git cd ToDo-Infra - Initialize Terraform
terraform init
- Configure Environment
Infrastructure Description Terraform Components
Compute Resources: EC2 instances/VM scale sets
Networking: VPC, security groups, load balancers
Storage: Managed disk volumes for persistent data
DNS: Automated domain record configuration
Deployment Process Execute full deployment pipeline:
terraform apply -auto-approve
Verify application deployment:
ansible-playbook -i inventory/hosts ansible/verify.yml
Environment Variables
AWS_ACCESS_KEY_ID=AKIAXXXXXXXXXXXXXXXX AWS_SECRET_ACCESS_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX TF_VAR_REGION=us-east-1
Directory Structure
.
├── ansible/ # Ansible configuration management
│ ├── roles/
│ │ ├── dependencies/ # System dependencies installation
│ │ │ ├── defaults/
│ │ │ └── tasks/ # Installation tasks
│ │ │ └── main.yml # Main tasks: Docker + dependencies
│ │ └── deployment/ # Application deployment
│ │ ├── defaults/ # Deployment variables
│ │ └── tasks/
│ │ └── main.yml # Deployment tasks: clone repo, start services
│ ├── inventory/
│ │ └── hosts # Generated inventory file (dynamic)
│ └── playbook.yml # Main Ansible entry point
│
├── terraform/ # Infrastructure provisioning
│ ├── terraform.lock.hcl # Dependency lock file
│ ├── main.tf # Core infrastructure resources
│ ├── outputs.tf # Output variables (IPs, URLs)
│ ├── provider.tf # Cloud provider configuration
│ ├── variables.tf # Input variables (instance size, region)
│ └── terraform.tfstate* # State files (⚠️ DO NOT COMMIT ⚠️)
│
├── .gitignore # Version control exclusions:
│ # - terraform.tfstate*
│ # - .env files
│ # - Sensitive credentials
│
├── generate_inventory.sh # Generates Ansible inventory from TF output
└── README.md # Project documentation (you are here)
-
Ansible Role Structure:
roles/ └── dependencies/ └── tasks/main.yml # Contains: # - apt package updates # - Docker CE installation # - Docker Compose setup -
Terraform Essentials:
provider.tf # Cloud credentials and region config variables.tf # Inputs: instance_type, domain_name, etc. main.tf # Defines: # - VM instances # - Security groups # - DNS records -
State File Warning:
terraform.tfstate* # Contains sensitive infrastructure data # Auto-generated - add to .gitignore # Managed remotely (S3/Cloud Storage) in prod -
Inventory Generation:
generate_inventory.sh # Converts Terraform outputs to Ansible format: # - Extracts IP addresses # - Sets connection parameters # - Groups servers by role