Parameterized Launches

Note:

This feature is supported from API version 2006-10-01 and its supporting command-line tools.

Introduction

This feature allows you to supply additional data to instances at launch time. This data, in addition to standard instance-specific metadata, is made available to those instances.

Example usage

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-data
My data goes here

Retrieve instance-specific metadata:

# curl http://169.254.169.254/1.0/meta-data/ami-id
ami-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-index
0
# curl http://169.254.169.254/1.0/meta-data/instance-id
i-10a64379
# curl http://169.254.169.254/1.0/meta-data/hostname
domU-12-34-31-00-00-05.usma1.compute.amazonaws.com
# curl http://169.254.169.254/1.0/meta-data/local-ipv4
216.182.234.123
# curl http://169.254.169.254/1.0/meta-data/reservation-id
r-fea54097
# curl http://169.254.169.254/1.0/meta-data/security-groups
default

Note:

More details about this feature can be found in the “Using Instance Data” section of the Developers Guide.