IAM policy attached directly to users

Check whether shared permissions can be managed through a group.

Description

Manage permissions shared by IAM users doing the same work through Groups on AWS::IAM::Policy. Review direct user exceptions separately.

Potential impact

A direct attachment can leave a user with access after their duties change.

Remediation

Confirm group membership and effective access before removing redundant direct attachments. The policy’s explicit denies also apply to other group members.

Examples

Define the SQS queue with logical ID myqueue or replace !GetAtt myqueue.Arn with its ARN. The policy allows sqs:* on that queue and explicitly denies those actions on other resources. Check the required actions and membership before moving it from the two users to myexistinggroup1.

Before

yaml
AWSTemplateFormatVersion: "2010-09-09"
Description: Policy attachment comparison
Resources:
    myuser:
      Type: AWS::IAM::Policy
      Properties:
        PolicyName: giveaccesstoqueueonly
        PolicyDocument:
          Version: '2012-10-17'
          Statement:
          - Effect: Allow
            Action:
            - sqs:*
            Resource:
            - !GetAtt myqueue.Arn
          - Effect: Deny
            Action:
            - sqs:*
            NotResource:
            - !GetAtt myqueue.Arn
        Users:
          - existinguser1
          - existinguser2

After

yaml
AWSTemplateFormatVersion: "2010-09-09"
Description: Policy attachment comparison
Resources:
    myuser:
      Type: AWS::IAM::Policy
      Properties:
        PolicyName: giveaccesstoqueueonly
        PolicyDocument:
          Version: '2012-10-17'
          Statement:
          - Effect: Allow
            Action:
            - sqs:*
            Resource:
            - !GetAtt myqueue.Arn
          - Effect: Deny
            Action:
            - sqs:*
            NotResource:
            - !GetAtt myqueue.Arn
        Groups:
          - myexistinggroup1

References