This project implements a fully automated cloud-based infrastructure using OpenTofu and Ansible to provision and configure resources on AWS. It’s designed to be secure, scalable, and fully managed using Infrastructure as Code (IaC).
This project was developed as part of a team during our DevOps course. We collaborated closely on all aspects — infrastructure provisioning, automation, and application deployment. All team members, including myself, contributed equally and worked together on every part of the project.
We were given a situation that our team has been hired as consultants to design and deliver a scalable infrastructure for a client’s web service. The client expects a secure solution deployed and maintained via automation.
- AWS CloudShell – Used to run everything directly in AWS
- OpenTofu – Infrastructure as Code tool to provision AWS resources
- Ansible – Configuration management and app deployment
- AWS account (with CloudShell access)
- GitHub account
-
Open CloudShell from AWS Console
-
Create an SSH key (if not already created):
ssh-keygen -t rsa -b 4096 -C "aws-instance" -f ~/.ssh/InfraProj-cocloudshell-key -N ""
-
Add the public key to GitHub
- View the key:
cat ~/.ssh/InfraProj-cocloudshell-key.pub- Copy the key
- Then go to GitHub → ⚙️ Settings → SSH and GPG keys → New SSH key and paste it.
- Start SSH agent and add your key
eval $(ssh-agent -s)
ssh-add ~/.ssh/InfraProj-cocloudshell-key- Clone the repository using SSH
git clone git@github.com:almafrank/InfrastructureProject.git
cd InfrastructureProject- Run the script
chmod +x install.sh
./install.sh🔧 What the Script Does The install.sh script automates:
- Installing OpenTofu and running
- Generating or using an existing SSH key
- Updating terraform.tfvars with your current IP
- Updating Ansible inventory using Terraform outputs
- Replacing IPs in the inventory and playbooks
- Installing Ansible
- Running playbooks to configure servers
- Accessing the Application Once the script finishes and the app is deployed, open EC2 in AWS -> Load Balancers -> Copy Load Balancer DNS name -> Open in web browser:
📁 Project Structure
InfrastructureProject/
├── Ansible/
│ ├── app_setup.yml
│ ├── inventory
│ ├── postgres_setup.yml
│ ├── python_setup.yml
│ └── files/
│ └── app.py
├── OpenTofu/
│ ├── main.tf
│ ├── output.tf
│ ├── terraform.tfvars
│ └── variable.tf
├── install.sh
└── README.md