What You Will Learn
Advanced
- How to write custom IAM policies
- Cross-account roles
- Security best practices
Policy: S3 read-only for one bucketjson
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": ["s3:GetObject", "s3:ListBucket"],
"Resource": [
"arn:aws:s3:::my-bucket",
"arn:aws:s3:::my-bucket/*"
]
}]
}Never use wildcards in production
Action: "*" gives full access to everything. Use specific actions: s3:GetObject, not s3:*.Practical Exercise
Go to IAM -> Policies
Create a custom policy for S3 read-only
Create a role for EC2 to assume
Attach the policy to the role
Launch an EC2 with the role and test access
Key Takeaways
- Write specific policies — never use
*in production. - Roles: temporary access for AWS services.
- Cross-account roles: share access between accounts.
- Always follow least privilege.
- Use IAM Access Analyzer to find over-permissive policies.
Comments
Comments
Post a Comment