Roles
An IAM role is an identity you can create that has specific permissions with credentials that are valid for short durations. Roles can be assumed by entities that you trust. IAM Roles are resource specific (means this role is for a specific EC2 instance for example).
Step 1: Create an EC2 instance.
Step 2: Connect to the above EC2 instance and make sure AWS CLI is already configured on this machine.
Step 3: Go to IAM Service and Select Roles and Click on Create Roles button
Step 4: Select Trusted Entity as AWS Service and Use Case EC2 instance and then click on Next Button
Step 5: Add the permissions to the Role add policy S3FullAccess and click on Next
Step 6: Provide the role name and click on Create Role button
Step 7: Go to EC2 instances and Select the EC2 instance which you have create on Step1
Step 8: Go to Action ---> Security---> ModifyIAM Role and Choose the role as the one which you have created in step 6 and click on save
Step 9: Connect EC2 instances and run the command
aws s3 ls
you will be able to see all the buckets even though you did not configure any profile on this system, it is because of the role.
