Introduction
Amazon Web Services (AWS) provides powerful tools for managing cloud infrastructure, including Identity and Access Management (IAM) for security, EC2 for virtual servers, and Jenkins for continuous integration and deployment (CI/CD).
This guide will walk you through:
Creating an IAM Group and assigning permissions.
Adding Users to the group for secure access.
Launching an EC2 Instance to host Jenkins.
Installing and Configuring Jenkins for automation.
By the end, you'll have a fully functional Jenkins server running on AWS with proper IAM security controls.
Part 1: Setting Up AWS IAM
Step 1: Creating an IAM Group
- Login to your AWS Management Console
- Search for IAM (identity and Access Management) and click on it
- Click on Group
- Click new group
- Name your Group (e.g Jenkins-admin)
- Click on next Step 2: Assigning Permissions to the Group
- In the attached policy section, select AmazonEC2FullAccess (this is for managing EC2 instances)
- You can equally select IAMReadOnlyAccess (this is for viewing IAM settings, it is optional)
- Click on next, then click on create group
Step 3: Creating and Adding Users to the Group
- Navigate to your IAM and click on Users
- Click add Users
- Name your User
- Enable provide User Access to AWS console
- Choose I want to create IAM User
- Enable autogenerated password (reason is that, the User can change their password)
- Scroll down and enable User must create a new password
- click next: permissions
- Select add User to Group and choose the Group you want to add the User to
- Click next, and next
- Then click create User
- Copy the user's login details before closing that page. Send the User his/her details
Part 2: Launching an EC2 Instance for Jenkins
- Navigate to your AWS Management Console
- Search for EC2 instances and click on it
- Click on launch instance
- Name your instance
- I'm choosing Ubuntu server
- Choose your instance type ( I'm choosing t2.micro free tier eligible)
- Beside key pair name, click on create new key pair
- Choose RSA
- In key name, name it anything (e.g aws-login)
Note: this key pair is an encrypted SSH key. It has a public key and a private key that is automatically generated by AWS for you.
- Click on create key pair
- Then, under the key pair drop-down menu, choose the key pair you just created (this is your public key)
- Leave the configuration storage at T×8, GB gp2
- Click on launch instance
Step 2: Connecting to the EC2 Instance
- If you are connecting with AWS CLI or Powershell, then open it and login in with this command. ssh -i your key pair name Ubuntu@your EC2 public IP address
Note: Your key pair ends with .pem and it is located at your downloads in your laptop. That is your private key.
- Once you are in, type chmod 600 your key pair.pem SSH -i your key pair.pem Ubuntu@your EC2 public IP address
- If you are login in with mobaxterm (also known as putty)
- Open your mobaxterm
- Click on session in the top left
- Select SSH
- Put the public IP of your EC2 where you see remote host
- Enter the name of your EC2 where you see Username
- Leave the default port (unless you have a port you want to access)
- Click on advance settings
- Check the box next to "use private key"
- Select your key pair.pem
- Click on Ok to save
- Click on Ok again to connect to your instance.
- Once you are logged in, type sudo apt update ( this is to update your instance)
Part 3: Installing and Configuring Jenkins
To install Jenkins, we need to install Java firstly because Jenkins is a Java-based application, and it requires a Java Runtime Environment (JRE) to run.
- After doing sudo apt update
- Next is to type sudo apt install openjdk-17-jdk -y, then hit enter
Note: 17 is the latest version of Java. -y means yes.
- Type Java --version (to see the Java version installed.
Step 2: Adding Jenkins Repository & Installing
- You can go to your browser and search for how to install Jenkins in Ubuntu, copy the command and paste it in your instance you are working on, then hit enter
- Or you can simply type sudo apt install Jenkins -y then hit enter
- Type sudo systemctl start Jenkins (to start the Jenkins)
- Type sudo systemctl enable Jenkins
- Check if the Jenkins is running by typing systemctl status Jenkins, hit enter
- Note: Jenkins runs on port 8080 by default
Let's set security group
- Go back to your AWS Management Console
- Navigate to your EC2
- Click on the instance ID
- Scroll down to security and click on it
- Click on security group
- Click on edit inbound
- Click on add rule
- Choose custom TCP
- Under port range, put 8080 (you can still change the port. It's not security wise to use default port)
- Under source, click on the drop-down box and select anywhere IPV4 (or customize it)
- Save rule
Step 4: Accessing Jenkins Web Interface
- Go to your browser, paste your EC2 public IP address:8080, hit enter
- Copy the command you see once you enter ( the link should look like this /var/lib/Jenkins/secrets/initialAdminpassword
- Go to your instance you are working on, type cat and paste it command without space please
- Copy the password generated once you hit enter
- Go back to your browser where you logged in your Jenkins, paste the password
- Click on connect
- Create an Admin User
- Select install selected plugins
- And woolla, we have successfully installed our Jenkins application
Conclusion
You’ve successfully:
- Created an IAM Group with proper permissions.
- Launched an EC2 Instance optimized for Jenkins.
- Installed and Configured Jenkins for CI/CD automation.
I hope you will try this steps and give me a feedback.
From your favorite girl, Dabbie 😘
Top comments (1)
Some comments may only be visible to logged-in visitors. Sign in to view all comments.