Step 1: Set Up Prerequisites
In this step, you need to ensure that you possess an Amazon Web Services account, an Amazon Web Services Identity and Access Management user name and password, an Amazon Elastic Compute Cloud key pair, and a configured Virtual Private Cloud (VPC).
Step 2: Launch an Elastic Compute Cloud Instance
There, we guide you with the steps for hosting Jenkins. The virtual servers that help to host Jenkins are called Elastic Compute Cloud instances. Please feel free to follow the below-mentioned steps:
Create a Security team for Your Amazon EC2 Instance
A security team controls the traffic allowed to succeed in EC2 instances. When you launch an instance, you give it to the security teams and add rules for every security team. One thing to keep in mind is that you can just modify the principles for security team whenever you want.
Steps to create and configure your security group:
- You should choose an IP address. To find your IP address, use the checkup service from Amazon Web Services. If you’re connecting through ISP, you will come to know about the variety of internet protocol addresses.
- Now, you should open the Amazon EC2 console.
- Within the navigation bar, you should ensure that you choose the US West area.
- In the left-hand navigation bar, you should select Security Groups, and then, should click Create Security Group.
- In the Security group name, you should enter WebServerSG and should provide a description.
- You should choose your VPC from the list.
- On the Inbound tab, you should add the rules
- And at last, you should click Create.
Launch Your EC2 Instance
- In the Amazon EC2 console’s left-hand navigation bar, you should opt for Instances, and then, should click Launch Instance.
- On the Amazon Machine Image page, you should select Free tier only and then, should select an Amazon Linux AMI with the HVM virtualization type.
- On the sort page, the t2.micro instance is selected by default. You should make this instance sort to stay within the free tier.
- Click Next: Configure Instance Details.
- On the Review Instance Launch page, you should click Edit security teams.
- On the Configure Security Group page, you should select an existing security group, select the WebServerSG security group that you created.
- Now, you should click the Review and Launch.
- On the Review Instance Launch page, you should click Launch.
- In the Select an existing key pair or create a new key pair dialogue box, you should select an existing key pair and then, should select the key pair you created while setting up to Host Jenkins on Amazon Web Services.
- Now, you should click the acknowledgement checkbox, and then, should click Launch Instances.
- In the left-hand navigation bar, you must choose Instances to see the status of your instance.
Step 3: Install and Configure Jenkins
In this step you’ll deploy Jenkins on your EC2 instance by finishing the subsequent tasks:
Connect to Your Linux Instance
After the launching phase, comes the connecting phase. But, before you connect with your instance, get the general public DNS name of the instance.
The tool that you just use to attach to your Linux instance depends on the software system running on your laptop. If your computer runs Windows, you will connect using PuTTY. If your computer runs Linux or Mac OS X, you will connect using the SSH client. These tools need the usage of your key pair. You should make sure that you just created your key pair as delineated in producing a Key Pair.
To Connect to Your Linux Instance from Windows using PuTTY
- From the Start menu, you should select All Programs > PuTTY > PuTTY.
- Within the class pane, you should choose Session, and complete the given fields.
- Within the class pane, you should expand Connection, SSH, and then, must select Auth.
- If this is the first time, you have to connect with this instance, PuTTY displays a security alert dialogue box that asks whether you trust the connected host or not. You should click Yes. Then, a window will open.
And you’re done!
To Connect to Your Instance from Linux or Macintosh OS X victimization SSH
1. Use the ssh command to connect to the instance. After that, you will see a response like the following:
Are you sure you wish to continue connecting?
2. Enter yes.
You will see a response like the following:
Warning: forevermore added ‘ec2-198-51-100-1.compute-1.amazon.
Amazon Web Services.com’ (RSA) to the list of identified hosts.
Download and Install Jenkins
To download and install Jenkins follow these steps:
1. To confirm that your code packages are up to date on your instance, use the command to perform a fast code update.
2. Add the Jenkins repo.
3. Bring in a key file from Jenkins-CI to enable installation from the package:
4. Install Jenkins
5. Start Jenkins as a service
After the installation phase, comes the configuration phase.
Let’s see together how to configure Jenkins!
1. Connect to http://:8080 from your favourite browser.
2. As prompted, you should enter the password.
3. The Jenkins installation script navigates you to the Customise Jenkins page. There, you should click Install suggested plugins.
4. After the installation, you need to enter Administrator Credentials, should click Save Credentials, and then, you need to click Start Using Jenkins.
5. On the left-hand, you should click Manage Jenkins, and then, should click Manage Plugins.
6. You should click on the Available tab, and then, should enter the Amazon Elastic Compute Cloud plugin at the top right.
7. You should choose the checkbox next to the Amazon Elastic Compute Cloud plugin, and then, should click Install without restart.
8. Once you are done with the installation, you need to click Go back to the top page.
9. You should click on Manage Jenkins, and then, should configure the system.
10. You must scroll all the way down to the Cloud section.
11. Click Add a new cloud, and, should select Amazon Elastic Compute Cloud. A collection of new fields appears.
12. Now, you must fill all the fields.
Congratulations! Great Job!
Step 4: Clean Up
After completing these steps, you should delete the existing AWS resources, so that, you do not continue to accrued charges.
Delete Your EC2 Instance
1. Within the Amazon EC2 console’s left-hand navigation bar, you need to select Instances.
2. You should click on the instance you created earlier and choose Instance State > Terminate.