Q: has anyone got a sample of granting public read access to a file in S3 using https://github.com/cognitect-labs/aws-api? I canโt seem to get it right. Hereโs my best effort
(aws/invoke s3 {:op :PutObjectAcl
:request {:Bucket bucket
:Key "test.txt"
:AccessControlPolicy {:Grants [{:Grantee {:Type "Group"
:URI "<http://acs.amazonaws.com/groups/global/AllUsers>"}
:Permission "READ"}]}}})
Any suggestions?@steveb8n have you turned on request validation?
{:paths ["src"]
:deps {org.clojure/clojure {:mvn/version "1.10.0"}
com.cognitect.aws/lambda {:mvn/version "705.2.402.0"}
com.cognitect.aws/api {:mvn/version "0.8.273"}
com.cognitect.aws/endpoints {:mvn/version "1.1.11.507"}}}
given these dependencies ^(require '[cognitect.aws.client.api :as aws])
(def c (aws/client {:api :lambda}))
(aws/invoke c {:op :Invoke :request {:FunctionName "ghadiecstsks"}})
I'm invoking the lambda without a body payload here
but it takes :Payload
too
(aws/doc c :Invoke)
shows you more
-------------------------
Request
{:FunctionName string,
:InvocationType string,
:LogType string,
:ClientContext string,
:Payload blob,
:Qualifier string}
Required
[:FunctionName]
-------------------------
Response
{:StatusCode integer,
:FunctionError string,
:LogResult string,
:Payload blob,
:ExecutedVersion string}
Pretty useful
does anyone have a favorite snippet for generating time limited signed s3 urls? generating those urls isn't really an api operation so I don't think aws-api covers it
I think it does actually
oh, maybe not time limited, not sure
https://github.com/cognitect-labs/aws-api/issues/5 also suggests it doesn't
it doesn't but (@dchelimsky will shoot me for suggesting this) you could call some internal stuff within cognitect.aws.signers to assemble the url
the actual 'spec' is here https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-query-string-auth.html
https://docs.aws.amazon.com/AmazonS3/latest/API/images/sigV4-using-query-params.png
just as a personal note, i implemented the same thing for my own project to do aws requests, this is quite a mess of an idea ๐
(aws/invoke c {:op :PutObjectAcl :request {:ACL "public-read" :Bucket "BUCKET" :Key "KEY"}})
> it doesn't but (@dchelimsky will shoot me for suggesting this) you could call some internal stuff within cognitect.aws.signers to assemble the url at your own risk ๐
@ghadi thanks. that worked immediately. I did have validation turned on. It was the end of my work day and my brain always slows down then. Appreciated ๐
2 hours with the spec to write a function to do it, so I guess the docs are good, but I do feel like my brain has been smeared over a flat surface to a thickness of about a quarter inch