'AWS cli --query is not returning expected JMES path

aws route53 list-hosted-zones --profile myprofile

is returning

{
    "HostedZones": [
        {
            "Id": "/hostedzone/Z0874178161VQMKVVVJBT",
            "Name": "mydomain.org",
            "CallerReference": "RISWorkflow-RD:62a669b6-5465-4741-bb96-671e0be70b10",
            "Config": {
                "Comment": "HostedZone created by Route53 Registrar",
                "PrivateZone": false
            },
            "ResourceRecordSetCount": 4
        }
    ]
}

I want to get the Id value and only the ID value.

based on https://jmespath.org/tutorial.html I think that the first command below should work but I cannot get the value of Id. I pasted the output into the JmesPath site and it thinks the first line should work

aws route53 list-hosted-zones --profile admin1 --query HostedZones[0].Id
zsh: no matches found: HostedZones[0].Id

aws route53 list-hosted-zones --profile admin1 --query HostedZones.Id   
null

aws route53 list-hosted-zones --profile admin1 --query Id 
null


Solution 1:[1]

You can get the id with
aws route53 list-hosted-zones --profile admin1 --query 'HostedZones[].{ID: Id}'

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Riz