- Overview
- Prerequisites
- Installation
- Usage
- Workspace Configuration (Terraform Cloud)
- Command Used
- Modules Used
- Authors
This project aims to provide a Terraform infrastructure template for deploying frontend, backend, and database applications on AWS. By utilizing Infrastructure as Code (IaC) principles, you can automate the provisioning and management of your application's infrastructure on any cloud platforms such as AWS, Azure, or Google Cloud.
The infrastructure setup includes the following components:
-
Frontend Application: Built with modern frontend frameworks like React.
-
Backend Application: Used Spring Boot to interact with the frontend application.
-
Database: MySQL as a persistent storage solution to store and retrieve data for your application.
-
Cloud Virtual Machine: Amazon EC2 compute resources for hosting all three applications.
Before getting started, ensure that you have the following prerequisites in place:
- Terraform : Install Terraform by following the official documentation for your operating system.
- Cloud Provider Account: Valid AWS account credentials with appropriate IAM permissions to provision AWS resources.
- Application Code: Prepare your frontend and backend application code, ensuring it is properly configured for deployment.
To install and set up the project, follow these steps:
- Clone the repository:
git clone <URL>
- Please create a new
env.auto.tfvars
file and populate it with the following content:
aws_region = "<AWS Region>"
aws_access_key = "<AWS Access Key>"
aws_secret_key = "<AWS Secret Key>"
security_group_ingress_ports = ["xx", "xxxx", "xx", "xxxx"]
ec2_ami = "<EC2 AMI Number>"
ec2_instance_type = "<EC2 Instance Type>"
ec2_tag_name = "<EC2 Tag Name>"
- Place this env file inside
backend, database and frontend
folders
To use this Terraform infrastructure template, follow these steps:
- Inside frontend, backend and database
- Run
terraform init
to initialize the Terraform workspace. - Run
terraform plan
to preview the changes that Terraform will apply to your infrastructure. - Run
terraform apply
to provision the infrastructure defined in your Terraform files. - Verify that your frontend, backend, and database applications are successfully deployed.
We also utilized Terraform Cloud, to store terraform state file in synchronized
mode.
NOTE: If do not want to use this feature than remove terraform.tf file.
This project utilizes the following custom modules:
aws_ec2
: Manages the provisioning and configuration of AWS EC2 instances to host frontend, backend, and database applications.aws_sg
: Configures security groups to enforce granular network traffic rules, ensuring robust security and controlled
terraform init
terraform plan
terraform apply -auto-approve
terraform destroy