Deploying Jenkins On AWS EC2
Running an EC2 instance and deploying a real world Application and accessing it.
In this post, I will walk you through some basics of EC2 and we will also be deploying a real-world Application to AWS EC2 instances.
I would also like to mention that, this tutorial is completely beginner-friendly so we will be using the less complex methods to run our EC2.
We will be using only the free tier resources.
Pre-requisites
There are a few pre-requisites to follow along the steps
You must have an AWS account
If you are on a Windows machine make sure you have an ssh terminal
What is EC2?
Amazon’s Elastic Compute Cloud (AWS EC2) is a cloud-based service that provides virtual machines, called “instances”, to run applications on Amazon Web Services. These instances allow developers and organizations to scale their software, reduce their maintenance costs, and increase their security and network configuration and storage as per demand.
All these can be done without the need to set up their own data centers, so nowadays most organizations are shifting toward cloud-based services.
Launching an AWS EC2 Instance
I will guide you through the complete steps to launch your first EC2 Instance, make sure you follow along correctly and don't skip any steps or you might get in trouble.
Step 1: Go to AWS Account and Search for EC2 , click on EC2 and you will be redirected to another page.
Step 2: Tap on 'Launch Instance' button.
Step 3: After you Press the 'Launch Instance' button you have to add a name for your Instance
Step 4: Choose 'Ubuntu' Application and OS Image Dropdown
Step 5: Select 't2.micro' from Instance type
Step 6: Create new key pair
Step 7: Name anything of your choise for 'Key Pair' and hit 'Create key pair' and then the key pair will be downloaded to your machine.
Step 8: And leave everything as it is and tap on 'Launch Instance'
Step 9: Now head over to your EC2 dashbard and tap on Instances and all your running instances will be visible there
Step 10: Setting up inbound rules, Tap on the 'Security' tab and then tap one launch wizard.
Step 11: Add a new rule
Type: Custom TCP, Port range: 8080, Source : Anywhere IPv6
Hit save rule!
SSH to Your Running EC2 Instance
You might remember after the step 7 a .pem file was downloaded to your machine. It might be in your Downloads folder.
Open a terminal in your Downloads folder and enter the following command, and replace the name of the key to whatever you named your key while following the step 7
chmod 400 key1.pem
Now enter the following command and replace the key.pem name according to your file and also the ip address, you can find you Ipv6 address in you
EC2 Dashboard > running instances
ssh -i key.pem ubuntu@44.211.81.217
Installing Jenkins On EC2 Instance
Run the following command on your terminal
sudo apt update
sudo apt install openjdk-11-jdk
curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee \
/usr/share/keyrings/jenkins-keyring.asc > /dev/null
echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
https://pkg.jenkins.io/debian-stable binary/ | sudo tee \
/etc/apt/sources.list.d/jenkins.list > /dev/null
sudo apt-get update
sudo apt-get install jenkins
Now your Jenkins should be up and running
link: 44.211.81.217 IPv6:8080
http://44.211.81.217:8080 / Replace the ipadress with your ipv6 address. and add :8080 after the IP