16

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.

2 Answers 2

14

You might have to construct it.

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

Sign up to request clarification or add additional context in comments.

Comments

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.