Tuesday, 18 August 2020

How to assign Roles for EC2 instance

Roles enable us to interact with AWS platform, without having to our EC2 instances access key id and secret key id's. 

in the below post, i will show you. How roles interact with EC2 instances.


Practical Steps:
  1. Login to AWS console.
  2. Navigate to services  --> Security,identity & Competence -->IAM as highlighted below.

3.To view already created roles.Click on Roles in the left side menu. Then Click on Create role option as shown below.                                                                                                                                    



4. Then the below resultant screen will appears.Choose the services that would be using this role.Here i want to use role to EC2 instance. So i am choosing with EC2.

followed by Next.


5. Provide policy information in the below screen. here i am giving Administrator Access policy. and click on Next.        


6.Provide role name in the below highlighted field.Click on create role.                                                     


7.Assign role to EC2 instance: Now navigate to running EC2 instance screen(Services -->Compute section -->EC2-->Running instances). 
Then the screen similar to the below screen will appears.Navigate to Actions from the menu --> instance settings --> Attach/Replace IAM Role.

8. Select the required role that need to assign to EC2 instance & Click on Apply.                                                                   


9.That's it. IAM role assigned to EC2 instance successfully. Click on Close.                                                      


Note: Basically the credential of each EC2 instance are available in home/.aws directory.if the                 administrator role is assigned to particular EC2,then even after deleting the hidden .aws directory in the home direction.Our EC2 instance can be accessed with SSH.                                                                   



Case studies where IAM roles are required for EC2 instance:                                                                   


No comments:

Post a Comment