- Newest
- Most votes
- Most comments
I don’t believe this is a supported working method and the ALB is behaving as normal.
I’d question what your trying to achieve ?
Hi,
The official documentation details the whole process to route requests from ALB to Lambda: https://docs.aws.amazon.com/elasticloadbalancing/latest/application/lambda-functions.html
Also have a look to this path to have the details of a full setup: https://dev.to/brooklyn2706/triggering-lambda-function-with-application-load-balancer-2947
Best,
Didier
I would like it to go to lambda only when my ECS service has no tasks registered (because it's down). I don't know how to do that.
The lambda spins up the targets again.
I think the problem here is detecting when there is "no traffic" vs "a little traffic" vs "a lot of traffic" - because for the first you'll want to use Lambda; for the second you want to use Lambda but start up ECS; and for the third you want to be using ECS. But how can you tell whether "a little traffic" is about to be "a lot of traffic" or going to go back down to "no traffic"?
If it were me and I was looking for cost-savings and flexibility I'd only use Lambda and avoid the complexity of trying to mix and match traffic between Lambda and ECS.
But if you absolutely must: I'd have a CloudWatch Metrics alarms for increasing/decreasing traffic which trigger a Lambda function that change the listener rules on the fly. So as traffic increases, scale the ECS cluster up then switch from Lambda to ECS; as it decreases switch back and scale down the ECS cluster.
Relevant content
- asked 2 years ago
- Accepted Answerasked 2 months ago
- Accepted Answerasked 3 years ago
- asked 6 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 6 months ago
- AWS OFFICIALUpdated 2 months ago
- AWS OFFICIALUpdated 20 days ago
I'm trying to scale down my cluster when it doesn't receive traffic and immediately scale back up when it does. It feels like a pretty standard setup.
You need to have 1 ECS task running at minimum at all times