Skip to content

orasraf12/3-tier-application-Demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

3-tier application Demo

Alt Text

Technical Overview

Welcome to the technical documentation for your inaugural AWS project! In this phase, you will be orchestrating a 3-tier application within your internal AWS Organization using Terraform as the Infrastructure as Code (IaC) tool. The architecture comprises 2 frontend machines, 2 backend machines, and 2 databases, meticulously configured in a multi-AZ (Availability Zone) setup. The application's gateway is facilitated through an Application Load Balancer (ALB) residing in a public subnet, while all machines, including frontends and backends, are strategically positioned in private subnets. An additional internal Load Balancer (LB) will be integral for secure communication between the tiers.

Project Components

Frontend

  • Node.js application running on 2 machines.
  • Deployed using Auto Scaling Groups (ASG) for scalability.
  • Utilizes custom Amazon Machine Images (AMIs).
  • Exposed on ports 3000.
  • Machines situated in private subnets.

Backend

  • Python Flask application running on 2 machines.
  • Deployed using Auto Scaling Groups (ASG) for scalability.
  • Utilizes custom Amazon Machine Images (AMIs).
  • Operating on ports 5000.
  • Machines positioned in private subnets.

Databases

  • 2 databases deployed in a multi-AZ configuration.
  • Utilizes one master and one replica instance.
  • Specific database configurations are to be customized.

Load Balancers

  • External ALB for public access.
  • Internal LB to manage communication between tiers.

Setup Instructions

Follow the precise steps below to set up the project:

  1. Clone the repository:

    git clone https://github.com/orasraf12/3-tier-application-Demo.git
    cd 3-tier-application-Demo/terraform
    
  2. Initialize Terraform:

    terraform init 
    
  3. Review and modify variables in terraform.tfvars file.

  4. Deploy the infrastructure:

    terraform apply 
    # Enter your database password when prompted
    
    

Accessing the Application

Access the application through the public URL provided by the ALB. Access the EC2 machines using Session Manager.

Providers

Name Version
aws 5.38.0

Modules

Name Source Version
backend_asg terraform-aws-modules/autoscaling/aws n/a
frontend_asg terraform-aws-modules/autoscaling/aws n/a
vpc terraform-aws-modules/vpc/aws ~> 5.0

Resources

Name Type
aws_autoscaling_attachment.asg_to_alb_backend resource
aws_autoscaling_attachment.asg_to_alb_frontend resource
aws_db_instance.mysql-rds resource
aws_db_instance.replica-mysql-rds resource
aws_db_subnet_group.db_subnet_group resource
aws_lb.application-lb_frontend resource
aws_lb.application_lb_backend resource
aws_lb_listener.alb-listener resource
aws_lb_listener.alb_listener_backend resource
aws_lb_target_group.target_group_backend resource
aws_lb_target_group.target_group_fronted resource
aws_route53_record.backend resource
aws_route53_record.database resource
aws_route53_record.frontend resource
aws_route53_zone.private resource
aws_security_group.backend-server resource
aws_security_group.lb_sg resource
aws_security_group.rds_sg resource

Inputs

Name Description Type Default Required
aws_lb_listener_type the type of the aws_lb_listener string "forward" no
azs A list of availability zones names or ids in the region list(string)
[
"eu-west-2a",
"eu-west-2b"
]
no
backend_ami n/a string "ami-04e1ec573bbbafba8" no
backend_asg n/a string "backend-asg" no
backend_asg_desired_capacity n/a number 2 no
backend_asg_max_size n/a number 4 no
backend_asg_min_szie n/a number 2 no
backend_asg_wait_for_capacity_timeout n/a number 0 no
backend_instance_type n/a string "t3.micro" no
backend_name name fo the backend string "backend" no
cidr VPC CIDR Block string "10.0.0.0/16" no
create_database_subnet_group VPC Create Database Subnet Group, Controls if database subnet group should be created bool true no
create_database_subnet_route_table VPC Create Database Subnet Route Table, Controls if separate route table for database should be created bool true no
database_subnets A list of database subnets inside the VPC list(string)
[
"10.0.151.0/24",
"10.0.152.0/24"
]
no
db_engine type of the db engine for example mysql or postgress etc... string "mysql" no
db_engine_version version of the db engine string "5.7" no
db_instance_type the db instance type string "db.t3.micro" no
db_name database name string "backend" no
db_pass password of the database live it empty and enter when you create string n/a yes
db_user user name for the data base string "root" no
enable_nat_gateway Should be true if you want to provision NAT Gateways for each of your private networks bool true no
frontend_ami n/a string "ami-0e6c17d28dc6c4208" no
frontend_asg_desired_capacity n/a number 2 no
frontend_asg_max_size n/a number 4 no
frontend_asg_min_szie n/a number 2 no
frontend_asg_name frontend vars string "frontend-asg" no
frontend_asg_wait_for_capacity_timeout n/a number 0 no
frontend_instance_type n/a string "t3.micro" no
frontend_name The name fo the frontend env for DNS string "frontend" no
ip_address_type the type of the ip address ipv4 or ipv6 string "ipv4" no
load_balancer_internal the ttype of LB application, nework etc... bool false no
load_balancer_type the ttype of LB application, nework etc... string "application" no
port_backend port number of the backend app number 5000 no
port_database port number of the database app number 3306 no
port_frontend port number of the frontend app number 3000 no
port_http port number of the database app number 80 no
private_subnets A list of private subnets inside the VPC list(string)
[
"10.0.1.0/24",
"10.0.2.0/24"
]
no
protocol_http http protocol for sg and helthchecks string "HTTP" no
protocol_tcp tcp protocol name for sg and helthchecks string "tcp" no
public_subnets A list of public subnets inside the VPC list(string)
[
"10.0.101.0/24",
"10.0.102.0/24"
]
no
region Region in which AWS Resources to be created string "eu-west-2" no
sg_cidr all to ip range list(string)
[
"0.0.0.0/0"
]
no
single_nat_gateway Should be true if you want to provision a single shared NAT Gateway across all of your private networks bool true no
tags ############################################## Tags ##################################### map(string)
{
"Created By": "orasraf@terasky.com",
"Env": "stage",
"Purpose": "learning",
"terraform": "true"
}
no
target_type The type for target group string "instance" no
vpc_name VPC Name string "vpc" no

Outputs

Name Description
azs A list of availability zones specified as argument to this module
nat_public_ips List of public Elastic IPs created for AWS NAT Gateway
private_subnets A list of private subnets inside the VPC
public_subnets A list of public subnets inside the VPC
vpc_cidr_block The CIDR block of the VPC
vpc_id The ID of the VPC

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published