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?