- Newest
- Most votes
- Most comments
Hello,
Yes, a Lambda function can call an ECS Service endpoint even if Service Discovery is not enabled. Here the traffic will route to public DNS if the VPC has access to internet then to a public IP and it will go to ECS. However, there are some considerations to keep in mind.
Since your Lambda function is in the same VPC as the ECS Service, you have a few options to establish connectivity:
-
Use the internal DNS name of the Application Load Balancer (ALB) if you have one in front of your ECS Service. This is often the simplest and most reliable method. The internal DNS name of the ALB will resolve to private IP addresses within the VPC, allowing your Lambda to communicate with the ECS Service.
-
If you're not using an ALB, you can use the private IP address of the ECS task. However, this is not recommended for production use as the IP address can change if the task is restarted.
-
You cannot use the public DNS or IP address of the service from within the VPC, as this would route traffic out to the internet and back in, which won't work for an internal Lambda.
-
Using the Load Balancer's IP address directly is not recommended, as these can change. Always use the DNS name instead.
For your test configuration, the simplest approach would be:
- If you have an ALB, use its internal DNS name.
- If not, you can temporarily use the private IP of the ECS task, but be aware this is not a stable long-term solution.
Your security group configuration sounds correct, allowing traffic between the Lambda and ECS Service. However, ensure that the ECS tasks are in private subnets if you want to keep them internal.
For a more robust, long-term solution, consider enabling ECS Service Discovery or using an Application Load Balancer. These methods provide stable endpoints for your services and offer better scalability and management of incoming traffic.
Yes, a Lambda function can call an ECS Service endpoint even if Service Discovery is not enabled, but there are some considerations to keep in mind.
Since your Lambda function is in the same VPC as the ECS Service, you have a few options to establish connectivity:
-
Use the internal DNS name of the Application Load Balancer (ALB) if you have one in front of your ECS Service. This is often the simplest and most reliable method. The internal DNS name of the ALB will resolve to private IP addresses within the VPC, allowing your Lambda to communicate with the ECS Service.
-
If you're not using an ALB, you can use the private IP address of the ECS task. However, this is not recommended for production use as the IP address can change if the task is restarted.
-
You cannot use the public DNS or IP address of the service from within the VPC, as this would route traffic out to the internet and back in, which won't work for an internal Lambda.
-
Using the Load Balancer's IP address directly is not recommended, as these can change. Always use the DNS name instead.
For your test configuration, the simplest approach would be:
- If you have an ALB, use its internal DNS name.
- If not, you can temporarily use the private IP of the ECS task, but be aware this is not a stable long-term solution.
Your security group configuration sounds correct, allowing traffic between the Lambda and ECS Service. However, ensure that the ECS tasks are in private subnets if you want to keep them internal.
For a more robust, long-term solution, consider enabling ECS Service Discovery or using an Application Load Balancer. These methods provide stable endpoints for your services and offer better scalability and management of incoming traffic.
Sources
ECS Task with public ip connect permanent | AWS re:Post
Can I call a service that is inside Fargate from a lambda function? | AWS re:Post
Connect ECS Fargate Service/Task from public | AWS re:Post
Relevant content
- asked a year ago
- asked 7 months ago
- AWS OFFICIALUpdated 7 months ago