AWS IAM (Identity and Access Management) kiểm soát authentication (ai được phép vào) và authorization (được phép làm gì) trong AWS account.
Các định danh: IAM User — định danh cho người dùng cụ thể hoặc ứng dụng, có credentials dài hạn — không nên dùng cho ứng dụng chạy trên AWS. IAM Group — nhóm chứa Users, áp dụng policy chung cho cả nhóm. IAM Role — định danh không có credentials dài hạn, được assume bởi AWS service (EC2, Lambda), user khác, hoặc external identity (SAML, OIDC); credentials tạm thời qua STS (15 phút đến 12 giờ).
IAM Policy là JSON document định nghĩa permissions; có 2 loại: Identity-based policy (attach vào user/group/role) và Resource-based policy (attach vào resource như S3 bucket, SQS queue — cho phép cross-account access). Policy evaluation: explicit Deny > explicit Allow > implicit Deny.
Best practices:
- Không dùng root account (tạo admin IAM user)
- Bật MFA cho mọi user
- Principle of least privilege
- Dùng Roles thay vì access keys cho EC2/Lambda
- Rotate access keys định kỳ
- Dùng IAM Access Analyzer để phát hiện over-permissive policies
- Dùng Permission Boundary để giới hạn max permissions delegate được
AWS IAM (Identity and Access Management) controls authentication (who can access) and authorization (what they are allowed to do) within an AWS account.
Identities: IAM User — an identity for a specific person or application with long-term credentials — should not be used for applications running on AWS. IAM Group — a collection of Users with a shared policy applied to all members. IAM Role — an identity with no long-term credentials; assumed by AWS services (EC2, Lambda), other users, or external identities (SAML, OIDC); temporary credentials via STS (15 minutes to 12 hours).
An IAM Policy is a JSON document defining permissions; two types: Identity-based policies (attached to users/groups/roles) and Resource-based policies (attached to resources like S3 buckets and SQS queues — enabling cross-account access). Policy evaluation order: explicit Deny > explicit Allow > implicit Deny.
Best practices:
- Do not use the root account (create an admin IAM user)
- Enable MFA for all users
- Principle of least privilege
- Use Roles instead of access keys for EC2/Lambda
- Rotate access keys regularly
- Use IAM Access Analyzer to detect over-permissive policies
- Use Permission Boundaries to limit the maximum permissions that can be delegated