Connect S3 Bucket to EC2 Instance using IAM Role| Create IAM Role|Create EC2 Machine

Опубликовано: 15 Октябрь 2024
на канале: sumit kumar
475
12

In This video we will learn to access S3 bucket from EC2.
1) create EC2 machine:-
2)login from VS Code:-
3)Try to access S3 , it will fail
4)We will create IAM service role for EC2 and attach S3 full access policy
5)Try to access S3 , it will work
To create an IAM role for an EC2 instance that has full access to S3, you can follow these steps:

Go to the IAM console in the AWS Management Console.

Click on "Roles" in the left-hand menu and then click the "Create role" button.

Select "AWS service" as the type of trusted entity, and choose "EC2" as the service that will use this role. Click "Next: Permissions" to continue.

In the "Attach permissions policies" step, search for "AmazonS3FullAccess" and select it. This policy provides full access to S3. Click "Next: Tags" to continue.

(Optional) Add tags to your role, and then click "Next: Review" to continue.

Enter a name for your role in the "Role name" field, and then click "Create role".

Your new IAM role is now created and can be attached to an EC2 instance. To attach the role to an EC2 instance, follow these steps:

Go to the EC2 console in the AWS Management Console.

Select the EC2 instance that you want to attach the role to.

Click the "Actions" button, select "Instance Settings", and then select "Attach/Replace IAM Role".

Select the IAM role that you created, and then click "Apply".

Your EC2 instance now has an IAM role attached that provides full access to S3. You can use the AWS CLI or SDK to interact with S3 on the EC2 instance using the credentials provided by the IAM role.