Sunday 2 July 2017

Bootstapping configuration while launching EC2 instances

In this brief article I'll be deomnstrating how we can add or bootstrap a custom configuration script/file while launching our EC2 instances.

This feature is particularly helpful when we want to deploy instances belonging to a certain application and want to customize the instances to the needs of the application during the instance launch process.

Since the primary focus of the article is to demonstrate using bootstrap scripts I will not be diving deep into instance launch configuration.

To get started, from the EC2 dashboard click on launch instance.



Next we'll be asked to choose an AMI. I'll select the Amazon Linux AMI for this demo.



I'll select an instance type and go for free tier.



Now we are brought to the instance configuration screen. Here we can type in or modify the network information for our instance and this is where we'll add our bootstrap file.

In the Configure Instance Details section expand the Advanced details drop down.

Here we see a user data section. This is where we type in our desired actions to be performed post instance launch.

For testing purpose, I've created a script which will install apache and create a file named testfile.txt in the /var/tmp directory and have the words "creating a test file".


The configuration done so far is enough for this demonstration so now I'll just click on reivew and launch.


From here just click on launch instance.

Now after launching my instance I logged into it using it's public IP and the key pair I generated for authntcation.

When I looked for the file and httpd package, both items were found as shown below.



I used a very simple script for this demonstration. You could get very creative and add installation of multiple packages, configuration file updates or even patching the VM via "yum update" in your bootstrap scripts.

I hope this article would prove to be of help to use and I thank you for reading.

1 comment:

  1. Thanks for providing such a wonderful information, keep updates with us, Get more knowledge on AWS Online Training India Get More Knowledge

    ReplyDelete

Using capture groups in grep in Linux

Introduction Let me start by saying that this article isn't about capture groups in grep per se. What we are going to do here with gr...