Reputation: 1109
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.
Upvotes: 16
Views: 4186
Reputation: 1675
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
Upvotes: 1
Reputation: 4596
You might have to construct it.
https://<restApiId>.execute-api.<region>.amazonaws.com/<stageName>
Upvotes: 14