Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fetch API Key using aws CLI

I have a script where I want to fetch the AWS API gateway ID and API key value. So far I have been able to get the API gateway ID using the cli:

aws apigateway get-api-keys --query 'items[?name==`my-api-key-name`].id' --output text --region us-east-1

But I am unable to fetch the value of API key. I have tried the following cli, but no luck:

aws apigateway get-api-keys --query 'items[?name==`my-api-key-name`].value' --output text --region us-east-1

Can someone assist me on this please?

like image 235
Satya Avatar asked Oct 17 '19 07:10

Satya


1 Answers

You're missing --include-values key.

You can try this:

aws apigateway get-api-keys --query 'items[?name==`my-api-key-name`].value' --include-values --output text --region us-east-1

or this:

aws apigateway get-api-key --api-key <api-key-id> --include-value --query "value" --output text

Here you can find more info on that.

UPD: Included suggestion from @Anatolii Bivol to use --query "value"

like image 117
dmigo Avatar answered Oct 26 '22 02:10

dmigo