Amazon S3 bucket policy for uploading and viewing pictures


I have an app that users log in with facebook and then can upload images to s3 bucket and view them. I used Cognito service to allow every logged in user to upload and view all files.

I have no idea how to set the correct permissions on the s3 bucket. This is my attempt at it, but I get can’t save the policy and get Statement is missing required element - Statement "NO_ID-0" is missing "Principal" element

This is the client part, if it helps:

Cognito IAM > Roles > Cognito_myappAuth_Role:


Have you checked out this blog post? It has a good example of how to set up a role that allows S3 bucket access for users. Cutting out the list bucket part out, the access policy you would link to your identity pool roles might look something like this:


Tl;dr from comments for future readers:

  • Apply the policy to the pool’s auth role instead of bucket
  • If the app use case requires a common area, use the bucket root directory, otherwise use a directory for each identity defined in the policy (as described in the blog)
  • The role itself doesn’t apply until after the authentication occurs. The policy just defines what the credentials given back will have access to do and to what.

Leave a Reply