Jenkins in AWS

Here are steps to launch a Jenkins instance on AWS EC2 in quickest way possible.

Login to AWS management console and under EC2 service, click launch instance and select following configurations

  1. Amazon Machine Image : Amazon Linux 2 AMI (HVM), SSD Volume Type
  2. Instance Type: t2.micro
  3. Keep the default values in “Configure Instance Details”. Under advance script, add below bash script to install and launch jenkins with the aws instance
    #!/bin/bash
    wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo  
    rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key
    yum install -y java jenkins
    chkconfig --add jenkins
    systemctl start jenkins
    
  4. Skip add storage
  5. Add Tags if needed
  6. Configure Security Groups as follows. (Select source as “My IP” for ssh. Add rule for port 8080) placeholder
  7. Review and launch (select existing keypair or create a new keypair to connect to the instance)

Once the instance is launched, get the public DNS for the aws instance. Jenkins instance can be accessed via “Public_DNS”:8080

When Jenkins gets started it will ask for administrator password to unlock jenkins. Password can be retrieved by login into the aws instance.

# Connect to the instance
ssh -i <key_name>.pem ec2-user@<aws instance>

# Get the password
sudo /var/lib/jenkins/secrets/initialAdminPassword