You don't appear to be setting the qualifier parameter on aws_lambda_function_event_invoke_config.

If you are publishing a new version, either use an alias or set qualifier = aws_lambda_function.lambda-deploy.version. If you don't intend to use a published version, set the qualifier = "$LATEST" or use the default.

Answer from Dan Monego on Stack Overflow
🌐
Terraform Registry
registry.terraform.io › providers › hashicorp › aws › latest › docs › resources › lambda_function_event_invoke_config
aws_lambda_function_event_invoke_config | Resources | hashicorp/aws | Terraform | Terraform Registry
resource "aws_lambda_function_event_invoke_config" "example" { function_name = aws_lambda_function.example.function_name maximum_event_age_in_seconds = 60 # 1 minute - fail fast maximum_retry_attempts = 0 # No retries }Copy
🌐
Shisho Cloud
shisho.dev › dojo › providers › aws › Lambda › aws-lambda-function-event-invoke-config
AWS Lambda Function Event Invoke Config - Examples and best practices | Shisho Dojo
The Function Event Invoke Config in Lambda can be configured in Terraform with the resource name aws_lambda_function_event_invoke_config.
🌐
Baeldung
baeldung.com › home › deployment tools › how to set up aws lambda function in terraform
How To Set Up AWS Lambda Function in Terraform | Baeldung on Ops
March 27, 2025 - The above configuration sets up AWS as the infrastructure provider and targets the us-east-1 region as the location for all resources. Based on the project structure, the Lambda function goes into hello_lambda.py. When invoked, this Python Lambda function returns a JSON response with a greeting and the environment name: $ cat ~/aws-lambda-terraform/lambda/hello-lambda.py import json import os def lambda_handler(event, context): return { 'statusCode': 200, 'body': json.dumps({ 'message': 'Hello from Lambda!', 'environment': os.getenv('ENV', 'default') }) }
Top answer
1 of 4
275

You can use an aws_cloudwatch_event_target resource to tie the scheduled event source (event rule) to your lambda function. You need to grant it permission to invoke your lambda function; you can use an aws_lambda_permission resource for this.

Example:

resource "aws_lambda_function" "check_foo" {
    filename = "check_foo.zip"
    function_name = "checkFoo"
    role = "arn:aws:iam::424242:role/something"
    handler = "index.handler"
}

resource "aws_cloudwatch_event_rule" "every_five_minutes" {
    name = "every-five-minutes"
    description = "Fires every five minutes"
    schedule_expression = "rate(5 minutes)"
}

resource "aws_cloudwatch_event_target" "check_foo_every_five_minutes" {
    rule = aws_cloudwatch_event_rule.every_five_minutes.name
    target_id = "check_foo"
    arn = aws_lambda_function.check_foo.arn
}

resource "aws_lambda_permission" "allow_cloudwatch_to_call_check_foo" {
    statement_id = "AllowExecutionFromCloudWatch"
    action = "lambda:InvokeFunction"
    function_name = aws_lambda_function.check_foo.function_name
    principal = "events.amazonaws.com"
    source_arn = aws_cloudwatch_event_rule.every_five_minutes.arn
}
2 of 4
6

Verbjorns Ljosa's answer only includes permissions for cloudwatch to invoke the lambda. Have you specified the proper policy and iam role that allows the lambda to perform its actions?

resource "aws_iam_role" "check_foo_role" {
  name="check-foo-assume-role"
  assume_role_policy="assume_role_policy.json"
}

with assume_role_policy.json

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Action": "sts:AssumeRole",
      "Principal": {
        "Service": "lambda.amazonaws.com"
      },
      "Effect": "Allow",
      "Sid": ""
    }
  ]
}

and a policy referencing the above resource iam role I.e. something like

resource "iam_role_policy" "check-foo-policy" {
  name="check-foo-lambda-policy"
  # referencing the iam role above
  role="${aws_iam_role.check_foo_role.id}"
  policy="check-foo-policy.json"
}

and finally the json specifying the policy, check-foo-policy.json.

{
  "Version": "2012-10-17",
  "Statement": [
    {
  "Effect": "Allow",
  "Action": [
    "logs:CreateLogGroup",
    "logs:CreateLogStream",
    "logs:PutLogEvents"
  ],
  "Resource": ["*"]
},
{
  "Effect": "Allow",
  "Action": [
    "abc:SomeAction",
    "abc:AnotherAction",
  ],
  "Resource": "some-arn-matching-the-actions"
}

Do note that you cannot specify a Resource restriction for the logs-related actions. abc:SomeAction might be ssm:GetParameter with an accompanying resource arn like "arn:aws:ssm:us-east-1:${your-aws-account-id}:parameter/some/parameter/path/*

Find elsewhere
🌐
Mattias
mattias.engineer › blog › 2025 › terraform-actions-deep-dive
Terraform Actions: Deep-Dive · mattias.engineer
September 25, 2025 - You could provision a Lambda resource in the same Terraform configuration where the action is configured and reference aws_lambda_function.<symbolic name>.function_name in the function_name argument of the action. To trigger the action in the previous code block using the Terraform CLI you can run this command: $ terraform apply \ -auto-approve \ -invoke=action.aws_lambda_invoke.message Terraform will perform the following actions: Plan: 0 to add, 0 to change, 0 to destroy.
🌐
Lumigo
lumigo.io › aws-lambda-deployment › aws-lambda-terraform
Deploying AWS Lambda with Terraform: Quick Tutorial and Basic Concepts · Dash0
4 weeks ago - It configures the ARN of the event source that triggers the Lambda function. It also defines the properties to control the behavior when triggering the function. Below is a Terraform AWS example of a DynamoDB event source:
🌐
Terraform Registry
registry.terraform.io › providers › hashicorp › awS › latest › docs › actions › lambda_invoke
aws_lambda_invoke | Actions | hashicorp/aws | Terraform | Terraform Registry
resource "aws_lambda_function" "example" { # ... function configuration } action "aws_lambda_invoke" "example" { config { function_name = aws_lambda_function.example.function_name payload = jsonencode({ key1 = "value1" key2 = "value2" }) } } resource "terraform_data" "example" { input = "trigger-lambda" lifecycle { action_trigger { events = [before_create, before_update] actions = [action.aws_lambda_invoke.example] } } }Copy
🌐
GitHub
github.com › terraform-aws-modules › terraform-aws-lambda
GitHub - terraform-aws-modules/terraform-aws-lambda: Terraform module, which takes care of a lot of AWS Lambda/serverless tasks (build dependencies, packages, updates, deployments) in countless combinations 🇺🇦
Control nearly all aspects of Lambda resources (provisioned concurrency, VPC, EFS, dead-letter notification, tracing, async events, event source mapping, IAM role, IAM policies, and more). Support integration with other serverless.tf modules like HTTP API Gateway (see examples there). module "lambda_function" { source = "terraform-aws-modules/lambda/aws" function_name = "my-lambda1" description = "My awesome lambda function" handler = "index.lambda_handler" runtime = "python3.12" source_path = "../src/lambda-function1" tags = { Name = "my-lambda1" } }
Starred by 1K users
Forked by 761 users
Languages   HCL 59.8% | Python 40.2%
🌐
GitHub
github.com › terraform-aws-modules › terraform-aws-lambda › issues › 263
ResourceConflictException: concurrent updates during Lambda creation · Issue #263 · terraform-aws-modules/terraform-aws-lambda
February 1, 2022 - We're basically calling aws_lambda_function_event_invoke_config twice (instead of just once), with the first one just for current_version, and the second one for unqualified_alias, which then depends_on the first one to being fully created. The yellow rectangles show the relevant changes and additions, whereas you should know that the second call to aws_lambda_function_event_invoke_config was not there before.
Author   riy
🌐
DEV Community
dev.to › aws-builders › how-to-schedule-the-execution-of-your-lambda-code-2fl3
How to schedule your Lambda with Terraform? - DEV Community
February 20, 2022 - Notice how we specify the InvokeFunction in the "action", then define the function name and the source (that's the event bridge rule) Run the following commands to validate and deploy the infrastructure: ... To make sure it's working, log in to the AWS console, select your Lambda function and click the "Monitor" tab.
🌐
GitHub
github.com › mineiros-io › terraform-aws-lambda-function
GitHub - mineiros-io/terraform-aws-lambda-function: A Terraform module for deploying and managing Lambda functions on Amazon Web Services (AWS). https://aws.amazon.com/lambda/
A list of permission objects of external resources (like a CloudWatch Event Rule, SNS, or S3) that should have permission to access the Lambda function. Default is []. ... permissions = [ { statement_id = "AllowExecutionFromSNS" principal = ...
Starred by 41 users
Forked by 24 users
Languages   HCL 74.8% | Go 13.9% | Makefile 11.3% | HCL 74.8% | Go 13.9% | Makefile 11.3%
🌐
GitHub
github.com › hashicorp › terraform › issues › 14342
Cloudwatch Event trigger Lambda doesn't associate unless we do a manual update to cloudwatch event. · Issue #14342 · hashicorp/terraform
May 10, 2017 - Terraform Launches all the required resources as expected. But the Event trigger is not being associated with the lambda function. Had to update the cloudwatch event manually from the console to add it as a trigger to lambda and to invoke. We can reproduce by running below resources by providing some meaningful zip to the function. resource "aws_lambda_function" "waf_spam_list" { filename = "lambda.zip" function_name = "waf_spam_list" role = "arn:aws:iam::xxxxxxxxxxxx:role/xxxxxxxxxxxxx" handler = "index.handler" source_code_hash = "${base64sha256(file("lambda.zip"))}" runtime = "nodejs4.3" timeout = "59" }
Published   May 10, 2017
Author   s-nakka
🌐
DEV Community
dev.to › codeisgood › invoking-an-aws-lambda-function-with-terraform-3nl7
Invoking an AWS Lambda Function with Terraform - DEV Community
April 24, 2024 - Below is an example of Terraform code that achieves our goal. We'll create an AWS Lambda function, an IAM role for the function, and configure a CloudWatch Events rule to trigger the Lambda function on every terraform apply.