Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the --rest-api-id and --resource-id and where do i find them?

I want to run this command: https://docs.aws.amazon.com/cli/latest/reference/apigateway/test-invoke-method.html

It requires these two fields, cant find any docs and were these are:

aws apigateway test-invoke-method --rest-api-id 1234123412 --resource-id avl5sg8fw8 --http-method GET --path-with-query-string '/'

My API gateway endpoint looks like this:

https://abc123.execute-api.us-east-1.amazonaws.com/MyStage/

I only see on unique identifier there- but this command seems to require two IDs. Where do I find them in the API Gateway console?

like image 550
red888 Avatar asked Sep 21 '18 15:09

red888


People also ask

Where do I find my REST API ID?

If you'd rather not kick out to a terminal window you can grab the RestApi ID from the URL in the browser: https://console.aws.amazon.com/apigateway/home?region={region}#/apis/{api-id}/... Show activity on this post.

What is resource ID in REST API?

Each REST API resource can be accessed by using a Uniform Resource Identifier (URI). The URI must contain the correct connection information to successfully call the API. The connection information consists of the host name where the web management service is running, and the port number that the service is using.

What is AWS REST API?

A REST API in API Gateway is a collection of resources and methods that are integrated with backend HTTP endpoints, Lambda functions, or other AWS services. You can use API Gateway features to help you with all aspects of the API lifecycle, from creation through monitoring your production APIs.


1 Answers

Your rest-api-id is the identifier before 'execute-api' in your endpoint URL.

In your example URL:

https://abc123.execute-api.us-east-1.amazonaws.com/MyStage/

The rest-api-id is abc123

The resource ID can be obtained with the CLI using the get-resources call and the rest-api-id:

> aws apigateway get-resources --rest-api-id abc123
{
"items": [
    {
        "id": "xxxx1",
        "parentId": "xxxx0",
        "pathPart": "foo",
        "path": "/foo",
        "resourceMethods": {
            "GET": {}
        }
    },
    {
        "id": "xxxx0",
        "path": "/"
    }
]}

Each one of the records in the items attribute is a resource, and its id attribute is a resource ID you can use in your test-invoke-method in conjunction with a method that is associated with the resource.

Both values are visible at the top of the console when you select one of your endpoints/resources: enter image description here

like image 77
Tres' Bailey Avatar answered Sep 20 '22 15:09

Tres' Bailey