Can't Get Max Result Of Spot Price History - Us-east Region
When I retrieve the history price of spot for 'us-east-f1' or any region in 'us-east-1', the result always less than 200 price, I need for single region and single instance type. H
Solution 1:
Your code appears to be working just fine, but the start and end timestamps were backwards.
I ran this code:
import boto3
import datetime
start_date = datetime.datetime.now() - datetime.timedelta(90)
end_date = datetime.datetime.now() - datetime.timedelta(0)
ec2 = boto3.client('ec2', region_name='us-east-1')
paginator = ec2.get_paginator('describe_spot_price_history')
page_iterator = paginator.paginate(InstanceTypes =['c3.4xlarge'],ProductDescriptions = ['Linux/UNIX'], AvailabilityZone = 'us-east-1a', StartTime= start_date, EndTime = end_date, MaxResults=2000 )
for page in page_iterator:
print page['SpotPriceHistory']
I got back one page that had 122 entries.
The first entry was for 2018-04-01:
{u'Timestamp': datetime.datetime(2018,
4,
1,
4,
40,
44, tzinfo=tzutc()), u'AvailabilityZone': 'us-east-1a', u'InstanceType': 'c3.4xlarge', u'ProductDescription': 'Linux/UNIX', u'SpotPrice': '0.840000'
},
The last entry was for 2018-01-02:
{u'Timestamp': datetime.datetime(2018,
1,
2,
0,
28,
35, tzinfo=tzutc()), u'AvailabilityZone': 'us-east-1a', u'InstanceType': 'c3.4xlarge', u'ProductDescription': 'Linux/UNIX', u'SpotPrice': '0.840000'
}
This cover the maximum 90 days of data that is available.
Solution 2:
To make an API call to another region, specify the region_name
:
ec2 = boto3.client('ec2', region_name='ap-southeast-2')
When MaxResults
is exceeded, obtain the next set of results by making the same call, but set NextToken
to the value returned by NextToken
in the previous result set.
Post a Comment for "Can't Get Max Result Of Spot Price History - Us-east Region"