IAM is an AWS service that allows humans and programs to securely access AWS services and infrastructure.
IAM provides very granular control over the resources. You can specify under what conditions the resorce can be accessed. Five conditions are supported. You can remember these five conditions using the Acronym WWW-RA
Who can access (IAM Principal)
From Where? a specific ip/CIDR
When? At a specific time range.
The Resource that can be accessed
The Action that can be performed on that resource
What is IAM not used for?
IAM is not OS level user management tool. For OS level user management use LDAP or Active Directory Services.
IAM is not application level user management tool. For application level user management such as the users that registered on your eCommerce website, use Application User Repositories such as ASP.NET Identity Framework on windows or in case of Mobile apps, use AWS Cognito.
At the heart of IAM lies the entity called the principal. What is IAM principal? IAM principal is an IAM entity (human or application) that can access AWS resources. Three types of principals:
use email/password to access
can use root user keys to access AWS services from applications but strongly NOT recommended
Should enable MFA (Multi Factor Authentication) for better security
Can be person or application
Can have userid/password
Can have Security Access Key ID/Secret Access Key combination (ID is 20 char and Secret Access Key is 40 char)
Access Key Rotation for security purposes
Every principal can have two sets of access keys.
You start with one key set
After some time you create a new key set
Keep both old and new key sets active for some time while your programs update your keys.
Later delete old key set.
Can be associated with policies containing permissions to ALLOW/DENY access to specific AWS resources
IAM roles/temporary security tokens
Roles are used to provide specific privileges to specific IAM principals for a set duration (time window) of min 15 min to 36 hours
Following use cases of Roles are important to remember
EC2 roles can be assigned to give access to processes on the EC2 to access AWS resources.
In fact it is a best practice to use the EC2 roles as opposed to using the Access Key (Access ID/Secret Access Key combo) inside the config files or hard coding in side the program code.
Also with this practice, no need to worry about access key rotation which is highly recommended otherwise.
Roles can be changed and policies can be modified without stopping the EC2 instances. New privileges will be effective immediately.
An IAM role automatically deploys AWS credentials to resources that assume it. Select the EC2 instance profile that contains the required IAM role. If you created your IAM role using the console, the instance profile has the same name as your IAM role. Learn more about IAM roles for EC2
Cross Account Access: Provide access to IAM principals from another account. This is better practice than distributing Access Keys.
Users of trusted external systems such as Google/Facebook users can be granted access to AWS resources thru roles and temp security tokens. OpenId Connect (OIDC) protocol is used.
Users of LDAP/Active Directory are federated thru Security Assertion Markup Language (SAML)