I need my lambda to call an API Gateway and have the following code in place as inline code for the lambda in my cloud formation template.
from requests_aws4auth import AWS4Auth
def handler(event,context):
client = boto3.client('sts')
responseAssumeRole = client.assume_role(
DurationSeconds=3600,
RoleArn='arn',// real arn of the api gateway invocation role
RoleSessionName='Bob',
)
credentials = responseAssumeRole['Credentials']
auth = AWS4Auth(aws_access_key=responseAssumeRole['Credentials']['AccessKeyId'],
aws_secret_access_key=responseAssumeRole['Credentials']['SecretAccessKey'],
aws_host='host.execute-api.us-east-1.amazonaws.com',
aws_region='us-east-1',
aws_service='execute-api')
headers= {'User-Agent' : 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36'}
response = requests.get('https://host.execute-api.us-east-1.amazonaws.com/test',
auth=auth, headers=headers)
This gives me the following error
No module named 'requests_aws4auth'
Any solution or alternative way to get the auth created using the aws credentials would be also welcome.
pip install requests-aws4auth