首页 > 解决方案 > how to invoke a request to a network load balancer(nlb) vpc endpoint from a lambda function in aws

问题描述

I created a service in ECS running a task on many instances for high availability. I created an internal network load balancer and a vpc endpoint, and I registered the service's instances to the nlb's target group. I have an API gateway to receive external requests from the client, and I want to pass these requests to the service and get a response.

I know I can integrate my API Gateway with VPC and attach to the nlb, and it worked. But its not sufficient, and I need to integrate the gateway's endpoint with a lambda to perform more actions on the service responses.

I want to perform a request from the lambda to the vpc/nlb endpoint and get a response from one of the instances, but I cant find anywhere how to do this. Is there a boto3 or any other way to properly invoke a request to the endpoint? like with sagemaker.

Thanks! my aws vpc endpoint description

标签: amazon-web-servicesaws-lambdaamazon-vpcendpointnlb

解决方案


您可以将 lambda 函数与 vpc 集成。这样,lambda 函数将能够访问 vpc 中的私有资源,包括您的 NLB。

因此,您的 API 网关将与该功能集成,而该功能又将与您的 VPC 集成。该函数将通过 NLB 调用您的服务并将任何响应返回给 API 网关。

没有特殊boto3的功能可以调用您的 NLB。您只需使用常规 python 工具来调用您的 NLB 的 url,例如requests.


推荐阅读