I'm trying to create an apigateway in order to create an api that integrates the lex bot.
I did that using sam with lambda function;the probelm when I run locally my script using sam local start-api I got this :
Invalid lambda response received: Invalid API Gateway Response Keys: {'requestId', 'errorMessage', 'errorType', 'stackTrace'} in {'errorMessage': "Unable to import module 'app': No module named 'aws_requests_auth'", 'errorType': 'Runtime.ImportModuleError', 'requestId': 'XXXXXX', 'stackTrace': []}
although I already installed aws_requests_auth lib and the api is working fine on postman.
I check the installation using pip list command and I got this :
aws-requests-auth 0.4.3
this is the script :
import json
import boto3
import os
import uuid
import requests
from aws_requests_auth.aws_auth import AWSRequestsAuth
def run(event,context):
URL = apiURL"
payload="{\r\n\r\n \"text\": \"2012\"\r\n}"
#### put the api-key found in the lapose.fr api documentation https://developer.laposte.fr/
headers = {
'Content-Type': 'application/json',
'X-Amz-Content-Sha256': 'XXXXXXXXX',
'X-Amz-Date': 'XXXXXXXXXXXX'
}
auth = AWSRequestsAuth(
aws_access_key='XXXXXXXXXXX',
aws_secret_access_key='XXXXXXXXXX',
aws_host='runtime-v2-lex.us-east-1.amazonaws.com',
aws_region='us-east-1',
aws_service='lex'
)
response = requests.post(URL, headers=headers, data=payload ,auth=auth)
print(response.json())
return{
'statusCode':200,
'headers': {
'Content-Type': 'application/json',
},
'body': json.dumps(response.json())
}