ec2-run-instances
ec2-run-instances AMI [-n INSTANCE_COUNT] [-g GROUP [-g GROUP ...]] [-k KEY] [-d USER_DATA | -f FILE_NAME] [ --addressing ADDRESSING_TYPE]
Launches one or more instances of the specified AMI. Optional parameters include
-
A security group. New instances will be launched in this group. If no group is specified instances are launched in the
default
group. -
A keypair name. The public key associated with this keypair name will be made available to the instances at boot time.
-
User data. This data will be made available to the launched instances. See using instance data for more info.
-
Addressing type. This specifies if the instance will have a NATted address or not. See Chapter 4, Using and Securing the Network for more information on instance addressing.
If the AMI has a product code attached for which the user has not subscribed, the ec2-run-instances call will fail.
A table containing the following information is returned:
-
Output type identifier ("INSTANCE")
-
Instance ID which uniquely identifies each running instance.
-
AMI ID of the image the instance is based on.
-
DNS name associated with the instance (only present for instances in the
running
state). -
Instance state. This will in most cases be
pending
which indicates that the instance is being prepared for launch. -
Key name. If a key was associated with the instance at launch it's name will be displayed in this column.
Errors are displayed on stderr.
Option | Definition | Required? | Example | |||
---|---|---|---|---|---|---|
-n INSTANCE_COUNT
|
The number of instances to launch. If
not specified, a value of
1 will be assumed. If it
is not possible to launch at least this many
instances (due to a lack of capacity or
funds), no instances will be launched. If
specified as a range (min-max) Amazon EC2 will
try to launch as many instances as possible,
up to max, but will launch no fewer than min
instances.
|
No | -n 5 | |||
-g GROUP
|
The security group(s) within which the instance(s) should be run. This determines the ingress firewall rules that will be applied to the instances. By default instances will run in the user's default group. If more than one group is specified, the security policy of the instances will be the union of the security policies of the specified groups. | No | -g fooGroup | |||
-k KEY
|
The keypair to make available to these instances at boot time. | No | -k fooKeyPair | |||
-d USER-DATA
|
The data to make available to these instances. The
data is read off the command line from the USER_DATA
argument. If you want the data to be read from a
file see the -f option.
|
No | -d "my user data" | |||
-f FILE_NAME
|
The data to make available to these instances. The data
is read from the file specified by FILE_NAME .
If you want to specify user data on the command line use
the -d flag.
-d option.
|
No | -f data.zip | |||
--addressing ADDRESS_TYPE
|
The address type with which the instance will be launched. The supported values
for ADDRESS_TYPE is public .
Instances launched with the public addressing type have an
internal and an external IP address. See the section called “Introduction to Instance Addressing”
for more information on instance addressing.
|
$
ec2-run-instances ami-6ba54002 -n 5
RESERVATION r-0ea54067 joeuser default INSTANCE i-3ea74257 ami-6ba54002 pending 0 INSTANCE i-31a74258 ami-6ba54002 pending 1 INSTANCE i-31a74259 ami-6ba54002 pending 2 INSTANCE i-31a7425a ami-6ba54002 pending 3 INSTANCE i-31a7425b ami-6ba54002 pending 4 INSTANCE i-31a7425c ami-6ba54002 pending 5