← All posts
2 min read

List managed policies attached to an IAM user

#aws#cli#iam#security#identity
📑 On this page

Part 92 of AWS from Zero. This lesson changes or inspects one IAM concept so the permission model stays understandable.

What we are learning

Direct attachments are only one permission source, but their policy ARNs make further inspection straightforward.

Before you run it

aws sts get-caller-identity
ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
USER_NAME="aws-zero-learner"
GROUP_NAME="aws-zero-readers"
ROLE_NAME="aws-zero-demo-role"

IAM is global rather than regional. Use a sandbox account and a delegated administrator identity, never root access keys.

The command

aws iam list-attached-user-policies \
  --user-name "$USER_NAME"

IAM writes can take a short time to propagate. Inspect the resource after every change.

Inspect the result

aws iam list-attached-user-policies \
  --user-name "$USER_NAME" \
  --query "AttachedPolicies[].{Name:PolicyName,Arn:PolicyArn}" \
  --output table

Read the returned ARN, path, IDs, and attachment state instead of checking only the command exit code.

One tiny variation

aws iam list-attached-user-policies \
  --user-name "$USER_NAME" \
  --path-prefix "/aws-service-role/"

Path filters are useful only when policy paths are part of your organization convention.

Common mistake

AWS managed policies can change over time. An attachment name alone is not a permanent statement of exact permissions.

Cleanup

# This lesson is read-only or reuses a named demo identity.
aws sts get-caller-identity

Keep shared demo identities only while following the IAM sequence. Part 125 removes them in dependency order.

Next, we will learn List inline policies on an IAM user.

Official AWS CLI reference