Search code examples
pythonamazon-web-servicesboto3amazon-kms

boto3 get KMS tags with lambda


I'm trying to get the attached tags on specific CMK how can I do that?, I tried with kms_client.list_aliases I get the alias info but not it's tags


Solution

  • You need to call the list_resource_tags function, which

    Returns a list of all tags for the specified customer master key (CMK).

    See https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/kms.html#KMS.Client.list_resource_tags

    Request

    response = kms_client.list_resource_tags(
        KeyId='string',
        Limit=123,
        Marker='string'
    )
    

    Response

    {
        'Tags': [
            {
                'TagKey': 'string',
                'TagValue': 'string'
            },
        ],
        'NextMarker': 'string',
        'Truncated': True|False
    }