Hi, currently im trying to invoke an api gateway that invokes a lambda function. Im doing this all from a local development server, not sure if thats the problem but i think i should be able to do so eitherway let me know if not. But im using django for my apps backend and thats where im running into the issue. i recive the response itself but i also recieve a 403 code. the response is just null however.
here is my code for my django view:
@api_view(['POST'])
def invoke_endpoint(request):
#call lambda function in the cloud to invoke sagemaker endpoint for response generation
input = request.data.get('query','')
lambda_payload = {
"queryStringParameters": input,
}
session = Session()
credentials = session.get_credentials()
aws_access_key = credentials.access_key
aws_secret_key = credentials.secret_key
region = session.region_name
service = 'execute-api'
endpoint = 'endpoint-link/generatearesposne'
auth = AWS4Auth(aws_access_key, aws_secret_key, region, service)
payload_bytes = json.dumps(lambda_payload).encode('utf-8')
r = requests.post(endpoint, data=payload_bytes, auth=auth)
response_payload = r.json()
print(r)
return JsonResponse({'response-payload': response_payload})
i am providing the auth to be able to call the function, i also have the aws cli setup and am configured to a user that has permissions to use lambda, sagemaker and api gateway. im not sure what else i need or if im making some sort of mistake here. fairly new user of AWS so im not sure.
my response looks like this:
<Response [403]>
As mentioned in the article provided by @Didier_Durand, check the
x-amzn-errortype
response header to get more information about the root cause.