-
Notifications
You must be signed in to change notification settings - Fork 998
s3-lambda-terraform: Update runtime to nodejs22.x #2830
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
ff919cc
c78baca
90b6b5e
5bfd917
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lambda.zip |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# AWS S3 to AWS Lambda | ||
# Amazon S3 to AWS Lambda | ||
|
||
The Terraform template deploys a Lambda function, an S3 bucket and the IAM resources required to run the application. A Lambda function consumes <code>ObjectCreated</code> events from an Amazon S3 bucket. The Lambda code checks the uploaded file and console log the event. | ||
|
||
|
@@ -57,7 +57,7 @@ After deployment, upload an object to the S3. Go to the CloudWatch Logs for the | |
```bash | ||
terraform show | ||
``` | ||
``` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
---- | ||
Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ terraform { | |
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = "~> 3.27" | ||
version = "~> 5.0" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
} | ||
random = { | ||
source = "hashicorp/random" | ||
|
@@ -32,7 +32,7 @@ resource "aws_lambda_function" "lambda_s3_handler" { | |
source_code_hash = data.archive_file.lambda_zip_file.output_base64sha256 | ||
handler = "index.handler" | ||
role = aws_iam_role.iam_for_lambda.arn | ||
runtime = "nodejs16.x" | ||
runtime = "nodejs22.x" | ||
} | ||
|
||
data "archive_file" "lambda_zip_file" { | ||
|
@@ -59,9 +59,13 @@ resource "aws_iam_role" "iam_for_lambda" { | |
] | ||
} | ||
EOF | ||
inline_policy { | ||
name = "lambda_logs_policy" | ||
policy = <<EOF | ||
} | ||
|
||
resource "aws_iam_role_policy" "lambda_logs" { | ||
name = "lambda_logs_policy" | ||
role = aws_iam_role.iam_for_lambda.id | ||
|
||
policy = <<EOF | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: The |
||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
|
@@ -78,7 +82,6 @@ EOF | |
] | ||
} | ||
EOF | ||
} | ||
} | ||
|
||
resource "aws_lambda_permission" "allow_bucket_invoke_lambda" { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: Fix to correct service name.