Reputation: 701
At the moment my application uses boto3 to access AWS resources. However I'd like to instead use the API Gateway to front the AWS Services used so that everything is funnelled through the API Gateway instead of directly to the services.
I have the API Gateway working, but how can I tell boto3 to use this new endpoint because the API Gateway endpoints are setup on a per action basis. i.e., there's one for ListQueues and another for CreateQueue.
Using boto3 with the endpoint-url parameter gives me this error:
botocore.parsers.ResponseParserError: Unable to parse response (not well-formed (invalid token): line 1, column 0), invalid XML received: {"message":"Credential should be scoped to correct service: 'execute-api'. "}
Upvotes: 0
Views: 4216
Reputation: 701
After doing some more research, the real answer is this is actually not possible because boto3 library does not support API Gateway as one of the services it makes available.
See here: https://github.com/boto/botocore/issues/1140
There is currently an open feature request to allow boto3 to make calls to an API Gateway resource: https://github.com/boto/boto3/issues/1246
If anyone knows something I don't know please let me know.
Upvotes: 0
Reputation: 80031
When creating your client, you can pass the keyword parameter endpoint_url
which lets you override the default URL botocore
would construct for the target service otherwise.
import boto3
client = boto3.client('sqs', endpoint_url="https://your.api.gateway.url.here")
You will need some management here since it sounds like you have read-only API Gateway endpoints, and then some that have write capabilities.
Upvotes: 3