1

I want to trigger a lambda function when a fargate task is deprovisionning, I created this EventBridge rule :

{
  "source": ["aws.ecs"],
  "detail-type": ["ECS Task State Change"],
  "detail": {
    "clusterArn": ["arn:aws:ecs:eu-west-3:xxx"],
    "lastStatus": ["DEPROVISIONING"]
  }
}

It does not seem to be working all the time, ie sometimes cloudwatch receives it and sometimes it doesn't (no logs are generated from the lambda function). What could cause this issue ?

JulienChamp
  • 113
  • 1
  • 9
  • What is your function? What are the permissions for it? – Marcin Dec 29 '21 at 23:16
  • My function is supposed to be triggered when a target of a target group is unhealthy, it deletes the rule of the load balancer and then deletes the target group itself. – JulienChamp Dec 30 '21 at 09:09
  • Here is the policy of the lambda : `code` { "Policy": "{\"Version\":\"2012-10-17\",\"Id\":\"default\",\"Statement\":[{\"Sid\":\"AWSEvents_EcsRule_Id211fca52-a8ed-4125-a7dd-bb2038f731f1\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"events.amazonaws.com\"},\"Action\":\"lambda:InvokeFunction\",\"Resource\":\"arn:aws:lambda:eu-west-3:xxx:function:KillTask\",\"Condition\":{\"ArnLike\":{\"AWS:SourceArn\":\"arn:aws:events:eu-west-3:xxx:rule/EcsRule\"}}}]}", "RevisionId": "05e93087-5020-4c9a-a689-724d68f91293" } `code` – JulienChamp Dec 30 '21 at 09:13

1 Answers1

0

So it seems the error was comming from my lambda function and because it was failing so often Event Bridge was blocking some of the calls of the lambda. Not that big of a deal afterall...

JulienChamp
  • 113
  • 1
  • 9