For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/security/code_security/iac_security/iac_rules/ansible/aws/lambda_permission_principal_is_wildcard.md.
A documentation index is available at /llms.txt.
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