You do not need to make the bucket public, and the files public. The bucket and its contents can be kept secret.
Do not restrict access to the segment based on the IP address, but restrict it based on the IAM role that the EC2 instance uses.
- Create an IAM EC2 instance role for your EC2 instances.
- Launch your EC2 instances using this role.
- Assign an S3 basket access policy to this IAM role.
For example:
{
"Version": "2012-10-17",
"Statement":[{
"Effect": "Allow",
"Action": "s3:*",
"Resource": ["arn:aws:s3:::my_bucket",
"arn:aws:s3:::my_bucket/*"]
}
]
}
- If you want to restrict access to the trash itself, try the S3 trash policy.
For example:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": ["arn:aws:iam::111122223333:role/my-ec2-role"]
},
"Action": "s3:*",
"Resource": ["arn:aws:s3:::my_bucket",
"arn:aws:s3:::my_bucket/*"]
}
]
}
Additional information: http://blogs.aws.amazon.com/security/post/TxPOJBY6FE360K/IAM-policies-and-Bucket-Policies-and-ACLs-Oh-My-Controlling-Access-to-S3-Resourc
source
share