I have the following setup
Instead of creating a NAT gateway for my lambda function to be able to access the AWS Beanstalk app apis over the internet , i want to create a VPC endpoint so that i can access aws beanstalk within AWS internal network from my lambda function.
The public subnet has security groups that allow web traffic (port 80/443)
The VPC endpoint is associated with the private subnets and its security groups allow web traffic traffic(Port 80/443).
The lambda function is also associated with the private subnets and its security groups allow web traffic traffic(Port 80/443).
DNS resolution and DNS hostnames are enabled at VPC level.
I copied the Endpoint dns name to form the url that is being called by the lambda function and i get a timeout
Even after i tried all steps above, AWS Lambda cannot access the beanstalk app api.
Simplified lambda function:
def lambda_handler(event, context):
http = urllib3.PoolManager()
r = http.request('GET', 'http://vpce-**********.elasticbeanstalk.us-east-2.vpce.amazonaws.com/')
print(r.data)
# TODO implement
return {
'statusCode': 200,
'body': json.dumps('Hello from Lambda!')
}
The Elastic beanstalk app is available over the internet at http://sample-app-dev.******.us-east-2.elasticbeanstalk.com/
What am i missing here?
If I understand correctly, you managed to create a VPC Endpoint which will let you access the Elastic Beanstalk AWS Service (where you can do administration for your EB instances). You did not expose your application itself deployed using Elastic Beanstalk.
I'm saying this, because in order to expose your EB application from a VPC, first you have to create an Endpoint Service which connects to a Network Load Balancer. The EB application needs to be registered as a target for this load balancer (which is easy if you have an Application Load Balancer for EB). This will give you and service name, from which you can create an Endpoint in the other VPC (consumer VPC), where you can find the service by name:
If you found your service, you can place and Endpoint into your consumer VPC to which you can connect.
Nevertheless, if both of your VPCs are in the same AWS account, having exposing a service through PrivateLink might be overkill. Probably a VPC peering would suffice.
Update - short tutorial for PrivateLink setup:
Create a Network Load Balancer in the VPC in which your EB application is deployed. This will ask you to create a Target Group, so open the link to create one.
For the Target Groups for the Load Balancer create a new one and select Application Load Balancer.
active
state.VPC
-> Endpoint Service
and create a new Endpoint Service
(PrivateLink). You will have to give the name of the load balancer here:Endpoints
and search for the endpoint name:Endpoint
which allows HTTP/HTTPS inbound traffic from the VPC:Endpoints
:It might require acceptance, so go back to the Endpoint Service
and accept the request.
This should also go from pending
to available
.
Endpoint
.