Skip to content

Commit 25f979e

Browse files
authored
Merge pull request #2830 from kakakakakku/s3-lambda-terraform
s3-lambda-terraform: Update runtime to nodejs22.x
2 parents 5bf6432 + 5bfd917 commit 25f979e

3 files changed

Lines changed: 12 additions & 8 deletions

File tree

s3-lambda-terraform/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lambda.zip

s3-lambda-terraform/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# AWS S3 to AWS Lambda
1+
# Amazon S3 to AWS Lambda
22

33
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.
44

@@ -57,7 +57,7 @@ After deployment, upload an object to the S3. Go to the CloudWatch Logs for the
5757
```bash
5858
terraform show
5959
```
60-
```
60+
6161
----
6262
Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
6363

s3-lambda-terraform/main.tf

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_providers {
33
aws = {
44
source = "hashicorp/aws"
5-
version = "~> 3.27"
5+
version = "~> 5.0"
66
}
77
random = {
88
source = "hashicorp/random"
@@ -32,7 +32,7 @@ resource "aws_lambda_function" "lambda_s3_handler" {
3232
source_code_hash = data.archive_file.lambda_zip_file.output_base64sha256
3333
handler = "index.handler"
3434
role = aws_iam_role.iam_for_lambda.arn
35-
runtime = "nodejs16.x"
35+
runtime = "nodejs22.x"
3636
}
3737

3838
data "archive_file" "lambda_zip_file" {
@@ -59,9 +59,13 @@ resource "aws_iam_role" "iam_for_lambda" {
5959
]
6060
}
6161
EOF
62-
inline_policy {
63-
name = "lambda_logs_policy"
64-
policy = <<EOF
62+
}
63+
64+
resource "aws_iam_role_policy" "lambda_logs" {
65+
name = "lambda_logs_policy"
66+
role = aws_iam_role.iam_for_lambda.id
67+
68+
policy = <<EOF
6569
{
6670
"Version": "2012-10-17",
6771
"Statement": [
@@ -78,7 +82,6 @@ EOF
7882
]
7983
}
8084
EOF
81-
}
8285
}
8386

8487
resource "aws_lambda_permission" "allow_bucket_invoke_lambda" {

0 commit comments

Comments
 (0)