15

I have an API that has been deployed in a stage in API Gateway. I am trying to get the URL of the deployed API using cli, but am having difficulties finding the command to do so. I have tried all the get- commands from the docs, found here:

https://docs.aws.amazon.com/cli/latest/reference/apigateway/index.html#cli-aws-apigateway

Even with the ID of the API, I can't get the actual URL that was deployed. Obviously I could just go to the console and copy it from there, but I was wondering if this was even possible from cli. Thanks.

himi64
  • 1,069
  • 3
  • 12
  • 23

2 Answers2

13

You might have to construct it.

https://<restApiId>.execute-api.<region>.amazonaws.com/<stageName>

cementblocks
  • 4,326
  • 18
  • 24
1

Using the construction provided by @cementblocks and some jq string interpolations (this assumes that .tags.STAGE is set as expected):

$ export AWS_DEFAULT_REGION=us-west-2
$ aws apigateway get-rest-apis | jq -r '.items[] | "https://\(.id).execute-api.'${AWS_DEFAULT_REGION}'.amazonaws.com/\(.tags.STAGE)"'
https://naj28sdkn.execute-api.us-west-2.amazonaws.com/my-stage
Darren Weber
  • 1,537
  • 19
  • 20