I am using this command to stream log to a lambda function.
aws logs put-subscription-filter --log-group-name $LOG_GROUP_NAME --filter-name $LAMBDA_NAME --filter-pattern '' --destination-arn $LAMBDA_ARN
but got this error:
An error occurred (InvalidParameterException) when calling the PutSubscriptionFilter operation: Could not execute the lambda function. Make sure you have given CloudWatch Logs permission to execute your function.
It seems the log doesn't have permission to invoke my lambda. How can I give the permission? There will be hundreds of log group in my account. I don't want to give permission to each log group one by one. Is there a solution to allow any log to invoke the lambda function?