Fork me on GitHub
#aws
<
2022-01-31
>
Nick Stares22:01:31

Hi! First time using aws-api and I I am trying to invoke a https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-private-api-test-invoke-url.html. Basically the equivalent of hitting

https://{restapi-id}.execute-api.{region}.
With a GET or POST request. How should I go about doing this? I took a shot in the dark but I don't know what the value for :api should be:
(aws/client {:api :apigateway
               :region "us-east-1"
               :endpoint-override {:hostname "ry8g3pqgz5"
                                   :path     "/prod/workflows"}}))
I'll also need to supply a session token. If I am able to build the client successfully, what would the Invoke :op be? I would have used an http client but then I think I would have to implement the signature calculations for the authorization header from scratch[??]

thegeez13:02:16

The url you want to reach looks similar to the websocket example with :PostToConnection, that might work for your use-case, see: https://github.com/cognitect-labs/aws-api#posttoconnection

Nick Stares18:02:36

Hmm, I tried this but it didn't work

(def amc
  (aws/client {:api :apigatewaymanagementapi
               :region "us-east-1"
               :endpoint-override {:hostname "ry8g3pqgz4"
                                   :path     "/prod/workflows"}
               :credentials-provider (credentials/basic-credentials-provider
                                            {:access-key-id     (:AccessKeyId creds)
                                             :secret-access-key (:SecretAccessKey creds)
                                             :session-token     (:SessionToken creds)})}))

(aws/invoke amc {:op :PostToConnection})
;; => {:cognitect.anomalies/category :cognitect.anomalies/not-found, :cognitect.anomalies/message "ry8g3pqgz4: nodename nor servname provided, or not known"}

Nick Stares18:02:28

Also, not sure what operation I would use for GET  since I assume :PostToConnection is only for`POST`