Skip to content

PutKeyPolicyRequest

Source code in docs_src/capo_kms/types/put_key_policy_request.py
class PutKeyPolicyRequest(TypedDict, closed=True):
    key_id: "capo_kms.types.key_id_type.KeyIdType"
    """<p>Sets the key policy on the specified KMS key.</p> <p>Specify the key ID or key ARN of the KMS key.</p> <p>For example:</p> <ul> <li> <p>Key ID: <code>1234abcd-12ab-34cd-56ef-1234567890ab</code> </p> </li> <li> <p>Key ARN: <code>arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab</code> </p> </li> </ul> <p>To get the key ID and key ARN for a KMS key, use <a>ListKeys</a> or <a>DescribeKey</a>.</p>"""
    policy_name: NotRequired["capo_kms.types.policy_name_type.PolicyNameType"]
    """<p>The name of the key policy. If no policy name is specified, the default value is <code>default</code>. Valid values are <code>default</code> and <code>AWS_RAM</code>, but you can set only the <code>default</code> key policy. RAM manages the <code>AWS_RAM</code> key policy for KMS keys that you share through RAM. If you specify <code>AWS_RAM</code>, the request fails with a <code>ValidationException</code>, or with an <code>AccessDeniedException</code> if you don't have permission to call <code>PutKeyPolicy</code> with that policy name.</p>"""
    policy: "capo_kms.types.policy_type.PolicyType"
    r"""<p>The key policy to attach to the KMS key.</p> <p>The key policy must meet the following criteria:</p> <ul> <li> <p>The key policy must allow the calling principal to make a subsequent <code>PutKeyPolicy</code> request on the KMS key. This reduces the risk that the KMS key becomes unmanageable. For more information, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/key-policy-default.html#prevent-unmanageable-key">Default key policy</a> in the <i>Key Management Service Developer Guide</i>. (To omit this condition, set <code>BypassPolicyLockoutSafetyCheck</code> to true.)</p> </li> <li> <p>Each statement in the key policy must contain one or more principals. The principals in the key policy must exist and be visible to KMS. When you create a new Amazon Web Services principal, you might need to enforce a delay before including the new principal in a key policy because the new principal might not be immediately visible to KMS. For more information, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/troubleshoot_general.html#troubleshoot_general_eventual-consistency">Changes that I make are not always immediately visible</a> in the <i>Amazon Web Services Identity and Access Management User Guide</i>.</p> </li> </ul> <note> <p>If either of the required <code>Resource</code> or <code>Action</code> elements are missing from a key policy statement, the policy statement has no effect. When a key policy statement is missing one of these elements, the KMS console correctly reports an error, but the <code>PutKeyPolicy</code> API request succeeds, even though the policy statement is ineffective.</p> <p>For more information on required key policy elements, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/key-policy-overview.html#key-policy-elements">Elements in a key policy</a> in the <i>Key Management Service Developer Guide</i>.</p> </note> <p>A key policy document can include only the following characters:</p> <ul> <li> <p>Printable ASCII characters from the space character (<code>\u0020</code>) through the end of the ASCII character range.</p> </li> <li> <p>Printable characters in the Basic Latin and Latin-1 Supplement character set (through <code>\u00FF</code>).</p> </li> <li> <p>The tab (<code>\u0009</code>), line feed (<code>\u000A</code>), and carriage return (<code>\u000D</code>) special characters</p> </li> </ul> <note> <p>If the key policy exceeds the length constraint, KMS returns a <code>LimitExceededException</code>.</p> </note> <p>For information about key policies, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/key-policies.html">Key policies in KMS</a> in the <i>Key Management Service Developer Guide</i>.For help writing and formatting a JSON policy document, see the <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies.html">IAM JSON Policy Reference</a> in the <i> <i>Identity and Access Management User Guide</i> </i>.</p>"""
    bypass_policy_lockout_safety_check: NotRequired[
        "capo_kms.types.boolean_type.BooleanType"
    ]
    """<p>Skips ("bypasses") the key policy lockout safety check. The default value is false.</p> <important> <p>Setting this value to true increases the risk that the KMS key becomes unmanageable. Do not set this value to true indiscriminately.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/key-policy-default.html#prevent-unmanageable-key">Default key policy</a> in the <i>Key Management Service Developer Guide</i>.</p> </important> <p>Use this parameter only when you intend to prevent the principal that is making the request from making a subsequent <a href="https://docs.aws.amazon.com/kms/latest/APIReference/API_PutKeyPolicy.html">PutKeyPolicy</a> request on the KMS key.</p> <p>The key policy lockout safety check and the <code>BypassPolicyLockoutSafetyCheck</code> parameter apply only to the <code>default</code> key policy. The check evaluates only the new <code>default</code> key policy, with <code>kms:PolicyName</code> set to <code>default</code>. It doesn't consider permissions in the <code>AWS_RAM</code> key policy.</p>"""

bypass_policy_lockout_safety_check instance-attribute

bypass_policy_lockout_safety_check: NotRequired[BooleanType]

Skips ("bypasses") the key policy lockout safety check. The default value is false.

Setting this value to true increases the risk that the KMS key becomes unmanageable. Do not set this value to true indiscriminately.

For more information, see Default key policy in the Key Management Service Developer Guide.

Use this parameter only when you intend to prevent the principal that is making the request from making a subsequent PutKeyPolicy request on the KMS key.

The key policy lockout safety check and the BypassPolicyLockoutSafetyCheck parameter apply only to the default key policy. The check evaluates only the new default key policy, with kms:PolicyName set to default. It doesn't consider permissions in the AWS_RAM key policy.

key_id instance-attribute

key_id: KeyIdType

Sets the key policy on the specified KMS key.

Specify the key ID or key ARN of the KMS key.

For example:

  • Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab

  • Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab

To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey.

policy instance-attribute

policy: PolicyType

The key policy to attach to the KMS key.

The key policy must meet the following criteria:

  • The key policy must allow the calling principal to make a subsequent PutKeyPolicy request on the KMS key. This reduces the risk that the KMS key becomes unmanageable. For more information, see Default key policy in the Key Management Service Developer Guide. (To omit this condition, set BypassPolicyLockoutSafetyCheck to true.)

  • Each statement in the key policy must contain one or more principals. The principals in the key policy must exist and be visible to KMS. When you create a new Amazon Web Services principal, you might need to enforce a delay before including the new principal in a key policy because the new principal might not be immediately visible to KMS. For more information, see Changes that I make are not always immediately visible in the Amazon Web Services Identity and Access Management User Guide.

If either of the required Resource or Action elements are missing from a key policy statement, the policy statement has no effect. When a key policy statement is missing one of these elements, the KMS console correctly reports an error, but the PutKeyPolicy API request succeeds, even though the policy statement is ineffective.

For more information on required key policy elements, see Elements in a key policy in the Key Management Service Developer Guide.

A key policy document can include only the following characters:

  • Printable ASCII characters from the space character (\u0020) through the end of the ASCII character range.

  • Printable characters in the Basic Latin and Latin-1 Supplement character set (through \u00FF).

  • The tab (\u0009), line feed (\u000A), and carriage return (\u000D) special characters

If the key policy exceeds the length constraint, KMS returns a LimitExceededException.

For information about key policies, see Key policies in KMS in the Key Management Service Developer Guide.For help writing and formatting a JSON policy document, see the IAM JSON Policy Reference in the Identity and Access Management User Guide .

policy_name instance-attribute

policy_name: NotRequired[PolicyNameType]

The name of the key policy. If no policy name is specified, the default value is default. Valid values are default and AWS_RAM, but you can set only the default key policy. RAM manages the AWS_RAM key policy for KMS keys that you share through RAM. If you specify AWS_RAM, the request fails with a ValidationException, or with an AccessDeniedException if you don't have permission to call PutKeyPolicy with that policy name.