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.
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: GetKeyPolicy
Use a bare-bones client and the command you need to make an API call.
import { KMSClient, PutKeyPolicyCommand } from "@aws-sdk/client-kms"; // ES Modules import // const { KMSClient, PutKeyPolicyCommand } = require("@aws-sdk/client-kms"); // CommonJS import const client = new KMSClient(config); const command = new PutKeyPolicyCommand(input); const response = await client.send(command);
PutKeyPolicyCommandInput for command's
input
shape.PutKeyPolicyCommandOutput for command's
response
shape.config for KMSClient's
config
shape.