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
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With