Back to Projects

EC2 Instance Configuration using Terraform and Ansible

EC2 Instance Configuration ArchitectureProject Architecture Diagram
AWS

AWS

Ansible

Ansible

Terraform

Terraform

Bash

Bash

Python

Python

Project Overview
This project uses Terraform to provision an EC2 instance on AWS and Ansible to configure it with a Flask application, enabling a seamless Infrastructure-as-Code workflow.
Key Features
  • Infrastructure as Code (IaC): Automates the provisioning of an AWS EC2 instance using Terraform.
  • Configuration Management: Installs and configures a Python Flask application using Ansible.
  • Automation: Uses Bash scripting to streamline the entire process from provisioning to deployment.
  • Modular Structure: Clean separation of concerns with dedicated folders for Terraform, Ansible, and scripts.
  • Repeatable Workflow: Easily reproducible setup for consistent and reliable infrastructure and application deployment.
How it works
  1. Terraform provisions an EC2 instance on AWS and outputs its public IP.
  2. A Bash script captures the public IP and dynamically updates the Ansible inventory file.
  3. Ansible connects to the instance via SSH and:
    • Installs required packages (Python3, pip, Flask)
    • Clones or sets up the Flask app
    • Runs the Flask application
  4. The Flask app becomes accessible via the EC2 public IP.