Description
Identify the invoking service or account in principal. Read it together with conditions such as source_arn to determine which calls are allowed.
Potential impact
Broad conditions can allow unintended invocations and increase execution costs.
Remediation
Limit service calls to the required source ARN and, where supported, source account. If the permission names an alias, point the event target to that same alias.
Examples
Both examples specify the RunDaily rule and the same function alias. Supply the ARN of your rule.
Before
hcl
resource "aws_lambda_permission" "example" {
statement_id = "AllowExecutionFromCloudWatch"
action = "lambda:InvokeFunction"
function_name = aws_lambda_function.test_lambda.function_name
principal = "*"
source_arn = "arn:aws:events:eu-west-1:111122223333:rule/RunDaily"
qualifier = aws_lambda_alias.test_alias.name
}
After
hcl
resource "aws_lambda_permission" "example" {
statement_id = "AllowExecutionFromCloudWatch"
action = "lambda:InvokeFunction"
function_name = aws_lambda_function.test_lambda.function_name
principal = "events.amazonaws.com"
source_arn = "arn:aws:events:eu-west-1:111122223333:rule/RunDaily"
qualifier = aws_lambda_alias.test_alias.name
}
The second changes only principal to events.amazonaws.com.