How to block internet access for S3 buckets?

0

I have many ECS instances distributed in different vpcs, according to https://docs.aws.amazon.com/AmazonS3/latest/userguide/example-bucket-policies-vpc-endpoint.html, I can restrict the access source of bucket by using sourceVPC condition. However, this brings some problems. One is that the bucket policy needs to be modified when adding a new VPC, and the other is that my bucket cannot be accessed through the AWS Console/other AWS Services. My goal is to want to prevent internet access to objects in the bucket, but based on Amazon S3 documentation I didn't find a proper solution.

已提問 2 年前檢視次數 632 次
2 個答案
1

Could specify the ecs-task role in the bucket policy as the only allowed principle and deny all others. Then in the trust policy of the ecs-task role only allow the ecs-tasks service to assume the role. See: How to Restrict Amazon S3 Bucket Access to a Specific IAM Role.

profile pictureAWS
專家
kentrad
已回答 2 年前
0

The short answer is: Use a bucket policy. But if you could expand the question and talk to what sort of access (and from where - in terms of networking) you'd like to have that would make it possible to provide a more relevant answer.

profile pictureAWS
專家
已回答 2 年前
  • I have many ECS instances distributed in different vpcs, according to https://docs.aws.amazon.com/AmazonS3/latest/userguide/example-bucket-policies-vpc-endpoint.html, I can restrict the access source of bucket by using sourceVPC condition. However, this brings some problems. One is that the bucket policy needs to be modified when adding a new VPC, and the other is that my bucket cannot be accessed through the AWS Console/other AWS Services. My goal is to want to prevent internet access to objects in the bucket, but based on Amazon S3 documentation I didn't find a proper solution.

  • You have conflicting goals then: Because the AWS console is only accessible via the Internet and other AWS services that use that bucket may not be VPC-based. And if you choose to restrict access to specific VPCs then you will need to update the bucket policy as you add more VPCs. You might consider an automated deployment process that creates the VPCs and updates the bucket policy at the same time. The other answer from kentrad is probably the better way to go here because you can choose "who" is accessing the bucket rather then restricting the "where from".

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

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

回答問題指南