Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions eventbridge-lambda-terraform/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lambda.zip
10 changes: 7 additions & 3 deletions eventbridge-lambda-terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.22"
version = "~> 5.0"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Older version does not support Node.js 22 runtime. So I updated the version to v5.

}
}

Expand All @@ -20,7 +20,7 @@ resource "aws_lambda_function" "lambda_function" {
source_code_hash = data.archive_file.lambda_zip_file.output_base64sha256
handler = "app.handler"
role = aws_iam_role.lambda_iam_role.arn
runtime = "nodejs16.x"
runtime = "nodejs22.x"
}

data "archive_file" "lambda_zip_file" {
Expand All @@ -35,7 +35,6 @@ data "aws_iam_policy" "lambda_basic_execution_role_policy" {

resource "aws_iam_role" "lambda_iam_role" {
name_prefix = "EventBridgeLambdaRole-"
managed_policy_arns = [data.aws_iam_policy.lambda_basic_execution_role_policy.arn]

assume_role_policy = <<EOF
{
Expand All @@ -54,6 +53,11 @@ resource "aws_iam_role" "lambda_iam_role" {
EOF
}

resource "aws_iam_role_policy_attachment" "lambda_basic_execution" {
role = aws_iam_role.lambda_iam_role.name
policy_arn = data.aws_iam_policy.lambda_basic_execution_role_policy.arn
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: The managed_policy_arns argument is already deprecated. I update code correctly😀 See document below.

resource "aws_cloudwatch_event_rule" "event_rule" {
name_prefix = "eventbridge-lambda-"
event_pattern = <<EOF
Expand Down