create_policy_version

create_policy_version(**kwargs)

Creates a new version of the specified IoT policy. To update a policy, create a new policy version. A managed policy can have up to five versions. If the policy has five versions, you must use DeletePolicyVersion to delete an existing version before you create a new one.

Optionally, you can set the new version as the policy's default version. The default version is the operative version (that is, the version that is in effect for the certificates to which the policy is attached).

Requires permission to access the CreatePolicyVersion action.

See also: AWS API Documentation

Request Syntax

response = client.create_policy_version(
    policyName='string',
    policyDocument='string',
    setAsDefault=True|False
)
Parameters
  • policyName (string) --

    [REQUIRED]

    The policy name.

  • policyDocument (string) --

    [REQUIRED]

    The JSON document that describes the policy. Minimum length of 1. Maximum length of 2048, excluding whitespace.

  • setAsDefault (boolean) -- Specifies whether the policy version is set as the default. When this parameter is true, the new policy version becomes the operative version (that is, the version that is in effect for the certificates to which the policy is attached).
Return type

dict

Returns

Response Syntax

{
    'policyArn': 'string',
    'policyDocument': 'string',
    'policyVersionId': 'string',
    'isDefaultVersion': True|False
}

Response Structure

  • (dict) --

    The output of the CreatePolicyVersion operation.

    • policyArn (string) --

      The policy ARN.

    • policyDocument (string) --

      The JSON document that describes the policy.

    • policyVersionId (string) --

      The policy version ID.

    • isDefaultVersion (boolean) --

      Specifies whether the policy version is the default.

Exceptions

  • IoT.Client.exceptions.ResourceNotFoundException
  • IoT.Client.exceptions.MalformedPolicyException
  • IoT.Client.exceptions.VersionsLimitExceededException
  • IoT.Client.exceptions.InvalidRequestException
  • IoT.Client.exceptions.ThrottlingException
  • IoT.Client.exceptions.UnauthorizedException
  • IoT.Client.exceptions.ServiceUnavailableException
  • IoT.Client.exceptions.InternalFailureException