Problem: We have 2 EC2 instances in public and private subnets that can access the internet. Can we use the aws s3 ls to list S3 bucket?
The answer is no. As you observed when entering the command in the EC2 terminal in the public subnet or private subnet. Even though there is a public S3 endpoint, we don’t have the permission to see the data in S3 buckets as it poses a security risk, potentially compromising data security.
It’s similar to walking down a street and seeing a beautiful house. However, you don’t have the right to enter the house, see how many rooms there are, or what belongings are inside.
This can be explained here
So the question is, what can we do to enable EC2 instances to access and view data within S3 buckets?
We have two options:
aws configure
command. This method is straightforward but highly discouraged. It should be avoided.In this lab, we will practice creating a IAM Role and assigning it to the EC2 instance in the private subnet.
EC2FullAccessS3
as Role name.