class AWS::S3::ACL::Grant

A Policy is made up of one or more Grant objects. A grant sets a specific permission and grants it to the associated grantee.

When creating a new grant to add to a policy, you need only set its permission and then associate with a Grantee.

grant = ACL::Grant.new
=> #<AWS::S3::ACL::Grant (permission) to (grantee)>

Here we see that neither the permission nor the grantee have been set. Let’s make this grant provide the READ permission.

grant.permission = 'READ'
grant
=> #<AWS::S3::ACL::Grant READ to (grantee)>

Now let’s assume we have a grantee to the AllUsers group already set up. Just associate that grantee with our grant.

grant.grantee = all_users_group_grantee
grant
=> #<AWS::S3::ACL::Grant READ to AllUsers Group>

And now are grant is complete. It provides READ permission to the AllUsers group, effectively making this object publicly readable without any authorization.

Assuming we have some object’s policy available in a local variable called policy, we can now add this grant onto its collection of grants.

policy.grants << grant

And then we send the updated policy to the S3 servers.

some_s3object.acl(policy)