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:
-
A security group. New instances launch in this group. If no group is specified instances are launched in the
default
group. -
A key pair name. The public key associated with this key pair name are available to the instances at boot time.
-
User data. This data is available to the launched instances. For more information, see Instance Metadata.
-
Addressing type. This specifies whether the instance has a NATted address. See Instance Addressing and Network Security for more information on instance addressing.
-
This specifies the instance type.
Options include
m1.small
,m1.large
, andm1.xlarge
.The default value is
m1.small
.For more information on instance types, see Selecting Instance Types
If the AMI has a product code attached for which the user has not subscribed, the ec2-run-instances call will fail.
Option | Description | Required | |||
---|---|---|---|---|---|
|
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: Example: |
No |
|||
|
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 Example: |
No |
|||
|
The key pair to make available to these instances at boot. Example: |
No |
|||
|
Data to make available to the instances. This data is read from the
command line of the Example: |
No |
|||
|
Data to make available to these instances. The data
is read from the file specified by Example: |
No |
|||
|
The address type with which the instance launches. Valid Value:
Example: |
No |
|||
|
The type of instance to launch. For more information, see Selecting Instance Types. Example: |
No |
Amazon EC2 returns a table that contains the following information:
-
Output type identifier ("INSTANCE")
-
Instance ID which uniquely identifies each running instance.
-
AMI ID of the image on which the instance(s) are based.
-
DNS name associated with the instance (only present for instances in the
running
state). -
Instance state. This is usually
pending
, which indicates that the instance(s) are preparing to launch. -
Key name. If a key was associated with the instance at launch its name is displayed
-
AMI launch index. For more information, see Instance Metadata.
-
Instance type. For more information on instance types, see Selecting Instance Types.
-
Instance launch time. Specifies when the instance launched.
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