I have created the VPC Link using the Network Load Balancer (NLB) as per the AWS documentation and attached the same with the API Gateway resource / method. But it throws "Internal Server Error" when accessing the "Invoke URL" and displays this error while testing: "Execution failed due to configuration error: There was an internal error while executing your request".
Procedure I followed:
1) Created Network Load Balancer :
- Load Balancer Scheme: Internal
- Load Balancer Protocol / port : TCP / 80
- Availability Zone : Created VPC with CIDR "10.0.0.0/16" and public subnet with CIDR "1XX.XX.0.0/16".
- Target Group : Protocol / Port / Target Type - TCP / 80 / Instance
- No Target Registration.
- Launched NLB.
2) Created VPC Link in API Gateway using the newly created NLB.
3) Created new API :
- Method : Get
- Integration Type : VPC Link
- Use Proxy Integration : True
- VPC Link : ${stageVariables.vpcLinkId}
- Endpoint URL : "My ec2 instance URL with port" (Ex: http://ec2-XX-XXX-XXX-XXX.compute-1.amazonaws.com:3000)
- Created API resource.
4) Deployed the selected API using the "Deploy API" action and newly created stage.
5) Configured the "vpcLinkId" in the "Stage Variables" section.
Now if I hit the "Invoke URL", the web page displays " {"message": "Internal server error"} ".
Note: If I use the same EC2 url with the "Integration Type : HTTP", the "Invoke URL" works. Same is not working with the VPC Link.
Error:
Other Points Worth Noting:
- In EC2 instance with security policy will allow all TCP ports.
- EC2 instance was launched by using ECS / ECR (Docker Container).
- Enabled the Cloud Watch logs from API Gateway stage, but it produces nothing.
I'm happy to provide additional information, if required.
EDIT 1
Based on JNY's (jny) input I have changed the API gateway end point to the NLB and added my EC2 instance as Target in the NLB. Still I'm facing the same issue. Below images will show all the configurations that I have done.
Load Balancer Config:
Load Balancer Target Group settings:
Target Group Port Settings:
- Here I have given 3000 as port to check the instance health as my application (Node) listens on 3000 port.
- Enabled the port numbers 80 and 3000 in the security policy.
API Gateway Settings:
- Finally I changed the Endpoint the API Gateway to NLB
Result of the same:
Still I'm not sure what is the mistake I'm making here.