home..

Deploy Java Application On Aws 3 Tier Architecture

3-Tier-Architecture

STEP ONE: Global AMI

We are going to create a Global AMI with the following installations

Go to AWS Console, Search for EC2 on the searchbar and click on instances. Launch an instance with default settings. Make sure to create a key pair. image

SSH Into the instance to install

Install AWS CLI

Navigate to the Official AWS documentation and follow the instructions given to install AWS CLI depending on the operating system you are using

How to Install or update to the latest version of the AWS CLI

image

image

Install Cloudwatch agent

Navigate to the Official AWS documentation and follow the instructions given to install CloudWatch Agent

How to Install the CloudWatch agent

image

Install AWS SSM agent

Navigate to the Official AWS documentation and follow the instructions given to install AWS SSM agent

How to Manually install and uninstall SSM Agent on EC2 instances for Linux

image

Creating AMI from the instance

Navigate back to the instance dashboard and click on the instance. Go to actions then images and templates then to create image

image

STEP TWO: Create Golden AMI using Global AMI for Nginx application

Launch an instance using the Global AMI we created, by navigating to AMIs selecting the Global AMI then selecting Launch instance from AMI image

SSH into the instance so as to:

Install Nginx

Navigate to the Official Nginx Website and check on the documentation to install Nginx on the Instance

How to Install nginx on Amazon Linux 2023

Push custom memory metrics to Cloudwatch

How to push custom metrics to CloudWatch

You can use SSM to install the CloudWatch agent then use the wizard to write the configuration file

sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-config-wizard

After you have finished with the configuration, start the cloudwatch agent with

sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:configuration-file-path -s

Your configuration file path is listed after finishing the configuration with the wizard

STEP THREE: Create Golden AMI using Global AMI for Apache Tomcat Application

Use the AMI created to launch another instance.

SSH into the instance so as to:

Install Apache Tomcat

You can use the instructions from the official AWS Website

How toInstall Apache Tomcat

To Configre Tomcat as Systemd service Step1: Create the systemd file: nano /etc/systemd/system/tomcat.service Step2: Copy

[Unit]
Description=Apache Tomcat
After=network.target

[Service]
Type=forking

User=tomcat10
Group=tomcat10

ExecStart=/opt/apache-tomcat-10.1.28/bin/startup.sh
ExecStop=/opt/apache-tomcat-10.1.28/bin/shutdown.sh

From now on, you can use following commands to start or stop the tomcat:

sudo service tomcat start
sudo service tomcat stop

Install JDK 11

How to install Java 11 on Amazon Linux 2023

Push custom memory metrics to Cloudwatch

How to push custom metrics to CloudWatch

You can use SSM to install the CloudWatch agent then use the wizard to write the configuration file

sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-config-wizard

After you have finished with the configuration, start the cloudwatch agent with

sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:configuration-file-path -s

Your configuration file path is listed after finishing the configuration with the wizard

STEP FOUR: Create Golden AMI using Global AMI for Apache Maven Build Tool

© 2024 Kennedy Njuguna   •  Powered by Soopr   •  Theme  Moonwalk