ec2-run-instances

ec2-run-instances ami_id [-n instance_count] [-g group [-g group ...]] [-k keyname] [-d user_data | -f user_data_file] [ --addressing addressing_type] [ --instance-type instance_type]

Launches one or more instances of the specified AMI. Optional parameters include:

If the AMI has a product code attached for which the user has not subscribed, the ec2-run-instances call will fail.

OptionDescriptionRequired

-n instance_count

The number of instances to launch. If Amazon EC2 cannot launch the specified number of instances, no instances will launch. If this is specified as a range (min-max), Amazon EC2 will try to launch the maximum number, but no fewer than the minimum number.

Default: 1

Example: -n 5

No

-g group

The security group(s) within which to launch the instances. This determines the ingress firewall rules applied to the instances. If you specify more than one group, the security policy will be the union of the security policies of the specified groups.

Default: The default group.

Example: -g fooGroup

No

-k keyname

The key pair to make available to these instances at boot.

Example: -k fooKeyPair

No

-d user_data

Data to make available to the instances. This data is read from the command line of the USER_DATA argument. If you want the data to be read from a file, see the -f option.

Example: -d "my user data"

No

-f user_data_file

Data to make available to these instances. The data is read from the file specified by FILE_NAME. To specify user data on the command line, use the -d option.

Example: -f data.zip

No

--addressing addressing_type

The address type with which the instance launches.

Valid Value: public

[Note]Note

To support the early beta legacy networking scheme, direct is supported for early beta users. For more information on instance addressing, see Instance Addressing.

Example: --addressing public

No

--instance-type instance_type

The type of instance to launch. For more information, see Selecting Instance Types.

Example: --instance-type m1.small

No

Amazon EC2 returns a table that contains the following information:

Amazon EC2 displays errors on stderr.

This example launches five instances of the ami-6ba54002 AMI:

$ ec2-run-instances ami-6ba54002 -n 5
RESERVATION r-0ea54067 495219933132 default
INSTANCE i-3ea74257 ami-6ba54002 pending 0 m1.small 2007-07-11T16:40:44+0000
INSTANCE i-31a74258 ami-6ba54002 pending 1 m1.small 2007-07-11T16:40:44+0000
INSTANCE i-31a74259 ami-6ba54002 pending 2 m1.small 2007-07-11T16:40:44+0000
INSTANCE i-31a7425a ami-6ba54002 pending 3 m1.small 2007-07-11T16:40:44+0000
INSTANCE i-31a7425b ami-6ba54002 pending 4 m1.small 2007-07-11T16:40:44+0000
INSTANCE i-31a7425c ami-6ba54002 pending 5 m1.small 2007-07-11T16:40:44+0000