GetPolicyVersionCommand

Retrieves information about the specified version of the specified managed policy, including the policy document.

Policies returned by this operation are URL-encoded compliant with RFC 3986 . You can use a URL decoding method to convert the policy back to plain JSON text. For example, if you use Java, you can use the decode method of the java.net.URLDecoder utility class in the Java SDK. Other languages and SDKs provide similar functionality.

To list the available versions for a policy, use ListPolicyVersions.

This operation retrieves information about managed policies. To retrieve information about an inline policy that is embedded in a user, group, or role, use GetUserPolicy, GetGroupPolicy, or GetRolePolicy.

For more information about the types of policies, see Managed policies and inline policies  in the IAM User Guide.

For more information about managed policy versions, see Versioning for managed policies  in the IAM User Guide.

Example Syntax

Use a bare-bones client and the command you need to make an API call.

import { IAMClient, GetPolicyVersionCommand } from "@aws-sdk/client-iam"; // ES Modules import
// const { IAMClient, GetPolicyVersionCommand } = require("@aws-sdk/client-iam"); // CommonJS import
const client = new IAMClient(config);
const input = { // GetPolicyVersionRequest
  PolicyArn: "STRING_VALUE", // required
  VersionId: "STRING_VALUE", // required
};
const command = new GetPolicyVersionCommand(input);
const response = await client.send(command);
// { // GetPolicyVersionResponse
//   PolicyVersion: { // PolicyVersion
//     Document: "STRING_VALUE",
//     VersionId: "STRING_VALUE",
//     IsDefaultVersion: true || false,
//     CreateDate: new Date("TIMESTAMP"),
//   },
// };

GetPolicyVersionCommand Input

See GetPolicyVersionCommandInput for more details

Parameter
Type
Description
PolicyArn
Required
string | undefined

The Amazon Resource Name (ARN) of the managed policy that you want information about.

For more information about ARNs, see Amazon Resource Names (ARNs)  in the Amazon Web Services General Reference.

VersionId
Required
string | undefined

Identifies the policy version to retrieve.

This parameter allows (through its regex pattern ) a string of characters that consists of the lowercase letter 'v' followed by one or two digits, and optionally followed by a period '.' and a string of letters and digits.

GetPolicyVersionCommand Output

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.
PolicyVersion
PolicyVersion | undefined

A structure containing details about the policy version.

Throws

Name
Fault
Details
InvalidInputException
client

The request was rejected because an invalid or out-of-range value was supplied for an input parameter.

NoSuchEntityException
client

The request was rejected because it referenced a resource entity that does not exist. The error message describes the resource.

ServiceFailureException
server

The request processing has failed because of an unknown error, exception or failure.

IAMServiceException
Base exception class for all service exceptions from IAM service.