Reputation: 491
I am trying to execute API gateway using AWS CLI in EC2 instance. I did not find any command in AWS CLI documentation. Has anyone used CLI before to execute API gateway endpoint?
Thank
Upvotes: 2
Views: 10787
Reputation: 3410
This is now possible with AWS CLI version 2.
https://docs.aws.amazon.com/cli/latest/reference/apigateway/test-invoke-method.html
Here's an example test POST using a file as the request body:
aws --region us-west-2 apigateway test-invoke-method --rest-api-id abcd1234 --resource-id abcd12 --http-method POST --path-with-query-string '/records/create' --body file://test-body.json
Upvotes: 9
Reputation: 238139
Sadly, there is no such API call in CLI or SDK. You have to use external tools to invoke your API.
Examples are, curl
, postman
or requests
package in python.
For example, if you protect your API through aws_iam
you can use AWSRequestsAuth in python to construct valid AWS IAM request. In postman
you can also provide IAM credentials for the request to such API.
Upvotes: 3