Skip to content

Debugging timeouts from an API Gateway lambda to an internal application load balancer

0

Hello,

I have an API Gateway that has a lambda integration. The lambda is configured to run in the VPC. The lambda is a proxy (written in node) that forwards requests to an internal application load balancer. The lambda is attempting to access the LB using it's internal DNS name and the port it is listening on (8000). The LB target group is healthy.

I know the ALB is answering requests, because I can attach a direct integration to the $default API route that targets the ALB and it answers. When I attach the lambda integration, the requests time out.

The lambda security group allows outbound traffic to the ALB security group on port 8000. The ALB security group allows inbound traffic from the lambda security group on port 8000.

I have also tried sending requests directly to the ALB target group listener (after adding the IP to the lambda outbound SG rules) but it also times out.

Could the problem be related to network ACL's?

Thanks in advance for any help!

Brian

1 Answer
0

Based on your description, there are several potential causes for the timeout issue between your Lambda function and the internal Application Load Balancer (ALB).

Network ACLs could indeed be a factor. Unlike security groups, network ACLs are stateless and require explicit rules for both inbound and outbound traffic. You should verify that the subnet's network ACLs for both the Lambda function and the ALB allow the necessary inbound and outbound traffic on port 8000.

Another potential issue could be related to routing. Ensure there's a valid route path to the ALB in the route table. If the Lambda function and ALB are in the same VPC, check that there's a local route. If they're in different VPCs, make sure the route table has the appropriate route for VPC peering.

The timeout could also be related to the idle timeout configuration. When a Lambda function establishes a connection to an ALB, the ALB has a default idle timeout of 60 seconds. If your Lambda function takes longer to respond, the ALB might close the connection before the function completes its task.

Additionally, check if the Lambda function's execution timeout is sufficient. The default timeout for Lambda functions is 3 seconds, which might not be enough for your proxy operation.

For a more thorough analysis of network path configuration issues, you could use the VPC Reachability Analyzer to diagnose connectivity problems between your Lambda function and the ALB.

Since you mentioned that a direct integration from API Gateway to the ALB works, but the Lambda integration doesn't, it suggests that the issue is specific to the Lambda-to-ALB communication path. This reinforces the need to check network ACLs, routing, and security group configurations specifically for the Lambda function's subnets.
Sources
Troubleshoot ETIMEDOUT error in my Lambda function | AWS re:Post
Troubleshoot your Application Load Balancers - Elastic Load Balancing
ALB stops communicating with the lambda on the backend when the lambda is decoupled from the VPC. | AWS re:Post
Lambda Timeout Errors | AWS re:Post

answered a year ago

EXPERT

reviewed a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.