Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Microservices TODO Application - Infrastructure Automation

Table of Contents

Overview

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.

Requirements

Software Prerequisites

Cloud Requirements

  • Active cloud provider account
  • IAM credentials with provisioning permissions
  • Registered domain name for SSL configuration

Setup Instructions

  1. Clone Repository
    git clone https://github.com/favy12/ToDo-Infra.git
    cd ToDo-Infra
    
  2. Initialize Terraform
    terraform init
    
  3. 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

Ansible Architecture

Component Purpose

dependencies role Install Docker, Docker Compose, and system packages

deployment role Clone app repo, start services

inventory directory Dynamic host inventory generated by Terraform

Deployment Process Execute full deployment pipeline:

terraform apply -auto-approve

Verify application deployment:

ansible-playbook -i inventory/hosts ansible/verify.yml

Environment Variables

Cloud Credentials

AWS_ACCESS_KEY_ID=AKIAXXXXXXXXXXXXXXXX AWS_SECRET_ACCESS_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX TF_VAR_REGION=us-east-1

Directory Structure

Project Structure with Annotations

.
├── 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)

Critical File Details

  1. Ansible Role Structure:

    roles/
    └── dependencies/
        └── tasks/main.yml        # Contains:
                                  # - apt package updates
                                  # - Docker CE installation
                                  # - Docker Compose setup
    
  2. 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
    
  3. State File Warning:

    terraform.tfstate*            # Contains sensitive infrastructure data
                                  # Auto-generated - add to .gitignore
                                  # Managed remotely (S3/Cloud Storage) in prod
    
  4. Inventory Generation:

    generate_inventory.sh         # Converts Terraform outputs to Ansible format:
                                  # - Extracts IP addresses
                                  # - Sets connection parameters
                                  # - Groups servers by role
    

About

Terraform + Ansible IaC for single-command cloud deployment of a microservices application

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages