To resolve the error, reduce your function's policy's size by removing repetitive policy statements and replacing them with consolidated statements that use wildcards (*). For more information, see Lambda quotas and Cleaning up resource-based policies.
Note: You can also use the command line JSON processor, jq, in the get-policy command to write advanced queries. For information on how to download and install jq, see Download jq on the jq website on GitHub.
Example get-policy command that uses jq to format a Lambda function's policy as a JSON file
2. In the resource-based policy, identify policy statements that you can replace with a wildcard. Note the Sid of each policy statement.
Remove repetitive policy statements
Run the following remove-permission AWS CLI command to remove each repetitive policy statement. Replace my-function with your function's name or ARN. Replace sid with the Sid of the policy statement that you want to remove.
Run the following add-permission AWS CLI command to add new, consolidated policy statements that include a wildcard (*), Replace my-function with your function's name or ARN. Replace sid with a new Sid of any value. Replace events.amazonaws.com with the AWS service or account principal that invokes your function. Replace arn:aws:events:region:account-id:rule/test-* with an ARN string (plus a wildcard) shared by the resources that you're granting permissions to.