IAM policies attached directly to a user

Review directly assigned user policies and manage shared permissions through groups or roles.

Description

iam_type in community.aws.iam_policy selects the identity that receives an inline policy. Manage shared user permissions through a group. For workloads, consider a role with temporary credentials.

Potential impact

A per-user policy can outlive the user’s assignment. Moving the same document to a group leaves its permissions intact.

Remediation

Limit admin_policy.json to required actions and resources. Add approved users to the destination group, verify access through its policy, then remove the old user policy.

Examples

The policy file, user and group definitions are omitted.

Before

yaml
- name: Set the user’s inline policy
  community.aws.iam_policy:
    iam_type: user
    iam_name: administrators
    policy_name: Admin
    state: present
    policy_document: admin_policy.json

The first task sets the Admin inline policy on the user named administrators.

After

yaml
- name: Set the group’s inline policy
  community.aws.iam_policy:
    iam_type: group
    iam_name: administrators
    policy_name: Admin
    state: present
    policy_document: admin_policy.json

The second sets Admin on the group of the same name. Manage the old user policy and group membership separately.

References