cover-img

Implementing Two-Tier Architecture in AWS - using Terraform #10weeksofCloudOps

17 August, 2023

0

0

0

⭐ Introduction :

Hi all, this is john paul I am currently exploring and learning DevOps and AWS Concepts . I have participated in the #10weeksofcloudops challenge launched by Piyush Sachdeva. In this challenge, we are implementing 2 tier architecture using Terraform which should be highly available and scalable.

What is two-tier architecture?

Two-tier architecture is a simple way of designing and organizing software applications. Imagine it like a two-level structure: the first level is where users interact and the second level handles all the behind-the-scenes work.

  1. Client Tier (First Level): This is where users interact with the application like a website or a mobile app. When you click buttons, type text, or perform any actions, you're using the client tier.
  2. Server Tier (Second Level): This is like the brain of the application. It handles all the logic, calculations, and data processing. When you send a request from the client tier (like searching for something or submitting a form), the server tier processes that request, retrieves or updates data from databases, and sends back the results.

⭐List of aws services used :

  • Amazon VPC (Virtual private cloud) - Private Network
  • Availability zone - (Achieving high availability and failover)
  • Subnets - (**Improving network performance and enhancing security)
  • Nat gateway - (Communication between resources in a private subnet)
  • Elastic load balancer - (Load c, Auto Scaling & Health Monitoring)
  • EC2 instance - (Provides scalable computing capacity in the AWS cloud)
  • EC2 auto scaling - (Adjusts no.of.instance based on demand)
  • Amazon RDS - (Database)
  • Amazon CloudWatch-(Triggers Alarm when CPU utilization increase / decreases)

Animated architecture :

💻 Local setup :

➡️ I am using VS CODE as my code editor because it's incredibly flexible and smooth in terms of development experience.

➡️ INSTALL TERRAFORM : click here

➡️ Now make your work more easier , We are going to download the Terraform extension - (HashiCorp Terraform) .

➡️ AWS CLI : We are going to install aws-cli to use the aws functionally from your system terminal : click here

Now , we have installed all the required software and tools. let's move on into aws cloud.

🗝️Aws iam security key :

create USER :

  • In the search type ➡️IAM ➡️ user ➡️ add users
  • Enter the name of the user ➡️ attach policy - administrator access "it's not a best practice to use this policy because it gives full access to all resources in AWS account" but as a common practice for accessing all aws service attach a policy - principle of least privilege or use the policy based on the resource you use.
    • Now create ➡️ access key and download the key.file , once you close the window you will you may lose the credentials and remember do not share access key credential.AWS CLI :
    • Now open the terminal and type - aws configure , enter the access key and secret key details , enter the output format - json and default region - us-east-1 (use the preferable region)

      Creating terraform code :

      • First we need create a folder and open the folder in VS CODE then create a variable.tf and copy this code.
      • Remember, always mention the latest terraform version , preferable region.

COPY

        terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.0"
}
}
}

# Configure AWS Provider
provider "aws" {
region = "us-east-1"
}
  • Please visit my Github repository for to source code , here you can find the full details to execute all the code.THEN EXECUTE THESE COMMAND ON THE TERMINAL
    • press ➡️ yes , it will prompt you for approval..

Github link :

💻 OUTPUT :

  • Now open the aws console , let's see what Terraform created on our AWS console.
  • VPC
  • SUBNET
    • ROUTE TABLE
    • IGW
  • EC2 instance
  • AUTO-SCALING
    • RDS
      • yes 🥳, we have completed the project and thanks for reading the blog before we end-up...

TYPE ➡️terraform destroy --auto-approve:to destroy the resources provisioned through terraform.Don't forgetto run this command, it will delete the resources you created.

GITHUB RESPORITORY LINK : https://github.com/JOHNPAUL548/2-tier-terraform

GITHUB PROFILE LINK : https://github.com/JOHNPAUL548

LINKEDIN LINK : https://www.linkedin.com/feed/update/urn:li:activity:7097984323852652545/

0

0

0

More Articles

Showwcase is a professional tech network with over 0 users from over 150 countries. We assist tech professionals in showcasing their unique skills through dedicated profiles and connect them with top global companies for career opportunities.

© Copyright 2025. Showcase Creators Inc. All rights reserved.