Skip to content

KMS  >  Operations  >  list_key_policies

list_key_policies

Operation

list_key_policies async

list_key_policies(request: ListKeyPoliciesInput | ListKeyPoliciesInputDict, /, *, plugins: list[Plugin] | None = None) -> ListKeyPoliciesOutput
list_key_policies(*, plugins: list[Plugin] | None = None, **kwargs: Unpack[ListKeyPoliciesInputDict]) -> ListKeyPoliciesOutput

Gets the names of the key policies that are attached to a KMS key. This operation is designed to get policy names that you can use in a GetKeyPolicy operation. However, the only valid policy name is default.

Cross-account use: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account.

Required permissions: kms:ListKeyPolicies (key policy)

Related operations:

Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency.

Parameters:

Name Type Description Default
plugins list[Plugin] | None

A list of callables that modify the configuration dynamically. Changes made by these plugins only apply for the duration of the operation execution and will not affect any other operation invocations.

None

Returns:

Type Description
ListKeyPoliciesOutput

An instance of ListKeyPoliciesOutput.

Input

Pass the input fields as keyword arguments, or pass a model or dictionary as the first positional argument. Pass plugins separately as a keyword argument.

Model

ListKeyPoliciesInput dataclass

Bases: _SerdeShape

Dataclass for ListKeyPoliciesInput structure.

Attributes
key_id class-attribute instance-attribute
key_id: str | None = ...

Gets the names of key policies for 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.

limit class-attribute instance-attribute
limit: int | None = ...

Use this parameter to specify the maximum number of items to return. When this value is present, KMS does not return more than the specified number of items, but it might return fewer.

This value is optional. If you include a value, it must be between 1 and 1000, inclusive. If you do not include a value, it defaults to 100.

Only one policy can be attached to a key.

marker class-attribute instance-attribute
marker: str | None = ...

Use this parameter in a subsequent request after you receive a response with truncated results. Set it to the value of NextMarker from the truncated response you just received.

Dictionaries

ListKeyPoliciesInputDict

Bases: TypedDict

Dictionary form of ListKeyPoliciesInput.

Attributes
key_id instance-attribute
key_id: Required[str]

Gets the names of key policies for 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.

limit instance-attribute
limit: int | None

Use this parameter to specify the maximum number of items to return. When this value is present, KMS does not return more than the specified number of items, but it might return fewer.

This value is optional. If you include a value, it must be between 1 and 1000, inclusive. If you do not include a value, it defaults to 100.

Only one policy can be attached to a key.

marker instance-attribute
marker: str | None

Use this parameter in a subsequent request after you receive a response with truncated results. Set it to the value of NextMarker from the truncated response you just received.

Output

ListKeyPoliciesOutput dataclass

Bases: _SerdeShape

Dataclass for ListKeyPoliciesOutput structure.

Attributes

next_marker class-attribute instance-attribute
next_marker: str | None = ...

When Truncated is true, this element is present and contains the value to use for the Marker parameter in a subsequent request.

policy_names class-attribute instance-attribute
policy_names: list[str] | None = ...

A list of key policy names. The only valid value is default.

response_metadata class-attribute instance-attribute
response_metadata: ResponseMetadata = ...

Metadata about the response that produced this output. Use this to recover the request identifiers a service's support team needs in order to investigate a call. Members of the metadata are individually optional.

truncated class-attribute instance-attribute
truncated: bool = ...

A flag that indicates whether there are more items in the list. When this value is true, the list in this response is truncated. To get more items, pass the value of the NextMarker element in this response to the Marker parameter in a subsequent request.