DeletePolicyVersionCommand

Deletes the specified version from the specified managed policy.

You cannot delete the default version from a policy using this operation. To delete the default version from a policy, use DeletePolicy. To find out which version of a policy is marked as the default version, use ListPolicyVersions.

For information about versions for managed policies, 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, DeletePolicyVersionCommand } from "@aws-sdk/client-iam"; // ES Modules import
// const { IAMClient, DeletePolicyVersionCommand } = require("@aws-sdk/client-iam"); // CommonJS import
const client = new IAMClient(config);
const input = { // DeletePolicyVersionRequest
  PolicyArn: "STRING_VALUE", // required
  VersionId: "STRING_VALUE", // required
};
const command = new DeletePolicyVersionCommand(input);
const response = await client.send(command);
// {};

DeletePolicyVersionCommand Input

See DeletePolicyVersionCommandInput for more details

Parameter
Type
Description
PolicyArn
Required
string | undefined

The Amazon Resource Name (ARN) of the IAM policy from which you want to delete a version.

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

VersionId
Required
string | undefined

The policy version to delete.

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.

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

DeletePolicyVersionCommand Output

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

Throws

Name
Fault
Details
DeleteConflictException
client

The request was rejected because it attempted to delete a resource that has attached subordinate entities. The error message describes these entities.

InvalidInputException
client

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

LimitExceededException
client

The request was rejected because it attempted to create resources beyond the current Amazon Web Services account limits. The error message describes the limit exceeded.

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.