aws Verified current stable Not installed? Security

Aws / Describe Iam Policy

Describe Iam Policy

Describes a specified IAM policy.

$
Terminal
aws iam get-policy --policy-arn arn:aws:iam::aws:policy/<policy_name>

When To Use

When needing to understand permissions and rules defined by a specific IAM policy.

Pro Tip

Review `Policy` JSON for any potential security vulnerabilities or overly permissive settings.

Command Builder

Tune the command before you copy it

Back to syntax
$
Generated Command
aws iam get-policy --policy-arn arn:aws:iam::aws:policy/<policy_name>

Terminal Output

Expected runtime feedback

Simulated preview
>
Output
Policy
----------------------------------
Policy Name               : {{policy_name}}
Policy Id                 : ABCDEFGHIJKLMNOP
Default Version Id        : v1
Attachment Count          : 5
Create Date               : 2021-01-01T12:00:00Z
Update Date               : 2023-01-01T12:00:00Z
Permissions                : {"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":"s3:*","Resource":"*"}]}

Anatomy of Output

Understanding the result

PolicyName: ExamplePolicy Policy Title

The display name of the IAM policy.

PolicyId: p-EXAMPLEID Policy Identifier

Unique identifier for the IAM policy.

CreateDate: 2023-02-20T10:00:00Z Creation Date

Indicates when the policy was first created.

Power User Variants

Optimized versions

aws iam get-policy --policy-arn arn:aws:iam::aws:policy/ExamplePolicy --query 'Policy.DefaultVersionId'

Retrieve the default version ID of the policy.

aws iam get-policy --policy-arn arn:aws:iam::aws:policy/ExamplePolicy --output json

Formats the output to JSON for easier reading.

aws iam get-policy --policy-arn arn:aws:iam::aws:policy/ExamplePolicy --profile specific-profile

Uses a designated profile when describing the policy.

Troubleshooting

Common pitfalls

An error occurred (NoSuchEntity) when calling the GetPolicy operation: The specified policy does not exist.

Solution: Check the policy name and confirm it matches an existing policy in your account.

An error occurred (AccessDenied) when calling the GetPolicy operation: User does not have permission to perform this operation.

Solution: Review IAM permissions, ensuring the user has access to describe policies.

An error occurred (ServiceFailure) when calling the GetPolicy operation: Internal error occurred with the service.

Solution: Retry the command; this might be due to temporary issues with AWS.

Command Breakdown

What each part is doing

aws
Base Command
The executable that performs this operation. Here it runs Aws before the shell applies any redirect operators.
<policy_name>
policy name
The value supplied for policy name.
--policy-arn
Command Option
Tool-specific option used by this command invocation.

How To Run

Execution path

  1. Step 1

    Run the command: aws iam get-policy --policy-arn arn:aws:iam::aws:policy/{{policy_name}}

  2. Step 2

    Verify the output to understand the IAM policy details and permissions.

Alternative Approaches

Comparable commands in other tools

Alternative security tools for the same job.