Ensures Lambda permissions are re-applied when the underlying function changes, using a lifecycle configuration.

Terraform Template

resource "aws_lambda_permission" "logging" {
  action = "lambda:InvokeFunction"
  function_name = "aws_lambda_function.example.function_name"

  lifecycle {
    replace_triggered_by = ["aws_lambda_function.example"]
  }
  principal = "events.amazonaws.com"
  source_arn = "arn:aws:events:eu-west-1:111122223333:rule/RunDaily"
}