Hi. I am trying to set a filter on an sns subscription but i get the following error message. The doc says :Attributes must be map of sting, string.
:Message "Invalid parameter: Attributes Reason: FilterPolicy: \"test\" must be an object or an array
at [Source: (String)\"{\"test\":\"this\"}\"; line: 1, column: 15]",
(aws/invoke aws-client {:op :Subscribe
:request {:TopicArn topic
:Protocol "sqs"
:Endpoint "arn:aws:sqs:eu-west-1:44444:queueue"
:ReturnSubscriptionArn true
:Attributes {"FilterPolicy" (clojure.data.json/json-str {"test" "this"})}}})
Haven't done anything with sns filter policies but based on https://docs.aws.amazon.com/sns/latest/dg/example-filter-policies.html it seems like you need the values in your Json maps to be sequential, representing sets of values you'll accept. So in your case the Json should be
{"test":["test"]}Regarding https://github.com/cognitect-labs/aws-api Assuming things like region/creds are constant throughout my app (and/or use defaults), is it reasonable to do something like:
(def get-client (memoize (fn [api] (aws/client {:api api}))))
(defn get-object [bucket key]
(aws/invoke (get-client :s3)
{:op :GetObject
:request {:Bucket bucket
:Key key}}))
or even:
(defn invoke [api op-map]
(aws/invoke (get-client api) op-map))clients can be memoized but I'd always pass them explicitly to functions
wrappers like get-object above don't add value (they're just taking positional syntax, making a map, then calling invoke)
since there's only one function to invoke clients aws/invoke, such wrappers all have the same shape: form a request, then invoke it.
Instead, make functions that simply form the request.
Just curious, why always explicitly pass the clients?
global state sucks
args > global state
Oh yeah makes sense 🙂