Listing the files in EC2 from s3 using Amazon Linux 🤠

Listing the files in EC2 from s3 using Amazon Linux 🤠

Tasks to do:

  1. Login as root user and create IAM group called Administrators. Attach the admin managed policy, to the administrator group.

  2. Customize a sign-in link, and write down the new link name in full.

  3. Create a password policy for your account.

  4. While logged in as the root user, create a new IAM user called Administrator.

  5. Add the new user created above to the Administrators group.

  6. On the details page for the administrator user, create a password.

  7. Log out as the root user.

  8. Use the customized sign-in link to sign in as Administrator.

  9. While signed in as Administrator, create an Amazon EC2-type role named TestClient.

  10. Attach the managed policy,to the TestClient.

  11. Launch an Amazon Linux EC2 instance with the new role attached.

  12. SSH into the new instance, and use the CLI to list the contents of an Amazon S3 bucket.

  13. Now, add a policy to your IAM Administrator user with a conflicting permission. Use the policy generator to create a new policy. Create the policy with effect: Deny; AWS Service: Amazon S3;Actions:; and ARN:.

  14. Attach the new policy to the Administrators group.

  15. Use the CLI to attempt to list the contents of an Amazon S3 bucket. The policy that allows access and the policy that denies access should resolve to deny access.

Task 1

  • Entered my credentials and logged into the AWS Management Console



  • Launched the AWS IAM and created a group with AdministratorAccess Policy attached to it


Task 2

  • Customized the Sign In URL


Task 3

  • Adjusted the Password Policy in the IAM


Task 4

  • Created Administrator User and assigned the user to Administrator Group


Task 5

  • Logged into the Administrator User


Task 6

  • Created a TestClient Role for the EC2 which allows to read the files from s3

    { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "" }, "Action": "sts:AssumeRole" } ] }

Task 7

  • Created an instance with TestClient Role


  • Created an s3 bucket named as tcsions3bucket


  • Uploaded 3 different files to the bucke


Task 8

  • Logged into the ec2 server using SSH

  • Listed the availables buckets using the command: aws s3 ls

  • Listed the list of objects in the bucket using the command: aws s3 ls s3://tcsions3bucket


Task 9

  • Updated the policy of the role which denies the access to the s3.

    { "Version": "2012-10-17", "Statement": [ { "Effect": "Deny", "Principal": { "Service": "" }, "Action": "sts:AssumeRole" } ] }

  • After the policy updation, the listing is denied from the ec2.



Thus I listed the files of the s3 bucket in the ec2 using iam service.

Did you find this article valuable?

Support Dev Maestro by becoming a sponsor. Any amount is appreciated!