I'm developing a workflow in AWS. The scenario is: whenever I get a suspicious log entry in a log group like lot's of 403 errors. I want the instance to be isolated from the environment. Currently the flow is like this: Log group -> Metric filter -> Alarm -> Eventbridge Rule/ SNS -> Lambda. The problem is, to isolate the instance I need to pass the instance id to the lambda function either by SNS or through Eventbridge rule but nothing is working. The logs that are getting ingested have the instance id but how can I fetch that from the logs and send it to the lambda?
I tried it through SNS but for that the message should include the instance id in JSON which should look like this: { "instance_i": "i-xxxx" }
But not getting a way to do that. Same is through Eventbridge rule. How can I fetch the instance id and send it to the lambda function? Can you please help me with that?