Put Key Policy
kms_put_key_policy | R Documentation |
Attaches a key policy to the specified KMS key¶
Description¶
Attaches a key policy to the specified KMS key.
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 multiple programming languages, see Setting a key policy in the Key Management Service Developer Guide.
Cross-account use: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account.
Required permissions: kms:PutKeyPolicy (key policy)
Related operations: get_key_policy
Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency.
Usage¶
kms_put_key_policy(KeyId, PolicyName, Policy,
BypassPolicyLockoutSafetyCheck)
Arguments¶
KeyId |
[required] Sets the key policy on the specified KMS key. Specify the key ID or key ARN of the KMS key. For example:
To get the key ID and key ARN for a KMS key, use
|
PolicyName |
The name of the key policy. If no policy name is specified, the
default value is |
Policy |
[required] The key policy to attach to the KMS key. The key policy must meet the following criteria:
A key policy document can include only the following characters:
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 . |
BypassPolicyLockoutSafetyCheck |
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
|
Value¶
An empty list.
Request syntax¶
svc$put_key_policy(
KeyId = "string",
PolicyName = "string",
Policy = "string",
BypassPolicyLockoutSafetyCheck = TRUE|FALSE
)
Examples¶
## Not run:
# The following example attaches a key policy to the specified KMS key.
svc$put_key_policy(
KeyId = "1234abcd-12ab-34cd-56ef-1234567890ab",
Policy = "{\n \"Version\": \"2012-10-17\",\n \"Id\": \"custom-policy-2016-...",
PolicyName = "default"
)
## End(Not run)