Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS API Gateway Access Private Subnet

I have Public and Pvt Subnets in my VPC. I have some services running on EC2 in Pvt subnet, that needs to be accessed by external/mobile resources. How do I do this- is VPCLink and NLB the way to do it, or any other way, create some access point in Public subnet (??). Lambda seems to be the answer (for almost everything in AWS now) - not sure even how that access works for resources in Pvt Subnet.

Also the same Pvt Subnet has access external resources (outside of AWS) - how do I do this using the API Gateway?

Not quite understanding how the API-Gateway (and Lambda) is situated vis-a-vis - VPC and subnets- and how the network access control functions- can they access Pvt subnets directly or not. The documentation is somewhat silent on this, only talks about IAM - if someone can explain this. Found this on Lambda: AWS Lambda: How to setup a NAT gateway for a lambda function with VPC access.

The documentation says "API Gateway allows you to securely connect ... publicly addressable web services hosted inside or outside of AWS". My resources in Pvt subnet are not publicly addressable - I suppose.

Thanks

like image 810
Sam-T Avatar asked Nov 28 '18 00:11

Sam-T


People also ask

How do I access API in private subnet?

To access your private API once it's deployed, you need to create an interface VPC endpoint for it in your VPC. After you've created your VPC endpoint, you can use it to access multiple private APIs. Sign in to the AWS Management Console and open the Amazon VPC console at https://console.aws.amazon.com/vpc/ .

Does API gateway sit in a VPC?

API Gateway as a fully managed service runs its infrastructure in its own VPCs. When you interface with API Gateway publicly accessible endpoints, it is done through public networks.

Does API gateway sit in a subnet?

API Gateways In the API Gateway service, an API gateway is a virtual network appliance in a regional subnet. Private API gateways can only be accessed by resources in the same subnet. Public API gateways are publicly accessible, including from the internet.


1 Answers

Are the services you have running on EC2 offering an API? API Gateway is meant to proxy API requests. It's commonly used in conjunction with Lambda to allow Lambda functions to process HTTP requests. An API Gateway is not necessary for your service. You can simply use an Application Load Balancer (ALB) or an Elastic Load Balancer (ELB). They can reside on a public subnet while your service remains in the private subnet. You can use security groups and VPC routing tables to allow communication from your public ALB/ELB to your private EC2 service.

like image 112
Ben Whaley Avatar answered Sep 21 '22 18:09

Ben Whaley