Lambda function permissions must not use wildcard principals (*). This effectively allows any AWS account or anonymous principal to invoke the function, increasing the risk of unauthorized invocations and data exposure.
In Ansible, check tasks using the amazon.aws.lambda_policy or lambda_policy modules and ensure the principal property does not contain * or other wildcard values. The principal must specify explicit principals such as an AWS account ARN, role ARN, or service principal (for example, arn:aws:iam::123456789012:role/MyRole or events.amazonaws.com). Tasks where principal includes * are flagged.
Secure example using an explicit service principal:
- name:Allow EventBridge to invoke Lambdaamazon.aws.lambda_policy:state:presentfunction_name:my-functionprincipal:events.amazonaws.comaction:lambda:InvokeFunctionsource_arn:arn:aws:events:us-east-1:123456789012:rule/MyRule