Search code examples
aws-cliamazon-ebsamazon-kms

aws cli: how to find kms key id?


When I run the following command, this is what I get.

$ aws ec2 get-ebs-default-kms-key-id --region us-west-2
{
    "KmsKeyId": "alias/aws/ebs"
}

But what I really want is the key id under "(default) aws/ebs" (shown below).

enter image description here


Solution

  • You can use this command to get the key ids for all the keys in your account.

    aws kms list-aliases --query 'Aliases[*].TargetKeyId'