| Did this page help you? Yes No Tell us about it... |
Launches a specified number of instances of an AMI for which you have permissions.
If Amazon EC2 cannot launch the minimum number of AMIs you request, no instances will be launched. If there is insufficient capacity to launch the maximum number of AMIs you request, Amazon EC2 launches the minimum number specified for each AMI and allocates the remaining available instances using round robin.
![]() | Note |
|---|---|
Every instance is launched in a security group (which you create using the |
For Linux instances, you can provide an optional key pair ID in the launch request (created using the ec2-create-keypair or ec2-import-keypair command). The instances will have access to the public
key at boot. You can use this key to provide secure access to an instance of an image on a per-instance basis. Amazon EC2 public
images use this feature to provide secure access without passwords.
The public key material is made available to the Linux instance at boot time by placing it in the openssh_id.pub file on a logical device that is exposed to the instance as /dev/sda2
(the instance store). The format of this file is suitable for use as an entry within ~/.ssh/authorized_keys (the OpenSSH format). This can be done at boot (e.g., as part of rc.local) allowing
for secure access without passwords.
![]() | Important |
|---|---|
Launching public images without a key pair ID will leave them inaccessible. |
You can provide optional user data in the launch request. All instances that collectively comprise the launch request have access to this data. For more information, go to Instance Metadata in the Amazon Elastic Compute Cloud User Guide.
![]() | Note |
|---|---|
If any of the AMIs have an Amazon DevPay product code attached for which the user has not subscribed, the |
The short version of this command is ec2run.
ec2-run-instances
ami_id [-n instance_count]
[-g group [-g group ...]]
[-k keypair] [-d user_data
|-f user_data_file] [--addressing
addressing_type] [--instance-type
instance_type] [--availability-zone
zone] [--kernel
kernel_id] [--ramdisk
ramdisk_id] [--block-device-mapping
block_device_mapping] [--monitor]
[--disable-api-termination] [--instance-initiated-shutdown-behavior
behavior] [--placement-group
placement-group] [--tenancy
tenancy] [--subnet
subnet_id] [--private-ip-address
ip_address] [--client-token token]
[--network-interface networkinterface]
| Name | Description | Required | |||
|---|---|---|---|---|---|
|
|
Unique ID of a machine image, returned by a call to ec2-describe-images. Type: String Default: None Example: ami-15a4417c |
Yes | |||
|
|
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. Type: String Default: 1 Constraints: Between 1 and the maximum number allowed for your account (default: 20). Example: -n 5-10 |
No | |||
|
|
Name of the security group. Type: String Default: None Example: -g websrv |
No | |||
|
|
The name of the key pair. Type: String Default: None Example: -k websvr-keypair |
No | |||
|
|
Specifies Base64-encoded MIME user data to be made available to the instance(s) in this reservation. Type: String Default: None Example: -d s3-bucket:my-logs |
No | |||
|
|
Specifies the filename of the user data to be made available to the instance(s) in this reservation. Type: String Default: None Example: -f user-data.txt |
No | |||
|
|
Deprecated. | ||||
|
|
Specifies the instance type. Type: String Valid Values: Default: m1.small Example: -t m1.large |
No | |||
|
|
The Availability Zone in which to run the instance. Type: String Default: None Example: --availability-zone us-east-1a |
No | |||
|
|
The ID of the kernel with which to launch the instance. Type: String Default: None Example: --kernel aki-ba3adfd3 |
No | |||
|
|
The ID of the RAM disk to select. Some kernels require additional drivers at launch. Check the kernel requirements for information on whether you need to specify a RAM disk. To find kernel requirements, refer to the Resource Center and search for the kernel ID. Type: String Default: None Example: --ramdisk ari-abcdef01 |
No | |||
|
|
Defines a block device mapping for the instance. This argument is passed in the form of
You may specify multiple For more detailed information on block device mapping, go to Block Device Mapping in the Amazon Elastic Compute Cloud User Guide. Type: String Default: None Example: -b "/dev/sdb=snap-92d333fb::false" |
No | |||
|
|
Enables monitoring for the instance. Type: Boolean Default: Disabled Example: --monitor |
No | |||
|
|
Disables the ability to terminate the instance using the EC2 API (i.e., "locks" the instance). To re-enable
this ability, you must change the Type: String Default: False (you can terminate the instance using the API) Example: --disable-api-termination |
No | |||
|
|
If an instance shutdown is initiated, this determines whether the instance stops or terminates. Type: String Valid Values: Default: Example: --instance-initiated-shutdown-behavior stop |
No | |||
|
|
Name of the placement group. Type: String Valid Values: Default: None Example: --placement-group XYZ-cluster |
No | |||
|
|
The tenancy of the instance you want to launch. An instance with a
tenancy of Type: String Valid Values: Default: default Example: --tenancy dedicated |
No | |||
|
|
If you're using Amazon Virtual Private Cloud, this specifies the ID of the subnet you want to launch the instance into. Type: String Default: None Example: -s subnet-f3e6ab83 |
No | |||
|
|
If you're using Amazon Virtual Private Cloud, you can optionally use this parameter to assign the instance a specific available IP address from the subnet. Type: String Default: Amazon VPC selects an IP address from the subnet for the instance Example: --private-ip-address 10.0.0.25 |
No | |||
|
|
Unique, case-sensitive identifier you provide to ensure idempotency of the request. For more information, go to How to Ensure Idempotency in the Amazon Elastic Compute Cloud User Guide. Type: String Default: None Constraints: Maximum 64 ASCII characters Example: --client-token 550e8400-e29b-41d4-a716-446655440000 |
No | |||
|
|
Specifies the network attachment for the launched instance. The format of the NETWORKINTERFACE definition is as follows: For an existing NETWORKINTERFACE - For a new NETWORKINTERFACE - Type: String Default: None Examples:
|
No |
| Option | Description |
|---|---|
|
|
Overrides the Region specified in the Default: The Example: |
|
|
Default: The Example: |
|
|
The private key to use when constructing requests to Amazon EC2. Default: The value of the Example: |
|
|
The X.509 certificate to use when constructing requests to Amazon EC2. Default: The value of the Example: |
|
|
Specifies a connection timeout (in seconds). Example: --connection-timeout 30 |
|
|
Specifies a request timeout (in seconds). Example: --request-timeout 45 |
|
|
Displays verbose output by showing the SOAP request and response on the command line. This is particularly useful if you are building tools to talk directly to our SOAP API. |
|
|
Displays column headers in the output. |
|
|
Shows empty columns as |
|
|
Do not display tags for tagged resources. |
|
|
Prints internal debugging information. This is useful to assist us when troubleshooting problems. |
|
|
Displays Help. |
|
|
If Example: |
The command 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
Instance state. This is usually pending, which indicates that the instance(s) are preparing to launch
Key pair name (if a key pair was associated with the instance at launch)
AMI launch index
Product code (if the AMI has a product code)
Instance type
Instance launch time
Availability Zone
Kernel ID
RAM disk ID
Monitoring status
Root device type (ebs or instance-store)
Placement group the cluster instance is in
The tenancy of the instance launched (if it is running within a VPC).
Virtualization type (paravirtual or hvm)
Hypervisor type (xen or ovm)
Amazon EC2 command line tools display errors on stderr.
This example launches three instances of the ami-b232d0db AMI.
PROMPT> ec2-run-instances ami-b232d0db -n 3 --availability-zone us-east-1a
RESERVATION r-385c5950 012301230123 default
INSTANCE i-5bca5a30 ami-b232d0db pending 0 m1.small 2010-04-07T12:25:47+0000 us-east-1a aki-94c527fd ari-96c527ff monitoring-disabled ebs paravirtual xen
INSTANCE i-59ca5a32 ami-b232d0db pending 1 m1.small 2010-04-07T12:25:47+0000 us-east-1a aki-94c527fd ari-96c527ff monitoring-disabled ebs paravirtual xen
INSTANCE i-5fca5a34 ami-b232d0db pending 2 m1.small 2010-04-07T12:25:47+0000 us-east-1a aki-94c527fd ari-96c527ff monitoring-disabled ebs paravirtual xenThis example launches an Amazon EBS-based Fedora image (ami-84db39ed) and provides a block device mapping that
mounts a public snapshot containing the 2000 US Census data.
PROMPT> ec2-run-instances ami-84db39ed -n 1 --b "/dev/sdb=snap-92d333fb::false"
RESERVATION r-5488ce3c 054794666394 default
INSTANCE i-770af21c ami-84db39ed pending 0 m1.small 2010-02-25T00:08:00+0000 us-east-1c aki-94c527fd ari-96c527ff monitoring-disabled ebs paravirtual xen