Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Use ListPolicyVersions with a CLI - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Use ListPolicyVersions with a CLI

The following code examples show how to use ListPolicyVersions.

Action examples are code excerpts from larger programs and must be run in context. You can see this action in context in the following code examples:

CLI
AWS CLI

To list information about the versions of the specified managed policy

This example returns the list of available versions of the policy whose ARN is arn:aws:iam::123456789012:policy/MySamplePolicy.

aws iam list-policy-versions \ --policy-arn arn:aws:iam::123456789012:policy/MySamplePolicy

Output:

{ "IsTruncated": false, "Versions": [ { "VersionId": "v2", "IsDefaultVersion": true, "CreateDate": "2015-06-02T23:19:44Z" }, { "VersionId": "v1", "IsDefaultVersion": false, "CreateDate": "2015-06-02T22:30:47Z" } ] }

For more information, see Policies and permissions in IAM in the AWS IAM User Guide.

PowerShell
Tools for PowerShell

Example 1: This example returns the list of available versions of the policy whose ARN is arn:aws:iam::123456789012:policy/MyManagedPolicy. To get the policy document for a specific version, use the Get-IAMPolicyVersion command and specify the VersionId of the one you want.

Get-IAMPolicyVersionList -PolicyArn arn:aws:iam::123456789012:policy/MyManagedPolicy

Output:

CreateDate Document IsDefaultVersion VersionId ---------- -------- ---------------- --------- 2/12/2015 9:39:53 AM True v2 2/12/2015 9:39:09 AM False v1
AWS CLI

To list information about the versions of the specified managed policy

This example returns the list of available versions of the policy whose ARN is arn:aws:iam::123456789012:policy/MySamplePolicy.

aws iam list-policy-versions \ --policy-arn arn:aws:iam::123456789012:policy/MySamplePolicy

Output:

{ "IsTruncated": false, "Versions": [ { "VersionId": "v2", "IsDefaultVersion": true, "CreateDate": "2015-06-02T23:19:44Z" }, { "VersionId": "v1", "IsDefaultVersion": false, "CreateDate": "2015-06-02T22:30:47Z" } ] }

For more information, see Policies and permissions in IAM in the AWS IAM User Guide.

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.