View a markdown version of this page

Use DescribeSpotPriceHistory with a CLI - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Use DescribeSpotPriceHistory with a CLI

The following code examples show how to use DescribeSpotPriceHistory.

CLI
AWS CLI

Example 1: To describe Spot price history

The following describe-spot-price-history example returns the Spot Price history for m1.xlarge instances for a particular day in January.

aws ec2 describe-spot-price-history \ --instance-types m1.xlarge \ --start-time 2014-01-06T07:08:09 \ --end-time 2014-01-06T08:09:10

Output:

{ "SpotPriceHistory": [ { "Timestamp": "2014-01-06T07:10:55.000Z", "ProductDescription": "SUSE Linux", "InstanceType": "m1.xlarge", "SpotPrice": "0.087000", "AvailabilityZone": "us-west-2b" }, { "Timestamp": "2014-01-06T07:10:55.000Z", "ProductDescription": "SUSE Linux", "InstanceType": "m1.xlarge", "SpotPrice": "0.087000", "AvailabilityZone": "us-west-2c" }, { "Timestamp": "2014-01-06T05:42:36.000Z", "ProductDescription": "SUSE Linux (Amazon VPC)", "InstanceType": "m1.xlarge", "SpotPrice": "0.087000", "AvailabilityZone": "us-west-2a" } ] }

For more information, see View Spot Instance pricing history in the Amazon EC2 User Guide.

Example 2: To describe Spot price history for Linux/UNIX Amazon VPC

The following describe-spot-price-history example returns the Spot Price history for m1.xlarge, Linux/UNIX Amazon VPC instances for a particular day in January.

aws ec2 describe-spot-price-history \ --instance-types m1.xlarge \ --product-descriptions "Linux/UNIX (Amazon VPC)" \ --start-time 2014-01-06T07:08:09 \ --end-time 2014-01-06T08:09:10

Output:

{ "SpotPriceHistory": [ { "Timestamp": "2014-01-06T04:32:53.000Z", "ProductDescription": "Linux/UNIX (Amazon VPC)", "InstanceType": "m1.xlarge", "SpotPrice": "0.080000", "AvailabilityZone": "us-west-2a" }, { "Timestamp": "2014-01-05T11:28:26.000Z", "ProductDescription": "Linux/UNIX (Amazon VPC)", "InstanceType": "m1.xlarge", "SpotPrice": "0.080000", "AvailabilityZone": "us-west-2c" } ] }

For more information, see View Spot Instance pricing history in the Amazon EC2 User Guide.

PowerShell
Tools for PowerShell V4

Example 1: This example gets the last 10 entries in the Spot price history for the specified instance type and Availability Zone. Note that the value specified for the -AvailabilityZone parameter must be valid for the region value supplied to either the cmdlet's -Region parameter (not shown in the example) or set as default in the shell. This example command assumes a default region of 'us-west-2' has been set in the environment.

Get-EC2SpotPriceHistory -InstanceType c3.large -AvailabilityZone us-west-2a -MaxResult 10

Output:

AvailabilityZone : us-west-2a InstanceType : c3.large Price : 0.017300 ProductDescription : Linux/UNIX (Amazon VPC) Timestamp : 12/25/2015 7:39:49 AM AvailabilityZone : us-west-2a InstanceType : c3.large Price : 0.017200 ProductDescription : Linux/UNIX (Amazon VPC) Timestamp : 12/25/2015 7:38:29 AM AvailabilityZone : us-west-2a InstanceType : c3.large Price : 0.017300 ProductDescription : Linux/UNIX (Amazon VPC) Timestamp : 12/25/2015 6:57:13 AM ...
Tools for PowerShell V5

Example 1: This example gets the last 10 entries in the Spot price history for the specified instance type and Availability Zone. Note that the value specified for the -AvailabilityZone parameter must be valid for the region value supplied to either the cmdlet's -Region parameter (not shown in the example) or set as default in the shell. This example command assumes a default region of 'us-west-2' has been set in the environment.

Get-EC2SpotPriceHistory -InstanceType c3.large -AvailabilityZone us-west-2a -MaxResult 10

Output:

AvailabilityZone : us-west-2a InstanceType : c3.large Price : 0.017300 ProductDescription : Linux/UNIX (Amazon VPC) Timestamp : 12/25/2015 7:39:49 AM AvailabilityZone : us-west-2a InstanceType : c3.large Price : 0.017200 ProductDescription : Linux/UNIX (Amazon VPC) Timestamp : 12/25/2015 7:38:29 AM AvailabilityZone : us-west-2a InstanceType : c3.large Price : 0.017300 ProductDescription : Linux/UNIX (Amazon VPC) Timestamp : 12/25/2015 6:57:13 AM ...