KMSClient.put_key_policy
rboto-kms==0.4.0 · Service index · Types
Model summary (excerpt): Attaches a key policy to the specified KMS key. You can use this operation to set only the default key policy. For more information about key policies, see Key Policies 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 . For examples of adding a key policy in...
Install and imports
Signature
async def put_key_policy(
*,
key_id: str,
policy: str,
policy_name: str | None = None,
bypass_policy_lockout_safety_check: bool | None = None,
) -> None: ...
Arguments without defaults are required. None omits an optional request argument. Static types do not validate resource existence, permissions, lengths, ranges, or conditional service requirements.
Arguments
| Argument | Required | Model notes (excerpt) |
|---|---|---|
key_id |
Yes | 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 |
Yes | 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... |
policy_name |
No | 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... |
bypass_policy_lockout_safety_check |
No | 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... |
Output
None.
| None means a value can be absent. Output mappings include every declared key; optional input keys may be omitted. Unknown output enum/union variants are not automatically valid inputs.
Related types
—
Follow these links for nested inputs and outputs; recursive types link back to the same type page.
Pagination and streaming
No generated paginator for this operation.
No output stream.
Errors
Import from rboto_kms.exceptions:
DependencyTimeoutError, InvalidArnError, KMSInternalError, KMSInvalidStateError, LimitExceededError, MalformedPolicyDocumentError, NotFoundError, UnsupportedOperationError.
Other service failures use the service base error; credential, transport and timeout failures use shared errors.