AWS Key Management Service

2021/01/11 - AWS Key Management Service - 1 updated api methods

Changes  Adds support for filtering grants by grant ID and grantee principal in ListGrants requests to AWS KMS.

ListGrants (updated) Link ΒΆ
Changes (request)
{'GrantId': 'string', 'GranteePrincipal': 'string'}

Gets a list of all grants for the specified customer master key (CMK).

You must specify the CMK in all requests. You can filter the grant list by grant ID or grantee principal.

Note

The GranteePrincipal field in the ListGrants response usually contains the user or role designated as the grantee principal in the grant. However, when the grantee principal in the grant is an AWS service, the GranteePrincipal field contains the service principal , which might represent several different grantee principals.

Cross-account use : Yes. To perform this operation on a CMK in a different AWS account, specify the key ARN in the value of the KeyId parameter.

Required permissions : kms:ListGrants (key policy)

Related operations:

  • CreateGrant

  • ListRetirableGrants

  • RetireGrant

  • RevokeGrant

See also: AWS API Documentation

Request Syntax

client.list_grants(
    Limit=123,
    Marker='string',
    KeyId='string',
    GrantId='string',
    GranteePrincipal='string'
)
type Limit

integer

param Limit

Use this parameter to specify the maximum number of items to return. When this value is present, AWS 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 100, inclusive. If you do not include a value, it defaults to 50.

type Marker

string

param Marker

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.

type KeyId

string

param KeyId

[REQUIRED]

Returns only grants for the specified customer master key (CMK). This parameter is required.

Specify the key ID or the Amazon Resource Name (ARN) of the CMK. To specify a CMK in a different AWS account, you must use the key ARN.

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 .

type GrantId

string

param GrantId

Returns only the grant with the specified grant ID. The grant ID uniquely identifies the grant.

type GranteePrincipal

string

param GranteePrincipal

Returns only grants where the specified principal is the grantee principal for the grant.

rtype

dict

returns

Response Syntax

{
    'Grants': [
        {
            'KeyId': 'string',
            'GrantId': 'string',
            'Name': 'string',
            'CreationDate': datetime(2015, 1, 1),
            'GranteePrincipal': 'string',
            'RetiringPrincipal': 'string',
            'IssuingAccount': 'string',
            'Operations': [
                'Decrypt'|'Encrypt'|'GenerateDataKey'|'GenerateDataKeyWithoutPlaintext'|'ReEncryptFrom'|'ReEncryptTo'|'Sign'|'Verify'|'GetPublicKey'|'CreateGrant'|'RetireGrant'|'DescribeKey'|'GenerateDataKeyPair'|'GenerateDataKeyPairWithoutPlaintext',
            ],
            'Constraints': {
                'EncryptionContextSubset': {
                    'string': 'string'
                },
                'EncryptionContextEquals': {
                    'string': 'string'
                }
            }
        },
    ],
    'NextMarker': 'string',
    'Truncated': True|False
}

Response Structure

  • (dict) --

    • Grants (list) --

      A list of grants.

      • (dict) --

        Contains information about a grant.

        • KeyId (string) --

          The unique identifier for the customer master key (CMK) to which the grant applies.

        • GrantId (string) --

          The unique identifier for the grant.

        • Name (string) --

          The friendly name that identifies the grant. If a name was provided in the CreateGrant request, that name is returned. Otherwise this value is null.

        • CreationDate (datetime) --

          The date and time when the grant was created.

        • GranteePrincipal (string) --

          The identity that gets the permissions in the grant.

          The GranteePrincipal field in the ListGrants response usually contains the user or role designated as the grantee principal in the grant. However, when the grantee principal in the grant is an AWS service, the GranteePrincipal field contains the service principal , which might represent several different grantee principals.

        • RetiringPrincipal (string) --

          The principal that can retire the grant.

        • IssuingAccount (string) --

          The AWS account under which the grant was issued.

        • Operations (list) --

          The list of operations permitted by the grant.

          • (string) --

        • Constraints (dict) --

          A list of key-value pairs that must be present in the encryption context of certain subsequent operations that the grant allows.

          • EncryptionContextSubset (dict) --

            A list of key-value pairs that must be included in the encryption context of the cryptographic operation request. The grant allows the cryptographic operation only when the encryption context in the request includes the key-value pairs specified in this constraint, although it can include additional key-value pairs.

            • (string) --

              • (string) --

          • EncryptionContextEquals (dict) --

            A list of key-value pairs that must match the encryption context in the cryptographic operation request. The grant allows the operation only when the encryption context in the request is the same as the encryption context specified in this constraint.

            • (string) --

              • (string) --

    • NextMarker (string) --

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

    • Truncated (boolean) --

      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 thisresponse to the Marker parameter in a subsequent request.