Fork me on GitHub
#aws
<
2019-08-30
>
kenny16:08:10

Has anyone worked with the AWS KMS API and Cognitect's aws-api? I'm having trouble reading the :Plaintext key from the response.

(let [r (aws-api/invoke c {:op      :GenerateDataKey
                           :request {:KeyId   cmk-arn
                                     :KeySpec "AES_256"}})
      plaintext (:Plaintext r)]
  (with-open [p plaintext
              out (io/output-stream "test.txt")]
    (clojure.data.codec.base64/decoding-transfer p out)))
java.lang.ArrayIndexOutOfBoundsException: Index -7 out of bounds for length 123
The AWS docs say Plaintext is a "Base64-encoded binary data object." If I slurp plaintext, I get "�$���r*�!��8yS�x;�\f�@\r�[email protected]�" returned which is definitely not base64. Is aws-api doing something with the response before I get it?

hiredman16:08:03

when you call the aws-api doc function for the operation what does it say?