Any idea why I might be getting a 400 com.amazon.coral.availability#ThrottlingException with the message Rate exceeded when calling the AWS Step Functions TestState API using aws-api, but not e.g. when using the AWS CLI? I am the only one calling the API and I'm certainly not calling it often enough to get throttled (and even if I was, I'd expect to also get throttled when using the AWS CLI).
Repro:
λ clj -Srepro -Sdeps '{:deps {com.cognitect.aws/api {:mvn/version "0.8.774"} com.cognitect.aws/endpoints {:mvn/version "871.2.40.4"} com.cognitect.aws/states {:mvn/version "871.2.39.3"}}}'
Clojure 1.12.4
user=> (require '[cognitect.aws.client.api :as aws])
nil
user=> (def states (aws/client {:api :states :retriable? (constantly false)}))
#'user/states
user=> (require '[clojure.data.json :as json])
nil
user=> (aws/invoke states {:op :TestState :request {:definition (json/write-str {"Type" "Pass" "End" true})}})
{:__type "com.amazon.coral.availability#ThrottlingException", :message "Rate exceeded", :cognitect.aws.http/status 400, :cognitect.anomalies/category :cognitect.anomalies/busy, :cognitect.aws.error/code "ThrottlingException"}
user=>
λ aws stepfunctions test-state --definition '{"Type": "Pass", "End": true}'
{
"output": "{}",
"status": "SUCCEEDED"
}Hey @flowthing This looks like a legitimate issue with aws-api - thanks for the writeup. As a workaround, I believe you can use an https://github.com/cognitect-labs/aws-api/blob/main/README.md#endpoint-override to point your client at the proper host:
(def states (aws/client {:api :states
:endpoint-override {:protocol :https
:hostname "sync-states.sa-east-1.amazonaws.com"
:port 443}
:retriable? (constantly false)}))
Note: this endpoint override should work only for the TestState and StartSyncExecution operations, which are the only two operations which require that sync- host prefix. You should use your default client for any other operations.
I've opened an issue here: https://github.com/cognitect-labs/aws-api/issues/292Fantastic, thank you! I'll give that a shot. 👍🏻