
This assumes you have already configured the aws command line tool. If not, check out my article on Getting Started with the AWS CLI.
This also assumes you are already created an API Gateway. For example, let's say you've created a REST API. The aws apigateway get-rest-apis command can be used to list your API Gateway REST APIs.
~]$ aws apigateway get-rest-apis
{
"items": [
{
"id": "2885zecrwj",
"name": "my-rest-api",
"createdDate": "2024-04-29T04:33:11+00:00",
"apiKeySource": "HEADER",
"endpointConfiguration": {
"types": [
"PRIVATE"
]
},
"disableExecuteApiEndpoint": false,
"rootResourceId": "sf6n2hrix7"
}
]
}
The aws apigateway get-resources command can be used to determine if the API Gateway has any methods. In this example, the API Gateway does not have any methods.
~]$ aws apigateway get-resources --rest-api-id 2885zecrwj
{
"items": [
{
"id": "6gv3n2wtze",
"path": "/",
"resourceMethods": {}
}
]
}
The aws apigateway put-method command can be used to update the API Gateway REST API with the methods it will allow (such as GET, POST).
aws apigateway put-method \
--rest-api-id 2885zecrwj \
--resource-id 6gv3n2wtze \
--http-method GET \
--authorization-type "NONE" \
--no-api-key-required
And POST.
aws apigateway put-method \
--rest-api-id 2885zecrwj \
--resource-id 6gv3n2wtze \
--http-method POST \
--authorization-type "NONE" \
--no-api-key-required
Now the aws apigateway get-resources command should show that the API Gateway has methods.
~]$ aws apigateway get-resources --rest-api-id 2885zecrwj
{
"items": [
{
"id": "sf6n2hrix7",
"path": "/",
"resourceMethods": {
"GET": {},
"POST": {}
}
}
]
}
Likewise, in the AWS console, the API Gateway should have the methods.
Did you find this article helpful?
If so, consider buying me a coffee over at