Description
Attach a managed IAM policy to a group when its members need the same permissions. Direct attachments require tracking a separate exception for each user.
Potential impact
An overlooked attachment can leave access in place after a user changes roles.
Remediation
Add approved users to the group, verify access through the group, then remove the direct attachment. Document the purpose and review date of any remaining exceptions.
Examples
TestUser and TestGroup must already exist. Set the bucket and object scope to the data the group needs to read.
Before
yaml
Resources:
CreateTestDBPolicy:
Type: "AWS::IAM::ManagedPolicy"
Properties:
Description: Read approved S3 objects
Path: /
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action: s3:GetObject
Resource: arn:aws:s3:::example-bucket/*
Users:
- TestUser
After
yaml
Resources:
CreateTestDBPolicy:
Type: "AWS::IAM::ManagedPolicy"
Properties:
Description: Read approved S3 objects
Path: /
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action: s3:GetObject
Resource: arn:aws:s3:::example-bucket/*
Groups:
- TestGroup
Both excerpts allow s3:GetObject. Changing Users to Groups moves the policy attachment. Add TestUser to the group separately.