How To Access AWS S3 From EC2 (2 Min) | Using IAM Role

preview_player
Показать описание
In this tutorial, you'll learn how to access AWS S3 buckets from an EC2 instance using an IAM Role.



Video Transcript

Hi guys, this is Abhi from Gokcedb. In this video, you're going to learn how to access s3 buckets from an ec2 instance in AWS. Let's start by navigating to the ec2 service then click on instances and hit launch instances. Give your instance a name then scroll down to the key pair section.

I'm going to select proceed without a key pair because we don't need one in this example. I'm going to leave everything else to default then click on launch instance. Click on view all instances then wait a few minutes for the instance state to change to running.

Click on the instance ID then hit connect. Click on connect again to launch the ec2 instance connect session. If I run the ls ltr command on my home directory you'll see that it's empty which is expected.

Next, I'm going to navigate to the s3 service and go inside my test bucket. As you can see, there is only one test file here. I'm going to grab the s3 URI and see if I can access this file from my ec2 instance.

Use the AWS s3 ls command to see if you can list this file. Seems like we don't have enough permission to do that. Navigate the AWS console and search for IAM.

Click on roles then click on create the role. Underuse case, select ec2 then hit next. Search for s3 then select amazon s3 read-only access and click on next.

Give your role a name then click on create a role. Now, go back to the ec2 window and click on the actions drop-down. Select modify IAM role under security then select the role that we just created.

Hit update then goes back to the ec2 instance connect session. This time if you return the AWS S3 command you should be able to list your test file. To copy the test file in your home directory, use the AWS s3 cp command.

Now you can cap this file to see what's inside it. There you have it. Make sure you like, subscribe, and turn on the notification bell. Until next time.
Рекомендации по теме
Комментарии
Автор

I was impressed with how you do the presentation for your tutorial, it's easy to understand for all your viewers here. Thanks, Gokce DB...😊

bert
welcome to shbcf.ru