Description
Passing a DateTime as the ValidFrom
or ValidUntil
argument to ec2 client request_spot_instances()
works fine. However, passing a similar DateTime object to request_spot_fleet()
results in an invalid parameter value from EC2: botocore.exceptions.ClientError: An error occurred (InvalidSpotFleetRequestConfig) when calling the RequestSpotFleet operation: Parameter: SpotFleetRequestConfig.ValidFrom is invalid.
The problem appears to be that request_spot_fleet()
sends the parameter as a string in YYYY-MM-DDTHH:MM:SS.xxxxxxZ
format (debug-level logging on a call to request_spot_fleet()
where ValidFrom and ValidUntil are DateTimes shows the request as including u'SpotFleetRequestConfig.ValidFrom': '2016-07-29T19:32:29.648833Z', u'SpotFleetRequestConfig.ValidUntil': '2016-07-29T19:32:30.648833Z'
).
If I change the call to have arguments of ValidFrom=valid_from.strftime('%Y-%m-%dT%H:%M:%SZ'), ValidUntil=valid_to.strftime('%Y-%m-%dT%H:%M:%SZ')
it then works correctly.
I don't know if this is an issue with boto3 or on the AWS side, but it appears that there needs to be some additional manipulation of the timestamp string sent to AWS.