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년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠