clj-aws-s3 icon indicating copy to clipboard operation
clj-aws-s3 copied to clipboard

Add bucket policy functions

Open petergillardmoss opened this issue 11 years ago • 6 comments

Added get-bucket-policy and update-bucket-policy.

Externally the policy is a clojure data structure. The AWS sdk wants a json structure as a string so the new s3 functions hide this implementation by converting between cli and json.

petergillardmoss avatar Feb 13 '14 11:02 petergillardmoss

I wonder if we should prefer Cheshire over data.json. Thoughts?

weavejester avatar Feb 13 '14 12:02 weavejester

No problems with Cheshire.

Updated to use.

petergillardmoss avatar Feb 13 '14 14:02 petergillardmoss

What keys are allowed in update-bucket-policy? The docstring doesn't say.

weavejester avatar Feb 13 '14 17:02 weavejester

That's rather a complex and open question!

Policies are quite complex data structures used by AWS represented in JSON. The BucketPolicy bean simply takes a string: http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/s3/model/BucketPolicy.html

As you can see the AWS SDK isn't very explicit about them. I guess that's because they are beasts. See the docs on policy documents here: http://docs.aws.amazon.com/AmazonS3/latest/dev/AccessPolicyLanguage.html

Policies are so complex most of the time people use the Policy Generator rather than hand craft them: http://awspolicygen.s3.amazonaws.com/policygen.html

They are also subject to change as AWS sees fit.

More than happy to take guidance but I think documenting AWS policies would be thankless. Perhaps just a link to the AWS docs would suffice?

petergillardmoss avatar Feb 13 '14 19:02 petergillardmoss

Okay, that's reasonable. A link to the docs should be sufficient.

weavejester avatar Feb 13 '14 19:02 weavejester

I have updated with a link to the docs

petergillardmoss avatar Feb 20 '14 15:02 petergillardmoss