AWS Security & IAM
Learn how to keep your AWS account safe. IAM, Roles, Policies, and security best practices.
What is IAM?
IAM (Identity and Access Management) is AWS's security service. It controls who can access your AWS resources and what they can do.
Users
Individual people
Groups
Collections of users
Roles
For services and EC2
IAM Users and Groups
Users
- Individual people accessing AWS
- Each has unique credentials
- Can have password and access keys
- Never share credentials!
Groups
- Collection of users with same permissions
- Example: Admins, Developers, ReadOnly
- Attach policies to groups
- Users inherit group permissions
IAM Roles
Roles are for AWS services that need permissions. Instead of giving users access keys, you give services permissions through roles.
EC2 Roles
Give EC2 access to S3, RDS, etc.
Lambda Roles
Give functions permissions
Cross-Account
Access resources in another account
IAM Policies
Policies are JSON documents that define what actions are allowed or denied.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:PutObject"
],
"Resource": "arn:aws:s3:::my-bucket/*"
}
]
}
Security Best Practices
Exercise: Create an IAM User
Task: Create an IAM user with limited permissions.
- Go to IAM → Users → Add user
- Name:
developer - Select "Programmatic access" and "AWS Management Console access"
- Create a group called
dev-groupwith EC2 and S3 read-only - Add the user to the group
- Save the access key and secret key
- Test the user by logging in
Show Solution
# Using AWS CLI to create a user
aws iam create-user --user-name developer
# Create access key
aws iam create-access-key --user-name developer
# Attach policy for S3 read-only
aws iam attach-user-policy --user-name developer --policy-arn arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess
Key Takeaway
IAM is the foundation of AWS security. Use groups for managing users, roles for services, and policies for fine-grained permissions. Always follow the principle of least privilege!