Shared Responsibility Model and AWS IAM Basics: Users, Groups, Roles, Policies and Least Privilege
Shared Responsibility Model
Security in AWS is a partnership. AWS protects the cloud itself. You protect what you put in it.
| AWS is responsible for: security OF the cloud | You are responsible for: security IN the cloud |
| Buildings, power, cooling, physical security | Your data and who can access it |
| Hardware, servers, network cables | IAM users, passwords, MFA, permissions |
| Virtualization layer and global network | Operating system patches on EC2 |
| Managed service software (for example the RDS engine platform) | Security group and firewall settings, encryption choices, application code |
- The responsibility shifts with the service type: with EC2 you patch the guest OS, with Lambda or S3 AWS handles much more, but you still control access and data
- Easy memory: AWS = hardware and facilities. You = data, access, configuration
Why IAM?
AWS Identity and Access Management (IAM) decides who can do what on which resources. It is free and global.
| Term | Meaning | Example |
| Authentication | Proving who you are | Password plus MFA code |
| Authorization | What you are allowed to do | Can read S3, cannot delete EC2 |
| Principal | Someone or something that makes a request | A user, a role, an application |
IAM Building Blocks
| Item | Meaning | Tip |
| Root user | The account owner. Unlimited | MFA on, no keys, rarely used |
| IAM user | A person or app identity with a name and credentials | One user per person. Never share |
| IAM group | A collection of users that share permissions | Developers, Admins, Auditors |
| IAM role | An identity with permissions that is assumed temporarily by a user, service or another account | EC2 uses a role to call S3 with no keys |
| IAM policy | A JSON document that lists permissions | Attach to users, groups or roles |
| Permission set (Identity Center) | A set of policies given to workforce users across accounts | Preferred way for people to sign in |
Reading a Policy
json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["s3:GetObject", "s3:ListBucket"],
"Resource": ["arn:aws:s3:::my-photos", "arn:aws:s3:::my-photos/*"]
}
]
}
| Part | Meaning |
Effect | Allow or Deny |
Action | Which API calls (service:Action) |
Resource | Which things, written as an ARN (Amazon Resource Name) |
Condition (optional) | Extra rules such as source IP, MFA, time or tags |
Golden rule Everything is denied by default. You must allow it. An explicit Deny always beats an Allow.
Types of Policies You Meet First
- AWS managed policies: ready-made by AWS, like
AmazonS3ReadOnlyAccess or AdministratorAccess
- Customer managed policies: you write and reuse them
- Inline policies: attached directly to one identity (use rarely)
- Resource-based policies: attached to a resource such as an S3 bucket
Least Privilege
Least privilege means giving only the permissions needed for the job, nothing more. Start small and add when needed.
| Too much | Better |
AdministratorAccess for every developer | Developers can use EC2 and S3 in the dev account only |
s3:* on * | s3:GetObject on one bucket |
| One shared login | One user per person with MFA |
Roles: Temporary Credentials, No Keys
A role has no password or permanent keys. Whoever assumes it receives temporary credentials that expire. This is safer than storing access keys.
bash
# 1. Trust policy: who may assume the role (EC2 service here)
cat > trust.json <<'EOF'
{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Principal":{"Service":"ec2.amazonaws.com"},"Action":"sts:AssumeRole"}]}
EOF
# 2. Create the role and give it S3 read-only permission
aws iam create-role --role-name WebServerRole --assume-role-policy-document file://trust.json
aws iam attach-role-policy --role-name WebServerRole --policy-arn arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess
# 3. Wrap it in an instance profile so EC2 can use it
aws iam create-instance-profile --instance-profile-name WebServerProfile
aws iam add-role-to-instance-profile --instance-profile-name WebServerProfile --role-name WebServerRole
- Use roles for EC2, Lambda, ECS and for cross-account access
- Never put access keys inside code or a server image
Users, Groups and Policies by CLI
bash
aws iam create-group --group-name Developers
aws iam attach-group-policy --group-name Developers --policy-arn arn:aws:iam::aws:policy/PowerUserAccess
aws iam create-user --user-name asha
aws iam add-user-to-group --user-name asha --group-name Developers
aws iam list-users --query 'Users[].UserName'
aws iam get-account-summary --query 'SummaryMap.[Users,Groups,Roles,Policies]'
Passwords, MFA and Access Keys
| Item | Best practice |
| Password policy | Minimum length, mix of characters, expiration, prevent reuse |
| MFA | Enable for root and every human user. Authenticator app, passkey/FIDO2 or hardware key |
| Access keys | Only for programs outside AWS. Rotate often, delete unused ones, never commit to Git |
| Credential report | Downloadable CSV of all users with password age, MFA and key status |
| Access Advisor | Shows which services a user really used so you can remove extra permissions |
| Access Analyzer | Finds resources shared with outsiders |
Common Beginner Mistakes
- Using the root user for daily work
- Giving admin to everyone
- Hard-coding access keys in code or public repositories
- Forgetting MFA
- Not removing permissions of people who leave
Practice
- Create a group
Readers with ReadOnlyAccess and a user in it, then sign in as that user and try to create an EC2 instance (it should fail)
- Write a policy that only allows reading one S3 bucket
- Create a role for EC2 with S3 read access
- Download the credential report and find users without MFA
Conclusion
AWS secures the cloud, you secure what is in it. Use IAM with users, groups, roles and JSON policies, follow least privilege, protect logins with MFA, and prefer roles with temporary credentials over long-lived keys.
Quick Summary: shared responsibility; IAM terms; policy; policy types; least privilege; roles; CLI; MFA and keys; mistakes.