Automated Startup – AWS EC2 Instance – Metadata & Userdata

EC2 Instance Metadata and Userdata
Self Configuration can be done with instance metadata and user data. This allows EC2 instance to answer the question “Who am I?” What should I do?
You can access instance metadata and user data from within the instance.
Data is not protected with cryptographic or authentication methods. Anyone with access to the instance can see its metadata. However, sensitive data such as passwords and user data should not be stored.
Both metadata and user data are available at the IP address with the most recent and older versions.
Metadata and User data can easily be retrieved with simple curl or the GET command. These requests are not billedInstance Metadata
Instance metadata is information about an instance that allows you to answer the Who am I? question.
It can be divided into two categories: Instance metadata includes metadata about the instance like instance id and AMI ID, hostname, role, ip address, etc
Can be accessed from
When the instances are launched, dynamic data is generated such as instance monitoring, instance identity documents, and instance monitoring.
Can be accessed from
It can be used to manage and configure running instances
Allows access to user data specified at the time of launching the instanceUser Data
The user data can be used to bootstrap (launch commands when the machine is started) EC2 instance. It also helps answer the question, What should I do?
This information is required to launch an EC2 instance. It is then executed at boot time
These can be in the form parameters or user-definable scripts that are executed when the instance launches, for example. Perform software patch updates, load the application from an S3 bucket, etc
can be used to create more generic AMIs that can then be configured dynamically at launch time
can be retrieved from
By default, user data commands and cloud-init directives are not executed during the first boot cycle after an EC2 instance launches.
You can stop an instance, modify user data, and then restart it. However, the new user information is not executed automatically.
A mime multi-part files can be used to configure user data scripts and cloud-init directives. A mime multipart file allows scripts to control how often user data is executed by the cloud-init package.
It is returned as is and treated as opaque data.
The limit is 16 KB. This limit applies to data in raw form and not base64-encoded.
Before being submitted to the API, must be base64-encoded. The base64 encoding is performed by the EC2 command-line tools. The data is decoded prior to being presented to the instance. Cloud-Init & Ec2Config
Cloud-Init and EC2Config allow you to run the instructions and parse the user data script on the instance
Cloud-InitAmazon Linux AMI supports Cloud Init, which is an open-source application created by Canonical.
It is installed on Amazon Linux, Ubuntu, and RHEL AMIs
This parameter allows you to specify actions that will be run on the instance at boot by using the EC2 userData parameter
If the user data begins with #, then Cloud-Init executes the user data on the first boot.
EC2ConfigEC2Config can be installed on Windows Server AMIs
If the user data starts with, the Cloud-Init process executes the user data on the first boot.
The EC2Config service starts when the instance boots. It performs tasks at initial instance startup (once), and every time you stop and restart the instance.
It can also perform tasks upon request. Some tasks can be done automatically, while others need to be activated manually.
Uses settings files to control the operation
Sysprep is a Microsoft tool that allows you to create a customized Windows AMI that can then be reused.
When EC2Config calls Sysprep, it uses the settings files in EC2ConfigService\Settings to determine which operations to perform. AWS Certi