Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PutKeyPolicyCommand

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

example

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);
see

PutKeyPolicyCommandInput for command's input shape.

see

PutKeyPolicyCommandOutput for command's response shape.

see

config for KMSClient's config shape.

Hierarchy

Implements

Index

Constructors

constructor

Properties

Readonly input

input: PutKeyPolicyCommandInput

Readonly middlewareStack

middlewareStack: IMiddlewareStack<PutKeyPolicyCommandInput, PutKeyPolicyCommandOutput>

Methods

Static getEndpointParameterInstructions