Amazon Elastic Compute Cloud
CLI Reference (API Version 2011-12-15)
Print this pageEmail this pageGo to the ForumsView the PDFShare this page on TwitterShare this page on FacebookBookmark this page on DeliciousSubmit this page to RedditSubmit this page to DiggDid this page help you?  Yes  No   Tell us about it...

ec2-request-spot-instances

Description

Creates a Spot Instance request. Spot Instances are instances that Amazon EC2 starts on your behalf when the maximum price that you specify exceeds the current Spot Price. Amazon EC2 periodically sets the Spot Price based on available Spot Instance capacity and current Spot Instance requests. For more information about Spot Instances, go to Spot Instances in the Amazon Elastic Compute Cloud User Guide.

The short version of this command is ec2rsi.

Syntax

ec2-request-spot-instances ami_id --addressing addressing_type --price price [--instance-count count] [--type type] [--valid-from timestamp] [--valid-until timestamp] [--launch-group group] [--availability-zone-group group] [--user-data data | --user-data-file data-file] [--group group [--group group ...]] [--key key-pair] [--instance-type type] [--subnet subnet_id] [--availability-zone zone] [--kernel kernel] [--ramdisk ramdisk] [--block-device-mapping mapping] [--monitor]

Options

NameDescriptionRequired

ami_id

The AMI ID.

Type: String

Default: None

Example: ami-2bb65342

Yes

-p, --price price

Specifies the maximum hourly price for any Spot Instance launched to fulfill the request.

Type: String

Default: None

Example: -p .15

Yes

-n, --instance-count count

The maximum number of Spot Instances to launch.

Type: xs:integer

Default: 1

Example: -n 10

No

-r, --type type

Specifies the Spot Instance request type.

Type: String

Valid Values: one-time | persistent

Default: one-time

Example: -r persistent

No

-s, --subnet subnet_id

Specifies the ID of the Amazon VPC subnet in which to launch the Spot Instance.

Type: String

Default: None

Example: -s subnet-baab943d3

No

--valid-from date

Start date of the request. If this is a one-time request, the request becomes active at this date and time and remains active until all instances launch, the request expires, or the request is canceled. If the request is persistent, the request becomes active at this date and time and remains active until it expires or is canceled.

Type: DateTime

Default: Request is effective indefinitely.

Example: --valid-from 2009-12-31T11:51:50

No

--valid-until date

End date of the request. If this is a one-time request, the request remains active until all instances launch, the request is canceled, or this date is reached. If the request is persistent, it remains active until it is canceled or this date and time is reached.

Type: DateTime

Default: Request is effective indefinitely.

Example: --valid-until 2009-12-31T11:51:50

No

--launch-group group

Specifies the instance launch group. Launch groups are Spot Instances that launch together and terminate together.

Type: String

Default: Instances are launched and terminated individually.

Example: --launch-group Skynet

No

--availability-zone-group group

Specifies the Availability Zone group. If you specify the same Availability Zone group for all Spot Instance requests, all Spot Instances are launched in the same Availability Zone.

Type: String

Default: Instances are launched in any available Availability Zone.

Example: --availability-zone-group batchGroup01

No

--placement-group group_name

The name of an existing placement group you want to launch the instance into (for cluster instances).

Type: String

Default: Instances are launched in the default placement group.

Example: --placement-group default

No

-d, --user-data user_data

Specifies the user data that will be made available to the instances.

Type: String

Default: None

Example: -d "My user data"

No

-g, --group group

Name of the security group.

Type: String

Default: User's default group.

Example: -g websrv

No

-k, --key key_name

The name of the key pair.

Type: String

Default: None

Example: -k MyKeyPair

No

-t, --instance-type instance_type

Specifies the instance type.

Type: String

Valid Values: m1.small | m1.large | m1.xlarge | c1.medium | c1.xlarge | m2.xlarge | m2.2xlarge | m2.4xlarge | t1.micro

Default: m1.small

Example: -t m1.large

No

-z, --availability-zone zone

Specifies the placement constraints (Availability Zone) for launching the instances.

Type: String

Default: Amazon EC2 selects an Availability Zone in the current Region.

Example: -z us-east-1b

No

--kernel kernel

The ID of the kernel to select.

Type: String

Default: None

Example: --kernel aki-ba3adfd3

No

--ramdisk ramdisk

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 and search for the kernel ID.

Type: String

Default: None

Example: --ramdisk ari-badbad00

No

-b, --block-device-mapping mapping

Defines a block device mapping for the instance. This argument is passed in the form of <devicename>=<blockdevice>. The devicename is the device name of the physical device on the instance to map. The blockdevice can be one of the following values:

  • none - specifies that the existing mapping on the specified image for this device should be suppressed. For example: /dev/sdc=none

  • ephemeral[0..3] - indicates that an instance local storage device should be mapped to this device. Example: /dev/sdc=ephemeral0

  • [snapshot-id]:[size]:[delete-on-termination (true|false)] - this value can be used to map a device to an existing EBS-backed volume by specifying an existing volume name. You can specify a new EBS-backed volume by skipping the snapshot ID and passing in a volume size instead; for example: /dev/sdb=:20. You can also specify whether the Amazon EBS volume should be deleted on termination; this value is true by default.

[Note]Note

The device mapping argument must be surrounded by double quotes on Windows systems.

You may specify multiple blockdevicemapping arguments in one call.

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

--monitor

Enables monitoring for the instance.

Type: String

Default: Disabled

Example: --monitor

No

Common Options

OptionDescription

--region REGION

Overrides the Region specified in the EC2_URL environment variable and the URL specified by the -U option.

Default: The EC2_URL environment variable, or us-east-1 if the environment variable is not set.

Example: --region eu-west-1

-U, --url URL

URL is the uniform resource locator of the Amazon EC2 web service entry point.

Default: The EC2_URL environment variable, or https://ec2.amazonaws.com if the environment variable is not set.

Example: -U https://ec2.amazonaws.com

-K, --private-key EC2-PRIVATE-KEY

The private key to use when constructing requests to Amazon EC2.

Default: The value of the EC2_PRIVATE_KEY environment variable.

Example: -K pk-HKZYKTAIG2ECMXYIBH3HXV4ZBEXAMPLE.pem

-C, --cert EC2-CERT

The X.509 certificate to use when constructing requests to Amazon EC2.

Default: The value of the EC2_CERT environment variable.

Example: -C cert-HKZYKTAIG2ECMXYIBH3HXV4ZBEXAMPLE.pem

--connection-timeout TIMEOUT

Specifies a connection timeout (in seconds).

Example: --connection-timeout 30

--request-timeout TIMEOUT

Specifies a request timeout (in seconds).

Example: --request-timeout 45

-v, --verbose

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.

-H, --headers

Displays column headers in the output.

--show-empty-fields

Shows empty columns as (nil).

--hide-tags

Do not display tags for tagged resources.

--debug

Prints internal debugging information. This is useful to assist us when troubleshooting problems.

-?, --help, -h

Displays Help.

-

If - is specified as an argument to one of the parameters, a list of arguments is read from standard input. This is useful for piping the output of one command into the input of another.

Example: ec2-describe-instances | grep stopped | cut -f 2 | ec2-start-instances -

Output

The command returns a table that contains the following information:

  • Output type identifier ("SPOTINSTANCEREQUEST")

  • ID of the Spot Instance request

  • Price

  • Type (one-time or persistent)

  • Product description (Linux/UNIX, Windows)

  • State (active, open, closed, cancelled, failed)

  • Create time

  • Valid from

  • Valid until

  • Launch group

  • Availability Zone group

  • Image ID

  • Instance type

  • Key pair name

  • Security group

  • Monitoring status

Amazon EC2 command line tools display errors on stderr.

Examples

Example Request

This example creates a Spot Instances request for ten m1.small instances.

PROMPT> ec2-request-spot-instances ami-b232d0db -p 0.04 --key gsg-keypair --group default --instance-type m1.small -n 3 --type one-time
SPOTINSTANCEREQUEST     sir-7545a802    0.04    one-time        Linux/UNIX      open    2010-04-07T16:57:04+0200                                          ami-b232d0db    m1.small gsg-keypair      default                         monitoring-disabled
SPOTINSTANCEREQUEST     sir-26d36202    0.04    one-time        Linux/UNIX      open    2010-04-07T16:57:04+0200                                          ami-b232d0db    m1.small gsg-keypair      default                         monitoring-disabled
SPOTINSTANCEREQUEST     sir-63fb5402    0.04    one-time        Linux/UNIX      open    2010-04-07T16:57:04+0200                                          ami-b232d0db    m1.small gsg-keypair      default                         monitoring-disabled