RunInstances
Description
Launches a specified number of instances of an AMI for which you have permissions.
If Amazon EC2 cannot launch the minimum number 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 allocate the remaining available instances using round robin.
In the following example, Libby generates a request to launch two images (database and web_server):
Libby runs the
RunInstances
operation to launch database instances (min. 10, max. 15) and web_server instances (min. 30, max. 40).Because there are currently 30 instances available and Libby needs a minimum of 40, no instances are launched.
Libby adjusts the number of instances she needs and runs the
RunInstances
operation to launch database instances (min. 5, max. 10) and web_server instances (min. 20, max. 40).Amazon EC2 launches the minimum number of instances for each AMI (5 database, 20 web_server).
The remaining 5 instances are allocated using round robin.
Libby adjusts the number of instances she needs and runs the
RunInstances
operation again to launch database instances (min. 5, max. 10) and web_server instances (min. 20, max. 40).
Note | |
---|---|
Every instance is launched in a security group (created using the |
You can provide an optional key pair ID for each image in the launch request (created using the CreateKeyPair
operation). All instances that are created from images that use this key pair will have access to the associated 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.
Important | |
---|---|
Launching public images without a key pair ID will leave them inaccessible. |
The public key material is made available to the 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.
Optional user data can be provided in the launch request. All instances that collectively comprise the launch request have access to this data. For more information, go the
Note | |
---|---|
If any of the AMIs have a product code attached for which the user has not subscribed, the |
Important | |
---|---|
We strongly recommend using the 2.6.18 Xen stock kernel with the c1.medium and c1.xlarge instances. Although the default Amazon EC2 kernels will work, the new kernels provide greater stability and performance for these instance types. For more information about kernels, go the Amazon Elastic Compute Cloud Developer Guide. |
Request Parameters
Name | Description | Required |
---|---|---|
|
Unique ID of a machine image, returned by a call to Type: String Default: None |
Yes |
|
Minimum number of instances to launch. If the value is more than Amazon EC2 can launch, no instances are launched at all. Type: Integer Default: None Constraints: Between 1 and the maximum number allowed for your account (default: 20). |
Yes |
|
Maximum number of instances to launch. If the value is more than Amazon EC2 can launch, the largest possible number above minCount will be launched instead. Type: Integer Default: None Constraints: Between 1 and the maximum number allowed for your account (default: 20). |
Yes |
|
The name of the key pair. Type: String Default: None |
No |
|
Name of the security group. Type: String Default: None |
No |
|
Specifies additional information to make available to the instance(s). Type: String Default: None |
No |
|
The user data. Type: String Default: None |
No |
|
Deprecated. Type: String Default: None |
No |
|
Specifies the instance type. Type: String Default: m1.small Valid Values: |
No |
|
Specifies the placement constraints (Availability Zones) for launching the instances. Type: String Default: Amazon EC2 selects an Availability Zone. |
No |
|
The ID of the kernel with which to launch the instance. Type: String Default: None |
No |
|
The ID of the RAM disk with which to launch the instance. 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, go to the Resource Center and search for the kernel ID. Type: String Default: None |
No |
|
The virtual name. Type: String Default: None |
No |
|
The device name (e.g., /dev/sdh). Type: String Default: None |
No |
|
Enables monitoring for the instance. Type: Boolean Default: Disabled |
No |
|
Specifies the subnet ID within which to launch the instance(s) for Amazon Virtual Private Cloud. Type: String Default: None |
No |
Response Elements
Name | Description |
---|---|
|
Type: RunInstancesResponseType Ancestor: None Children: |
|
The ID of the request. Type: xsd:string Ancestor: Children: None |
|
Unique ID of the reservation. Type: xsd:string Ancestor: Children: None |
|
AWS Access Key ID of the user who owns the reservation. Type: xsd:string Ancestor: Children: None |
|
Group set. Type: GroupSetType Ancestor: Children: |
|
Group set item. Type: GroupItemType Ancestor: Children: |
|
Name of the security group. Type: xsd:string Ancestor: Children: None |
|
Instance set. Type: RunningInstancesSetType Ancestor: Children: |
|
Running instance set item. Type: RunningInstancesItemType Ancestor: Children: |
|
Unique ID of the instance launched. Type: xsd:string Ancestor: Children: None |
|
Image ID of the AMI used to launch the instance. Type: xsd:string Ancestor: Children: None |
|
The current state of the instance. Type: InstanceStateType Ancestor: Children: |
|
A 16-bit unsigned integer. The high byte is an opaque internal value and should be ignored. The low byte is set based on the state represented: Type: xsd:int Ancestor: Children: None |
|
The current state of the instance. Type: xsd:string Ancestor: Children: None |
|
The private DNS name assigned to the instance. This DNS name can only be used inside the Amazon EC2 network. This element remains empty until the instance enters a running state. Type: xsd:string Ancestor: Children: None |
|
The public DNS name assigned to the instance. This DNS name is contactable from outside the Amazon EC2 network. This element remains empty until the instance enters a running state. Type: xsd:string Ancestor: Children: None |
|
Reason for the most recent state transition. This might be an empty string. Type: xsd:string Ancestor: Children: None |
|
If this instance was launched with an associated key pair, this displays the key pair name. Type: xsd:string Ancestor: Children: None |
|
The AMI launch index, which can be used to find this instance within the launch group. For more information, go to the Metadata section of the Type: xsd:string Ancestor: Children: None |
|
Product codes attached to this instance. Type: ProductCodesSetType Ancestor: Children: |
|
Information for one product code. Type: ProductCodesSetItemType Ancestor: Children: |
|
Product code. Type: xsd:string Ancestor: Children: None |
|
The instance type. For more information on instance types, go to the Type: xsd:string Ancestor: Children: None |
|
The time the instance launched. Type: xsd:dateTime Ancestor: Children: None |
|
The location where the instance launched. Type: PlacementResponseType Ancestor: Children: |
|
Returns the Availability Zones of the instances. Type: xsd:string Ancestor: Children: None |
|
Optional. Kernel associated with this instance. Type: xsd:string Ancestor: Children: None |
|
Optional. RAM disk associated with this instance. Type: xsd:string Ancestor: Children: None |
|
Platform of the instance (e.g., Windows). Type: xsd:string Ancestor: Children: None |
|
Specifies whether monitoring is enabled for the instance. Type: InstanceMonitoringStateType Ancestor: Children: |
|
State of monitoring for the instance. Type: xsd:string Ancestor: Children: None |
|
Specifies the subnet ID in which the instance is running (Amazon Virtual Private Cloud). Type: xsd:string Ancestor: Children: None |
|
Specifies the VPC in which the instance is running (Amazon VPC). Type: xsd:string Ancestor: Children: None |
|
Specifies the private IP address that is assigned to the instance (Amazon VPC). Type: xsd:string Ancestor: Children: None |
|
Specifies the IP address of the instance. Type: xsd:string Ancestor: Children: None |
|
ID of the requester. Type: xsd:string Ancestor: Children: None |
Examples
Example Request
This example launches three instances of the ami-60a54009
AMI.
https://ec2.amazonaws.com/?Action=RunInstances&ImageId=ami-60a54009&MaxCount=3&MinCount=1&Placement.AvailabilityZone=us-east-1a&Monitoring.Enabled=true&AuthParams
Example Response
<RunInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2009-07-15/"> <reservationId>r-47a5402e</reservationId> <ownerId>AIDADH4IGTRXXKCD</ownerId> <groupSet> <item> <groupId>default</groupId> </item> </groupSet> <instancesSet> <item> <instanceId>i-2ba64342</instanceId> <imageId>ami-60a54009</imageId> <instanceState> <code>0</code> <name>pending</name> </instanceState> <privateDnsName></privateDnsName> <dnsName></dnsName> <keyName>example-key-name</keyName> <amiLaunchIndex>0</amiLaunchIndex> <instanceType>m1.small</instanceType> <launchTime>2007-08-07T11:51:50.000Z</launchTime> <placement> <availabilityZone>us-east-1b</availabilityZone> </placement> <monitoring> <enabled>true</enabled> </monitoring> </item> <item> <instanceId>i-2bc64242</instanceId> <imageId>ami-60a54009</imageId> <instanceState> <code>0</code> <name>pending</name> </instanceState> <privateDnsName></privateDnsName> <dnsName></dnsName> <keyName>example-key-name</keyName> <amiLaunchIndex>1</amiLaunchIndex> <instanceType>m1.small</instanceType> <launchTime>2007-08-07T11:51:50.000Z</launchTime> <placement> <availabilityZone>us-east-1b</availabilityZone> </placement> <monitoring> <enabled>true</enabled> </monitoring> </item> <item> <instanceId>i-2be64332</instanceId> <imageId>ami-60a54009</imageId> <instanceState> <code>0</code> <name>pending</name> </instanceState> <privateDnsName></privateDnsName> <dnsName></dnsName> <keyName>example-key-name</keyName> <amiLaunchIndex>2</amiLaunchIndex> <instanceType>m1.small</instanceType> <launchTime>2007-08-07T11:51:50.000Z</launchTime> <placement> <availabilityZone>us-east-1b</availabilityZone> </placement> <monitoring> <enabled>true</enabled> </monitoring> </item> </instancesSet> </RunInstancesResponse>