Cloud Init(AWS)
What is cloud-init and Why is it so cool?
Cloud-init is a software package that automates the initialization of cloud instances during system boot. System can be configured at the boot time only. Setting up new cloud instances can be very time-consuming, especially if you are dealing with a lot of configurations and software. With cloud-init, you’ll never have to worry about this ever again.
Cloud-init is a software developed for cloud server instances that will set up the server automatically using the provided metadata. This metadata describes how your server should look like, e.g. which packages should be installed and commands that’ll be executed on init.
Ever image provided by aws has cloud-init programme which comes into action when we boot os. Their are some cases when we want to perform task at the boot time . For Example : download anything , run scripts etc .
Every operating system has its own met-data server it contains
entire information about the operating system .
user-data .
Instance metadata and user data
Instance metadata is data about your instance that you can use to configure or manage the running instance. Instance metadata is divided into categories, for example, host name, events, and security groups.
You can also use instance metadata to access user data that you specified when launching your instance. For example, you can specify parameters for configuring your instance, or include a simple script. You can build generic AMIs and use user data to modify the configuration files supplied at launch time.
Launch instance in EC2 :
While launching the instance go to advanced details and then to the user data :
After connection to instance we will able to see the directory we have created at the boot time :
To see boot file in linux :
cd /var/log/
ls
Connect to met-data server:
curl http:/ip/latest
How to change the user data after the instance has been launched ?
Go to EC2 instance (to edit user-data first stop the instance)
Go to Actions
Go to instance Setting
Edit user-data .