https://github.com/coding4deep/terraform-ansible-project
Springboot Fullstack Application Deployment on AWS, Infrastructure Automation with Terraform + Ansible
https://github.com/coding4deep/terraform-ansible-project
ansible aws bash-scripting devops devopsproject git linux memcached mongodb rabbitmq springboot terraform
Last synced: 29 days ago
JSON representation
Springboot Fullstack Application Deployment on AWS, Infrastructure Automation with Terraform + Ansible
- Host: GitHub
- URL: https://github.com/coding4deep/terraform-ansible-project
- Owner: Coding4Deep
- Created: 2025-06-21T00:38:33.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-06-21T00:51:04.000Z (7 months ago)
- Last Synced: 2025-06-21T01:37:25.545Z (7 months ago)
- Topics: ansible, aws, bash-scripting, devops, devopsproject, git, linux, memcached, mongodb, rabbitmq, springboot, terraform
- Language: HCL
- Homepage:
- Size: 0 Bytes
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Springboot Fullstack Application Deployment on AWS
**Infrastructure Automation with Terraform + Ansible**
---
## Project Overview
This project demonstrates **fully automated infrastructure provisioning and configuration** for a full-stack Spring Boot web application using:
* **Terraform**: to provision AWS infrastructure (VPC, Subnets, EC2 instances, Security Groups, SSH Key, etc.)
* **Ansible**: to install and configure required software on provisioned instances (Tomcat, Memcached, RabbitMQ, MongoDB)
* **Shell Scripting**: to automated the whole process just by single command .
---
## Tech Stack Used
| Layer | Technology |
| ---------------------------- | ------------- |
| Infrastructure Provisioning | Terraform |
| Infrastructure Configuration | Ansible |
| Cloud Provider | AWS |
| Application Server | Apache Tomcat |
| Database | MongoDB |
| Caching | Memcached |
| Messaging Queue | RabbitMQ |
---
## Prerequisites
Make sure you have following tools installed in your machine:
1. **Terraform**
* [Terraform Installation Guide](https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli)
2. **Ansible**
* [Ansible Installation Guide](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html)
3. **AWS CLI**
* [AWS CLI Installation Guide](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)
4. **Python Boto3 Module (for Ansible AWS Plugin)**
```bash
pip install boto3 botocore
```
5. **AWS Account** with Access Key and Secret Key configured:
```bash
aws configure
```
---
## AWS Resources Provisioned
* VPC
* Public Subnet
* Private Subnet
* Security Groups
* EC2 Instances:
* Public EC2 (Tomcat Server)
* Private EC2 (Memcached)
* Private EC2 (RabbitMQ)
* Private EC2 (MongoDB)
* SSH Key Pair
---
## Complete Project Structure
```
project-root/
│
├── terraform/
│ ├── # All Terraform code here
|
├── ansible/
│ ├── # All Ansible code here
|
└── project.pem (auto-generated by Terraform)
```
---
## End-to-End Usage Guide
### Step 1: Clone the Project Repository
```bash
git clone https://github.com/Coding4Deep/Terraform-Ansible-Project.git
cd Terraform-Ansible-Project
```
### Step 2: Update Terraform Configuration
```bash
* Update `provider.tf` with your AWS region.
* Replace `ami-xxxxxxxx` with valid Ubuntu AMI ID from your region.
```
### Step 3: Apply Terraform to Create Infrastructure
```bash
terraform init
terraform plan
terraform apply
```
✅ Terraform will create the entire AWS infrastructure.
✅ After provisioning is done, Terraform automatically triggers Ansible via `null_resource` to configure all servers.
> **Note:** You may be prompted for approval during `terraform apply`.
### Step 5: Ansible Dynamic Inventory Setup
Ensure you have valid AWS credentials locally (`~/.aws/credentials`).
The file `ansible/inventory/aws_ec2.yaml` uses AWS EC2 dynamic inventory plugin to auto-discover EC2 instances using tags.
You can test Ansible inventory:
```bash
cd ../ansible/
ansible-inventory --graph
```
You should see:
```
@all:
|--@aws_ec2:
|--@role_tomcat:
| |--springboot-public
|--@role_memcached:
| |--springboot-memcached
|--@role_rabbitmq:
| |--springboot-rabbitmq
|--@role_mongo:
| |--springboot-mongo
```
No IP addresses needed. Fully dynamic!
### Step 5: Run Ansible Playbooks Manually (optional)
If you want to re-run Ansible manually anytime:
```bash
ansible-playbook playbooks/site.yml
```
This will execute all roles (tomcat, memcached, rabbitmq, mongo).
---
## What Happens During Provisioning?
| Component | Action |
| ------------------ | ---------------------------------------------------------------- |
| Terraform | Provisions VPC, Subnets, EC2 Instances, Security Groups, SSH Key |
| Ansible | Dynamically discovers EC2 instances via AWS tags |
| Tomcat Playbook | Installs Java, Downloads and Configures Apache Tomcat |
| Memcached Playbook | Installs and Starts Memcached Service |
| RabbitMQ Playbook | Installs and Starts RabbitMQ Server |
| MongoDB Playbook | Adds official MongoDB repo, Installs MongoDB, Starts MongoDB |
---
## Future Enhancements (Optional Improvements)
* Use Bastion Host for secure SSH into private instances
* Jenkins CI/CD integration for full automation pipeline
* Monitoring with CloudWatch
* HTTPS with ACM and Load Balancer
---
## Credits
Created by \[Deepak Sagar]. Open-source project to help anyone learn cloud provisioning and automation.
---
## 📅 License
This project is open-source and available under MIT License.
---