1. Open the AWS Console, launch an EC2 instance, connect to it, and then try to list IAM users using the AWS CLI or Management Console.
2. Type this Commands
# aws iam list-users
3. So, if you’re not able to access it, go to the IAM section, create a role for that purpose, click on the Roles option, then click on Create role. Select the trusted entity and the use case, and then click Next.
4. Select the permissions you want to assign to the role, then click Next.
5. Provide a name for the role, check the permissions assigned, and add tags for identification.
6. finally role is created
7. Go to the EC2 section, select the server, click on Actions, then go to the Security section, and select Modify IAM role. Click on this option.
8. Select the IAM role you want to assign and click on Update IAM role.
9. Verify if the IAM role is attached by checking the instance details under the IAM role section in the EC2 console.
10. Now, connect to the server and try to access the IAM users list using the AWS CLI or Management Console.
END