I am making a call for launching spot instances. The code that I am using -
request_spot_instances(
SpotPrice = str(price),
ClientToken = client_token,
InstanceCount = count,
Type = 'one-time',
ValidFrom = valid_from,
ValidUntil = valid_until,
LaunchGroup = '',
AvailabilityZoneGroup = '',
BlockDurationMinutes = 120,
LaunchSpecification = {
'ImageId': image_id,
'KeyName': key_name,
'SecurityGroups': security_groups,
'UserData': user_data,
'InstanceType': instance_type,
'Placement' : placement,
'BlockDeviceMappings': block_device_map,
'SubnetId': subnet_id,
'NetworkInterfaces': [
network_interface
],
'IamInstanceProfile': iamprofile,
'Monitoring': {
'Enabled': True
}
}
)
The values of valid_from and valid_until are -
valid_from = datetime.utcnow()
valid_until = datetime.utcnow() + timedelta(minutes=10)
I get the following error while making the call -
*** ClientError: An error occurred (InvalidTime) when calling the RequestSpotInstances operation: "Sun Dec 04 22:17:59 UTC 2016" is an invalid time
How do I resolve this error?
This should work:
valid_from = datetime.utcnow() + timedelta(seconds=3)
valid_until = valid_from + timedelta(minutes=10)
I ran into the same problem and I concluded that valid_from
has to be "now" or somewhere in the future. By adding 2-3 seconds to your valid_from
datetime it will work.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.