Saturday, May 16, 2020

How To Use BootStrap Scripts in AWS EC2 Instance during Launch - Running commands on your Linux instance at launch | How to Run commands on your Linux instance at launch

What is bootstrap script in aws?

if you want to execute some commands during boot up(also launch), you can execute it easily by mentioning during step 3 of EC2 launch. Bootstrap scripts run only once - when the instance is instantiated for the 1st time.

Please follow the below steps to create an EC2 instance.  We will be installing Java, Maven, Jenkins and Apache during boot up.

Steps to add bootstrap script during EC2 launch

1: Go to AWS console. click on All services, Click on Compute -->  Click on EC2



2. Click on Launch instance. Choose an Amazon machine image (AMI), click next

3. select Ubuntu Server 18.04 LTS (HVM), SSD Volume Type


click next
4. choose an instance type as t2.small, 2GB memory. click next

5. in step 3, go down, under advanced details.  Copy the script
from this link.

6. Now continue like how you provision EC2 instance.
7. once you provision, you will be able to see Java, Maven and Jenkins installed in EC2 instance after launch.

Check the Logs in EC2 instance

Login to EC2 instance, and type the below command:

tail -f /var/log/cloud-init-output.log

This will give the output of bootstrap execution

Verify if Java got installed.

java -version
mvn --version


Go to the browser and try to access Jenkins in the browser, Jenkins should be coming up.(make sure you open port 8080 in the firewall rules)

Java, Maven and Jenkins should be installed successfully.


No comments:

Post a Comment

DevOps Bootcamp Aug 2024 Schedule | DevOps & AWS Azure Cloud Coaching by Coach AK | DevOps and Cloud Computing Online Classes

  (Lot of new topics covered like GitHub Actions, Helm and Monitoring..) The DevOps requirements in the IT market space is expected to grow ...