I have a lambda function that retrieves records from AWS Aurora Serverless db. Now I thought of adding api gateway to trigger the lambda function but I get this error.
[ERROR] BadRequestException: An error occurred (BadRequestException) when calling the ExecuteStatement operation:
Access denied for user 'admin'@'10.x.xx.xxx' (using password: YES); Error code: 1045; SQLState: 28000
Traceback (most recent call last):
File "/var/task/index.py", line 11, in handler
sql="SELECT * FROM ecomdev.Customer;"
What is causing BadRequestException when calling the ExecuteStatement operation on Aurora Serverless db. I have used AWS CDK to create the stacks. i have deployed the db in isolated subnet of VPC and created a lambda role to access the db along with role policies to access the db secret from secretmanager.
Lambda is not inside the vpc. I tested the lambda code and it gets the records perfectly. But when I add an api gateway with Lambda rest api to trigger the lambda function I get above error. Any help would be appreciated