Here, I have created DB REST API using API Gateway, method is POST. I want to build a another REST API that calls the DB API, which passes the event to DB API and return the response from it (with some more jobs). Both languages are Python 3.9
While I could use requests library from outside of AWS Lambda and call DB API and got the result, using the exact same code and run it at AWS Lambda gives me error message that it cannot connect to DB API.
I checked both DB API function and API caller function in same VPC, same security code and the role has following:
I know I can just invoke DB API lambda function inside the Lambda but I need that REST API so that other services can access to that DB API
Can anyone help me on achieving what I want? Thank you
ADDED
So I want to know what I have missed when people usually calls AWS gateway API by AWS lambda.
My expectation was since it worked in other environment, it must work at lambda too but in reality it wasn't even able to connect to the API.
I used the following code to call the API:
# DB API caller
def lambda_handler(event, context):
URL = 'THE_URL_OF_DEPLOYED_API'
timeout = 10
# event is in format of dictionary
response = requests.post(URL, json=event, timeout=timeout)