Extracting your user and meta data from AWS

To make our lives easier as cloud system administrators, we can automate the creation of instances. We can also automate the installation of applications & code on those instances.

Each instance includes meta data (which is shown in the details pane of your EC2 dashboard).

Launch a new instance

Enable public IP

Click advanced details

In here type: # bin/bash touch /root/test1 yum install -y httpd service httpd startWhat this will do is it will touch the file ‘test1’ and then install apache httpd server & set it running.

Launch your instance

type in ‘sudo su-‘ to run as a root user

type: cd cs /root lsHere you should see test1 as a response (as per your bash script instructions)

Next, open ‘security groups’

Edit the inbound rules on the security group to enable HTTP

You can view meta data curl http://169.254.169.254/latest/meta-dataThis gives you all the meta data about the instance. You can search a piece of meta data by just adding to the end of that statement. e,g, /public-ipv4

You can also see the user data and the scripts passed at launch curl http://169.254.169.254/latest/user-data

You can set your automated code to download code from a git repository and install multiple applications. This can also be applied to multiple servers at once (e.g. you could launch 10 servers sharing the same config).

The cloud.cfg file (found in etc/cloud) holds the configuration for the system. This runs at instance creation, not at instance start.