This is a continuation to CI-CD setup , refer previous step Part One


Setup a build server to run project, when trigger from Jenkins. Will use aws elastic beanstalk to execute through build server

 

First will setup a IAM role, navigate to IAM dashboard on aws console. And Click on the roles.


Select the Create role


Select the AWS service, and click on the Next Permissions



Search beanstalk in the box and select, AdministratorAccess-AWSElasticBeanstalk, and click on the Next Tags



Set tag name as build-server, and click on the review



Set the description and name, and click on Create role



Then can see a new role with name build-server has been created



Now will create a new Security Group for another instance (build-server).  Set the inbound role with SSH and select the Jenkins-master group


Click on the next, a new group will get created



Next create a new Key pair for build server to connect with the ssh, in this case, Jenkins server will connect with the build server. Download the.pem file and save it for later reference


Create a new instance for build server. This time will select Amazon Linux image


Instance type as same t2 micro



Configure the instance details

And set the IAM role, as we created in earlier steps , so select the build-server role which we created


Click on the advance details

And in User data section , paste the below details

#!/bin/bash

# install dependencies

yum -y group install "Development Tools"

yum -y install \

        bzip2-devel.x86_64 \

        java-11-amazon-corretto-headless \

        libffi-devel \

        ncurses-devel \

        openssl-devel \

        python3 \

        nodejs14 \

        readline-devel.x86_64 \

        sqlite-devel.x86_64 \

        zlib-devel

# install the elastic beanstalk CLI

curl -O https://bootstrap.pypa.io/get-pip.py

/usr/bin/python3 get-pip.py

/usr/local/bin/pip3 install awsebcli



Next keep the default storage



Add the tags and give the name build-server



Select the security group


And click on the review and launch


Click on Launch, and select the created .pem file build-server



On Launch instance, a new instance will be created



Select on the build-server instance, gives all information





Please refer the previous steps to configure Jenkins on the AWS EC2 instance. This is a continuous of the CI CD process . Refer the Part One | Part Three