Amazonica and S3

680 views
Skip to first unread message

Gareth Rogers

unread,
Jul 20, 2016, 9:53:11 AM7/20/16
to Clojure
Hi

Has any one had any success using either amazonica.aws.s3/set-bucket-notification-configuration or amazonica.aws.s3/set-bucket-tagging-configuration?

I've got

(amazonica.aws.s3/set-bucket-notification-configuration
    {"my-custom-event-name"
    {"<sqs-arn>" ;; This replaced with the ARN of an SQS queue I've created
     "ObjectCreatedByPut" ;; [S3Event/ObjectCreatedByPut] ;; "s3:ObjectCreated:Put" <-- tried all three
     ;; :filter    "/_SUCCESS"
         }})

and

(amazonica.aws.s3/set-bucket-tagging-configuration
     "my.bucket.name"
     {:tag-sets [{"Formation" "notlive"}]})

Both of those are wrapped with amazonica.core/with-credential which I've omitted.

The call to amazonica.aws.s3/set-bucket-notification-configuration returns nil. I guess this means it's getting converted to a valid call but the S3 API is rejecting it silently? Anyone know what it should look like?

The call to amazonica.aws.s3/set-bucket-tagging-configuration is throwing:

Unhandled com.amazonaws.services.s3.model.AmazonS3Exception
   The XML you provided was not well-formed or did not validate
   against our published schema (Service: Amazon S3; Status Code: 400;
   Error Code: MalformedXML; Request ID: )

I can't figure out what might be wrong there either. I've tried a few variations on the tag sets but it either doesn't run because it can't find an appropriate function or gives the XML error.

Any pointers would be appreciated.

Thanks
Gareth

Gareth Rogers

unread,
Jul 20, 2016, 10:56:10 AM7/20/16
to Clojure
After chatting with a colleague who read this and showed me the magic of trace I think the problem with amazonica.aws.s3/set-bucket-tagging-configuration is that I need

{:tag-sets [{:tag {"Formation" "notlive"}}]}

i.e. I need to know how to call setTag(string key, string value) which takes two args through the Amazonica. I've only dealt with single args before.

Andrea Richiardi

unread,
Jul 20, 2016, 7:44:11 PM7/20/16
to Clojure
Maybe not related, but I was checking that api and this showed up, maybe it can be helpful?

Gareth Rogers

unread,
Jul 21, 2016, 5:30:50 AM7/21/16
to Clojure
Thanks that's helpful. I must have been too frustrated by the end of the day and didn't Google that one!

Reading the trace output for the tag setting I believe the original code I wrote is producing an empty TagSet which is what the API considers malformed. Looks like a <tag> element is required: http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketPUTtagging.html.

That makes me feel that the my problem is that I can't create a tag set correctly through Amazonica. For now I need this to work so I'll switch to doing the Java interop which the SO article is very helpful, thanks :)

set-bucket-notification-configuration is still a mystery but I haven't tried trace with that yet.

I'm going to try set-bucket-lifecycle-configuration which has an example in tests and I'd like to set a policy to delete failed part file uploads. It's use is similar to the notification configuration.

Gareth Rogers

unread,
Jul 21, 2016, 9:53:34 AM7/21/16
to Clojure
I've created this issue https://github.com/mcohen01/amazonica/issues/230 for the set-bucket-notification-configuration as I believe there is a problem with the use of that function.

Having looked at the trace out from set-bucket-notification-configuration I'm convinced I can get set-bucket-tagging-configuration to work with the right structure as it looks like it's doing the right thing when it needs to pass multiple args to a function. Can't get the data structures correct though.

Andrea Richiardi

unread,
Jul 21, 2016, 9:24:45 PM7/21/16
to Clojure
I am glad you solved and raised the issue so that we can track that!

Gareth Rogers

unread,
Jul 27, 2016, 3:41:13 AM7/27/16
to Clojure
Thanks to a quick turn around by the mcohen01, the author, two bugs have been fixed with the bucket notifications and tagging :) The project docs (README) have been updated with examples.
Reply all
Reply to author
Forward
0 new messages