Can i still upload files to S3 using the AWS SDK when i restrict access with an CloudFront distribution?

0

I want my users to only access files via the cloudfront distribution. I've found this article that explains how to do that. My question is though; If i restrict access like that, will my web application still be able to upload files to amazon s3 buckets directly or does it have to use cloudfront for that as well?

Thank you

2 個答案
3
已接受的答案

Assuming your web application is running in EC2/ECS, you can create an IAM Role with permissions to access the Bucket and attach it to your EC2 Instance(s). The Role will authorise SDK calls made from the instance (assuming the correct permissions are defined) without you having to create/manage access keys.

As long as your Buckets access Policy/ACLs are configured to allow access from the account/role your web application will be able to continue using the SDK as standard.

Note: IAM Roles & Bucket ACLs are notoriously tricky to get right so I strongly advise getting the configuration right on a UAT environment first.

已回答 2 年前
profile picture
專家
已審閱 10 個月前
  • what is an UAT environment?

  • UAT means User Acceptance Testing environment. So Daniel just mentioned that you should always test your solution before going live with it.

1

Like Daniel Craigine wrote, of course, you can use SDK to upload new files to this S3 Bucket.

Origin Access Identity (OAI) is the way how the CloudFront is authorized to get objects from S3 and you need to allow OAI permission in Bucket Policy as is explained in the article you mention. But you can still add your application permission to PutObjects to this S3 Bucket in the IAM Role used by your application.

I hope it is clear right now :)

profile picture
MG
已回答 2 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南