3-Tier Architecture (Part-6)

3-Tier Architecture (Part-6)

Publish Date: Mar 28
0 0

AWS Three-Tier Architecture - Part 6

Table of Contents


Update Config File

Before creating and configuring the web instances, open the application-code/nginx.conf file from the repository we downloaded.
Image description

  1. Scroll down to line 58 and replace [INTERNAL-LOADBALANCER-DNS] with your internal load balancer’s DNS entry.
  2. You can find this DNS by navigating to your internal load balancer's details page.
  3. Copy the DNS Name and replace it in your nginx.conf file.
  4. Upload this file and the application-code/web-tier folder to the S3 bucket you created for this lab.

Web Instance Deployment

  1. Navigate to the EC2 service dashboard and click on Instances on the left-hand side.
  2. Click Launch Instances.
  3. Select the first Amazon Linux 2 AMI.
  4. Choose the T2.micro instance type (free tier eligible) and click Next: Configure Instance Details.
  5. Proceed without a key pair since we'll use EC2 Instance Connect.
  6. Configure the instance details:
    • Select the correct Network, Subnet, and IAM role.
    • Use a private subnet for this app layer.
    • Enable Auto-assign Public IP.
    • Attach the Web Tier Security Group.
    • Assign the pre-created IAM Role.
  7. Click Launch Instance.

Connect to Instance

  1. Navigate to EC2 Instances.
  2. Once the instance state is running, select the instance and click Connect.
  3. Select the Session Manager tab and click Connect.
  4. A new browser tab will open.
  5. Test internet connectivity by running:
   sudo -su ec2-user
   ping 8.8.8.8
Enter fullscreen mode Exit fullscreen mode

Configure Web Instance

Install Node.js

  1. Install NVM (Node Version Manager) and Node.js:
   curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
   source ~/.bashrc
   nvm install 16
   nvm use 16
Enter fullscreen mode Exit fullscreen mode

Download Web Tier Code

  1. Navigate to the home directory and download the web-tier code from the S3 bucket:
   cd ~/
   aws s3 cp s3://BUCKET_NAME/web-tier/ web-tier --recursive
Enter fullscreen mode Exit fullscreen mode
  1. Navigate to the web-tier folder and build the React app:
   cd ~/web-tier
   npm install
   npm run build
Enter fullscreen mode Exit fullscreen mode

Install and Configure NGINX

  1. Install NGINX:
   sudo amazon-linux-extras install nginx1 -y
Enter fullscreen mode Exit fullscreen mode
  1. Navigate to the NGINX configuration directory:
   cd /etc/nginx
   ls
Enter fullscreen mode Exit fullscreen mode
  1. Remove the existing nginx.conf file and replace it with the one from S3:
   sudo rm nginx.conf
   sudo aws s3 cp s3://BUCKET_NAME/nginx.conf .
Enter fullscreen mode Exit fullscreen mode
  1. Restart NGINX:
   sudo service nginx restart
Enter fullscreen mode Exit fullscreen mode
  1. Ensure NGINX has the necessary permissions:
   chmod -R 755 /home/ec2-user
Enter fullscreen mode Exit fullscreen mode
  1. Enable NGINX to start on boot:
   sudo chkconfig nginx on
Enter fullscreen mode Exit fullscreen mode

Conclusion

I hope this guide helped you through the AWS three-tier architecture implementation! 🚀

Continue to the next Part 🔗 Access Part 7 here: AWS Three-Tier Architecture (Part-7)

Comments 0 total

    Add comment