Fork me on GitHub
#aws
<
2021-12-10
>
hadils15:12:32

I am having problems with `

:apigatewaymanagementapi
I can’t seem to :GetConnection :PostToConnection or :DeleteConnection. I followed all the instructions in the Cognitect API manual and have a valid endpoint.

Alex Miller (Clojure team)15:12:01

what error are you seeing? might also be helpful to post the metadata on the response

Alex Miller (Clojure team)15:12:12

(and be aware that there are some reports of AWS issues right now)

hadils16:12:22

How do you get the metadata?

ghadi16:12:59

(meta response)

ghadi16:12:15

where response is the return value from aws/invoke

hadils16:12:37

Thanks! Let me take a look.

hadils16:12:13

Here’s what i found:

def r (aws/invoke apigwmgtapi {:op          :GetConnection
                                :request {:ConnectionId connection-id}}))
=> #'com.yardwerkz.components.ring-middleware/r
r
=>
#:cognitect.anomalies{:category :cognitect.anomalies/not-found,
                      :message ": nodename nor servname provided, or not known"}
(meta r)
=>
{:http-request {:request-method :get,
                :scheme :https,
                :server-port 443,
                :uri "/@connections/KI_kqfLjvHcCGQQ%3D",
                :headers {"x-amz-date" "20211210T161455Z",
                          "x-amz-target" ".GetConnection",
                          "content-type" "application/x-amz-json-1.1",
                          "host" "",
                          "authorization" "AWS4-HMAC-SHA256 Credential=AKIAQ66JWWZ5V3F4MLM4/20211210/us-west-2/execute-api/aws4_request, SignedHeaders=content-type;host;x-amz-date;x-amz-target, Signature=0046c6adfc560b2d9102b0c388f69eb3642906c5f76813eb9e413f7c484d1a02"},
                :body nil,
                :server-name ""},
 :http-response {:cognitect.anomalies/category :cognitect.anomalies/not-found,
                 :cognitect.anomalies/message ": nodename nor servname provided, or not known",
                 :body nil}}
(def r (aws/invoke apipost {:op          :GetConnection
                                :request {:ConnectionId connection-id}}))
=> #'com.yardwerkz.components.ring-middleware/r
r
=>
{:message "No method found matching route @connections/ for http method GET.",
 :cognitect.anomalies/category :cognitect.anomalies/not-found}
(meta r)
=>
{:http-request {:request-method :get,
                :scheme :https,
                :server-port 443,
                :uri "/production/@connections/",
                :headers {"x-amz-date" "20211210T161538Z",
                          "x-amz-target" ".GetConnection",
                          "content-type" "application/x-amz-json-1.1",
                          "host" "",
                          "authorization" "AWS4-HMAC-SHA256 Credential=AKIAQ66JWWZ5V3F4MLM4/20211210/us-west-2/execute-api/aws4_request, SignedHeaders=content-type;host;x-amz-date;x-amz-target, Signature=469260a8d59c47e93fd9a288d4daa86765055a8477949d448d142cacb688d2ea"},
                :body nil,
                :server-name ""},
 :http-response {:status 404,
                 :headers {"x-amz-apigw-id" "KJB-sE1avHcFcGQ=",
                           "connection" "keep-alive",
                           "x-amzn-requestid" "43c66301-3469-4fee-87b7-ffeab3d9bc6d",
                           "x-amzn-errortype" "NotFoundException",
                           "content-length" "79",
                           "date" "Fri, 10 Dec 2021 16:15:38 GMT",
                           "content-type" "application/json"},
                 :body #object[java.io.BufferedInputStream 0x77e80748 "[email protected]"]}}
where
(def apigwmgtapi (aws/client {:api :apigatewaymanagementapi}))
(def apipost (aws/client
                 {:api               :apigatewaymanagementapi
                  :endpoint-override {:hostname host
                                      :path     (str "/" stage "/@connections/")}}))

hadils19:12:54

I think the problem is that is a Private API.

hadils21:12:00

No, it is being called from a VPC.