I have an AWS API Gateway that I would like to secure using IAM Roles .
I am looking for a package to help me accessing it using Python. I am trying to avoid implementin
If you want to make a call using the IAM role, you should use BotoAWSRequestsAuth
from aws-requests-auth:
import requests
from aws_requests_auth.boto_utils import BotoAWSRequestsAuth
auth = BotoAWSRequestsAuth(
aws_host="API_ID.execute-api.us-east-1.amazonaws.com",
aws_region="us-east-1",
aws_service="execute-api"
)
response = requests.get("https://API_ID.execute-api.us-east-1.amazonaws.com/STAGE/RESOURCE", auth=auth)
This will use botocore to retrieve a key and secret from the AWS metadata service rather than you needing to pass them yourself.
Thanks to Ka Hou Leong for the suggestion of the aws-requests-auth library.