title: How to set Amazon bucket policy using the Ruby SDK?
body: <p>I'm trying to set a bucket policy using the Ruby SDK like this:</p>
  
  <pre><code>s3 = Aws::S3::Resource.new(region:'us-east-1')
  obj = s3.bucket('my-bucket-name')
  policy = AWS::S3::Policy.new
  policy.allow(
    :actions =&gt; [:get_object],
    :resources =&gt; [obj],
    :principals =&gt; :any)
  
  obj.policy = policy
  obj.save!
  </code></pre>
  
  <p>But it doesn't seem to be saving. I've looked through the <a href="https://aws.amazon.com/documentation/sdk-for-ruby/" rel="nofollow">ruby documentation</a> but it's not clear how to do this. I'd also like to be able to print out the current policies for the bucket if possible. </p>