- Newest
- Most votes
- Most comments
Hello.
How about separating your S3 buckets into those for public images and those for private files, and using a combination of CloudFront and signed URLs depending on the use case?
While separation using prefixes is possible, separating buckets allows you to independently manage IAM, bucket policies, encryption, lifecycle policies, and more.
For public content such as profile images or product images, I recommend a configuration that delivers them via CloudFront.
You should keep public access to the S3 bucket blocked, configure CloudFront Origin Access Control (OAC), and set the bucket policy to allow only s3:GetObject requests from the specific CloudFront distribution.
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-restricting-access-to-s3.html
OAC helps you secure your origins, such as Amazon S3.
For private documents, on the other hand, the appropriate approach is to verify the user's access permissions within the application and then issue a signed URL.
While an S3 signed URL suffices for files accessed infrequently, using a CloudFront signed URL allows you to benefit from caching for files that are frequently downloaded from locations around the world.
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-choosing-signed-urls-cookies.html
Relevant content
- AWS OFFICIALUpdated 8 months ago
