I am using the Java AWS SDK to create EC2 instance requests. Unlike on demand instances, the point request API has nothing like ClientToken and therefore does not support idempotency out of the box.
The easiest way I could come up with is to set the LaunchGroup property to a unique UUID; when I check this, I call DescribeSpotInstanceRequests and see if I already have a request with the same launch group.
To my surprise, it seems that the delay before calling the description returns requests to the place sent earlier. I wrote a JUnit test for this, and it seems that in order for it to be consistent, I would have to set a timeout of at least 60 seconds between two calls (an instance of a place request and describe requests for a place instance). I need to have a dimension of 10 seconds, because my requests can be repeated by the application at this interval, in case of any failure - that is, something breaks after I sent the request, but before I could read the result, I returned from Amazon In this case, I do not want to repeat the request, I just want it to register and go.
@Test public void testRunSpotInstances() throws Exception { activity.execute(execution); timeout(TIMEOUT);
The test runs every time if TIMEOUT is set to 60 seconds; for the 40-50s, he works intermittently. Anything below this fails every time.
Could anyone get around this delay? Is idempotency implementation for point requests possible using only the AWS API and no state stored in the client application?
source share