I’m using temporary sessions in Amazon S3 with GetSessionToken/GetFederationToken, I am planing on having more than 10K users each one can upload to S3 so initialy I thought of use a bucket for each user and set write (upload) permissions per bucket for each user, but since there is a limitation on the number of buckets per Amazon account I have forsaken that idea.
How can I set a permission like allow public read, and upload only if the prefix on the key of the object that the user wants to upload ?
For example if username X uploads a file the key must be like X_filename.
Or any other way which allows me to have security, this is for a mobile app and I would not like to go through our own servers when uploading a file.
Edit:
I’ve tried the operation GetFederationToken with the following policy
"{
"Statement":[{
"Effect":"Allow",
"Action":["s3:PutObject","s3:GetObject","s3:GetObjectVersion",
"s3:DeleteObject",\"s3:DeleteObjectVersion"],
"Resource":"arn:aws:s3:::user.uploads/john/*"
}
]
}"
I have the bucket user.uploads on S3 and folder john
however any upload with the session credentials to bucket user.uploads with key john/filename fails with access denied”
Amazon’s Identity and Access Management (IAM) service is what you need. The documentation has numerous examples, some of which match your scenario.
From the docs:
You would create a new identity for each user and use that to control access to the subfolders (prefixes) as needed.