Reputation: 6208
I need to fetch some data from ApiGateway
endpoint and then based on response store this data in database.
I created simple Lambda
function that just fetch data from ApiGateway
endpoint and print it in console. My first Lambda function did not have any VPC
configuration and fetch operation worked like a charm.
const fetch = require('node-fetch');
exports.handler = async () => {
const data = await fetch("https://<<ag-api-key>>.execute-api.us-east-1.amazonaws.com/v1/data");
const response = await data.json();
console.log(data, response);
}
As I need to store data received from endpoint into database which run under VPC I decided to put Lambda in same VPC(this vpc has configured Internet Gateways and other stuff to have access to internet).
As a result fetch
operation start to fail with 403
response code and {"message":"Forbidden"}
response body.
Api Gateway resource does not have any custom domain configuration and maintained by other team so I do not have direct access to its configuration
May be anyone can suggest how I can fix this
Upvotes: 3
Views: 2425
Reputation: 600
Let me know if any of that helps. I have ran into that issue many times in different situations.
Upvotes: 1