I created an ecs service running a task definition that creates a docker container running a flask app. The flask app is getting an image through the http request and returning a ML model inference.
Since I want this service to run in production env, I created an internal network load balancer, and attached it to a vpc endpoint service. The nlb is forwarding requests to a target group which registers all ECS cluster's instances.
I have an API gateway which integrates with a lambda function that is configured inside the same vpc, and from the lambda I need to access the ecs service(through the nlb or vpc endpoint)
*** However, I keep getting 'max retries exceeded' with python requests- as the endpoint is not reachable. Nor the nlb and neither the vpc endpoint service.
Please help me understand whats wrong, or suggest another infrastructure that handles these requests in a production env.
** The docker container is valid and responding using postman directly, but I need postman to send to API gateway and get an edited response from the lambda.
Attached are some of my configurations. Let me know if you think more configurations are required. Thanks:)
Lambda connection error to endpoint
VPC endpoint service configuration
Rest of your configurations seem alright, and it is validated by accessing the service inside EC2.
There is only one piece to the puzzle I can point out, i.e. while attaching your Lambda Function with the VPC, only use the
private subnets
. Currently, I'm not sure if the attached subnets to your Lambda Function are private or public.