amazon-web-servicesboto3botocore

Does `amz-sdk-invocation-id` header provide idempotency for aws api calls?


So, I was looking at the source code for botocore and it seems that botocore adds a request header called amz-sdk-invocation-id in the headers in a function called add_retry_headers.

Does this mean that every request generated by boto3 is idempotent? What about requests that take a client-token parameter like EC2. client-token is supposed to provide idempotency for creating ec2 instances. How would that work? I mean what would happen if client-token are different but amz-sdk-invocation-id are same or if amz-sdk-invocation-id are different but client-token are the same?


Solution

  • The Kotlin SDK defines this property as:

    The unique request ID generated for tracking the request in-flight client side.

    This already hints to the fact that the property is only used client side, not on the server (AWS) side.

    Moreover: it is possible to manually craft a HTTP request to create EC2 instances, and it is not necessary to add this header. (Page with information on what is necessary for a raw HTTP request, and the list of required headers - which does not even mention the aws-sdk-invocation-id)

    So in conclusion: Treat it as a implementation detail for botocore only, and only rely on client-token, because that is the only parameter that is explicitly documented for providing idempotency.