deletePolicyVersion method

Future<void> deletePolicyVersion({
  1. required String policyArn,
  2. required String versionId,
})

Deletes the specified version from the specified managed policy.

You cannot delete the default version from a policy using this API. 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.

May throw NoSuchEntityException. May throw LimitExceededException. May throw InvalidInputException. May throw DeleteConflictException. May throw ServiceFailureException.

Parameter policyArn : 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) and AWS Service Namespaces in the AWS General Reference.

Parameter versionId : 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.

Implementation

Future<void> deletePolicyVersion({
  required String policyArn,
  required String versionId,
}) async {
  ArgumentError.checkNotNull(policyArn, 'policyArn');
  _s.validateStringLength(
    'policyArn',
    policyArn,
    20,
    2048,
    isRequired: true,
  );
  ArgumentError.checkNotNull(versionId, 'versionId');
  final $request = <String, dynamic>{};
  $request['PolicyArn'] = policyArn;
  $request['VersionId'] = versionId;
  await _protocol.send(
    $request,
    action: 'DeletePolicyVersion',
    version: '2010-05-08',
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    shape: shapes['DeletePolicyVersionRequest'],
    shapes: shapes,
  );
}