API Reference

PREVIEW DOCUMENTATION - This is a preview of a new format for the AWS SDK for Go API Reference documentation. For the current AWS SDK for Go API Reference, see

We welcome your feedback on this new version of the documentation. Send your comments to


import ""

type PutKeyPolicyInput struct { BypassPolicyLockoutSafetyCheck *bool `type:"boolean"` KeyId *string `min:"1" type:"string" required:"true"` Policy *string `min:"1" type:"string" required:"true"` PolicyName *string `min:"1" type:"string" required:"true"` }


Type: *bool

A flag to indicate whether to bypass the key policy lockout safety check.

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

For more information, refer to the scenario in the Default Key Policy ( section in the AWS 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 CMK.

The default value is false.


Type: *string

A unique identifier for the customer master key (CMK).

Specify the key ID or the Amazon Resource Name (ARN) of the CMK.

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 CMK, use ListKeys or DescribeKey.

KeyId is a required field


Type: *string

The key policy to attach to the CMK.

The key policy must meet the following criteria:

  • Each statement in the key policy must contain one or more principals. The principals in the key policy must exist and be visible to AWS KMS. When you create a new AWS principal (for example, an IAM user or role), 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 AWS KMS. For more information, see Changes that I make are not always immediately visible ( in the AWS Identity and Access Management User Guide.

The key policy size limit is 32 kilobytes (32768 bytes).

Policy is a required field


Type: *string

The name of the key policy. The only valid value is default.

PolicyName is a required field



func (s PutKeyPolicyInput) GoString() string

GoString returns the string representation


func (s *PutKeyPolicyInput) SetBypassPolicyLockoutSafetyCheck(v bool) *PutKeyPolicyInput

SetBypassPolicyLockoutSafetyCheck sets the BypassPolicyLockoutSafetyCheck field's value.


func (s *PutKeyPolicyInput) SetKeyId(v string) *PutKeyPolicyInput

SetKeyId sets the KeyId field's value.


func (s *PutKeyPolicyInput) SetPolicy(v string) *PutKeyPolicyInput

SetPolicy sets the Policy field's value.


func (s *PutKeyPolicyInput) SetPolicyName(v string) *PutKeyPolicyInput

SetPolicyName sets the PolicyName field's value.


func (s PutKeyPolicyInput) String() string

String returns the string representation


func (s *PutKeyPolicyInput) Validate() error

Validate inspects the fields of the type to determine if they are valid.

On this page: