Launch your AMIs using the ec2-run-instances command, supplying your data using either the -d or -f flag:
$ ec2-run-instances ami-5bae4b32 -d "My data goes here" -k gsg-keypair
RESERVATION r-fea54097 598916040194 default
INSTANCE i-10a64379 ami-5bae4b32 pending gsg-keypair 0
Check whether your instance is running:
$ ec2-describe-instances i-10a64379
RESERVATION r-fea54097 598916040194 default
INSTANCE i-10a64379 ami-5bae4b32 domU-12-34-31-00-00-05.usma1.compute.amazonaws.com running gsg-keypair 0
Once your instance is running, log in using ssh:
$ ssh -i id_rsa-gsg-keypair root@domU-12-34-31-00-00-05.usma1.compute.amazonaws.com
Welcome to your Linux 6.4.21 node
Half a mind is a terrible thing to waste.
#
Retrieve the data you supplied when launching the AMI:
# curl http://169.254.169.254/1.0/user-dataMy data goes here
Retrieve instance-specific metadata:
# curl http://169.254.169.254/1.0/meta-data/ami-idami-5bae4b32
# curl http://169.254.169.254/1.0/meta-data/ami-manifest-path<your-s3-bucket>/getting-started.manifest.xml
# curl http://169.254.169.254/1.0/meta-data/ami-launch-index0
# curl http://169.254.169.254/1.0/meta-data/instance-idi-10a64379
# curl http://169.254.169.254/1.0/meta-data/hostnamedomU-12-34-31-00-00-05.usma1.compute.amazonaws.com
# curl http://169.254.169.254/1.0/meta-data/local-ipv4216.182.234.123
# curl http://169.254.169.254/1.0/meta-data/reservation-idr-fea54097
# curl http://169.254.169.254/1.0/meta-data/security-groupsdefault
More details about this feature can be found in the “Using Instance Data” section of the Developer Guide.