VerifiedPermissions / Client / update_policy

update_policy#

VerifiedPermissions.Client.update_policy(**kwargs)#

Modifies a Cedar static policy in the specified policy store. You can change only certain elements of the UpdatePolicyDefinition parameter. You can directly update only static policies. To change a template-linked policy, you must update the template instead, using UpdatePolicyTemplate.

Note

  • If policy validation is enabled in the policy store, then updating a static policy causes Verified Permissions to validate the policy against the schema in the policy store. If the updated static policy doesn’t pass validation, the operation fails and the update isn’t stored.

  • When you edit a static policy, you can change only certain elements of a static policy:

    • The action referenced by the policy.

    • A condition clause, such as when and unless.

You can’t change these elements of a static policy:

  • Changing a policy from a static policy to a template-linked policy.

  • Changing the effect of a static policy from permit or forbid.

  • The principal referenced by a static policy.

  • The resource referenced by a static policy.

  • To update a template-linked policy, you must update the template instead.

Note

Verified Permissions is eventually consistent . It can take a few seconds for a new or changed element to propagate through the service and be visible in the results of other Verified Permissions operations.

See also: AWS API Documentation

Request Syntax

response = client.update_policy(
    policyStoreId='string',
    policyId='string',
    definition={
        'static': {
            'description': 'string',
            'statement': 'string'
        }
    }
)
Parameters:
  • policyStoreId (string) –

    [REQUIRED]

    Specifies the ID of the policy store that contains the policy that you want to update.

  • policyId (string) –

    [REQUIRED]

    Specifies the ID of the policy that you want to update. To find this value, you can use ListPolicies.

  • definition (dict) –

    [REQUIRED]

    Specifies the updated policy content that you want to replace on the specified policy. The content must be valid Cedar policy language text.

    You can change only the following elements from the policy definition:

    • The action referenced by the policy.

    • Any conditional clauses, such as when or unless clauses.

    You can’t change the following elements:

    • Changing from static to templateLinked.

    • Changing the effect of the policy from permit or forbid.

    • The principal referenced by the policy.

    • The resource referenced by the policy.

    Note

    This is a Tagged Union structure. Only one of the following top level keys can be set: static.

    • static (dict) –

      Contains details about the updates to be applied to a static policy.

      • description (string) –

        Specifies the description to be added to or replaced on the static policy.

      • statement (string) – [REQUIRED]

        Specifies the Cedar policy language text to be added to or replaced on the static policy.

        Warning

        You can change only the following elements from the original content:

        • The action referenced by the policy.

        • Any conditional clauses, such as when or unless clauses.

        You can’t change the following elements:

        • Changing from StaticPolicy to TemplateLinkedPolicy.

        • The effect ( permit or forbid) of the policy.

        • The principal referenced by the policy.

        • The resource referenced by the policy.

Return type:

dict

Returns:

Response Syntax

{
    'policyStoreId': 'string',
    'policyId': 'string',
    'policyType': 'STATIC'|'TEMPLATE_LINKED',
    'principal': {
        'entityType': 'string',
        'entityId': 'string'
    },
    'resource': {
        'entityType': 'string',
        'entityId': 'string'
    },
    'createdDate': datetime(2015, 1, 1),
    'lastUpdatedDate': datetime(2015, 1, 1)
}

Response Structure

  • (dict) –

    • policyStoreId (string) –

      The ID of the policy store that contains the policy that was updated.

    • policyId (string) –

      The ID of the policy that was updated.

    • policyType (string) –

      The type of the policy that was updated.

    • principal (dict) –

      The principal specified in the policy’s scope. This element isn’t included in the response when Principal isn’t present in the policy content.

      • entityType (string) –

        The type of an entity.

        Example: "entityType":"typeName"

      • entityId (string) –

        The identifier of an entity.

        "entityId":"identifier"

    • resource (dict) –

      The resource specified in the policy’s scope. This element isn’t included in the response when Resource isn’t present in the policy content.

      • entityType (string) –

        The type of an entity.

        Example: "entityType":"typeName"

      • entityId (string) –

        The identifier of an entity.

        "entityId":"identifier"

    • createdDate (datetime) –

      The date and time that the policy was originally created.

    • lastUpdatedDate (datetime) –

      The date and time that the policy was most recently updated.

Exceptions

  • VerifiedPermissions.Client.exceptions.ValidationException

  • VerifiedPermissions.Client.exceptions.ServiceQuotaExceededException

  • VerifiedPermissions.Client.exceptions.ConflictException

  • VerifiedPermissions.Client.exceptions.AccessDeniedException

  • VerifiedPermissions.Client.exceptions.ResourceNotFoundException

  • VerifiedPermissions.Client.exceptions.ThrottlingException

  • VerifiedPermissions.Client.exceptions.InternalServerException