Skip to content

Instantly share code, notes, and snippets.

@leegilmorecode
Created December 13, 2021 21:26
Show Gist options
  • Save leegilmorecode/41a21691e43eb90df11d92c6459b0427 to your computer and use it in GitHub Desktop.
Save leegilmorecode/41a21691e43eb90df11d92c6459b0427 to your computer and use it in GitHub Desktop.
Private DNS on VPC with VPC Endpoints
import axios from "axios";
async function handler() {
const { data } = await axios.get(
`https://private-api-id.execute-api.eu-west-1.amazonaws.com/prod/stock`, // ๐Ÿ‘ˆ this private call would work
{
headers: {
"x-api-key": "super-secret-api-key",
},
}
);
console.log(`private call is successful: ${data}`);
const { data: test } = await axios.get(
`https://public-api-id.execute-api.eu-west-1.amazonaws.com/prod/pets` // ๐Ÿ‘ˆ this public call would not
);
console.log("public call is unsuccessful: ", test);
return {
body: JSON.stringify(data),
statusCode: 200,
};
}
module.exports = { handler };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment