Skip to content

lambda-sqs-terraform: Update runtime to nodejs22.x #2813

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

kakakakakku
Copy link
Contributor

Issue #, if available:
N/A

Description of changes:
Hi😀 Thanks for the useful patterns!

To prevent future deployment issues, I updated the Lambda Node.js runtime version to nodejs22.x.

While testing lambda-sqs-terraform, I noticed that the Lambda runtime version nodejs16.x was deprecated. Although it's still deployable at the moment, it will not be allowed after October 1, 2025.
https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html

Check

terraform apply completed successfully and works good.

$ aws lambda invoke --function-name QueuePublisherFunction response.json --region us-east-1
$ aws sqs receive-message --queue-url https://sqs.us-east-1.amazonaws.com/000000000000/terraform-20250803233159603400000002 --region us-east-1
{
    "Messages": [
        {
            "MessageId": "0d21cb17-aebd-46c0-bd1a-7e751e8b36ea",
            "ReceiptHandle": "AQEBbxE0aKAGP2KiExKZCGcydSkEp5Z87jO8motSTMAuD7U260xhi2elRxlJEfTRT6BwCKuWYutUHw1IRTrEebk5sXcWN8mB9AAx0QZUUD+dYPk/XvRxuKHunhVN6Y1WqbI+VyvZHp3gYfmpMbOXtqmzWXXypoPb18WUTZ1sZ3Mc7MbT+zFoTwb6IBi/RGDRq2/q515PSBSt2ChdFvx5uUK8cUAnt/cwc8BKcLeyBPN36SuCJZSPpc0AT9SY3V3CnisWfCpfEASfRkrjQxdQL80T5aMP3lXhyF6GGI+8WD8S4fUB7BebZb7cksGk/HysuaJ6SornQ4B5uHyItYj1cRCwir4O9py29DJi/UkYvGQvDgwia/JY3Gd6zax9XLD+RpyYjosJGVjRUbuZubyGhIht3PTs+Mq4Cdl5siOsdk2Kmxk=",
            "MD5OfBody": "6dab270b464b247462756a3038f48ce5",
            "Body": "Message at Sun Aug 03 2025 23:49:16 GMT+0000 (Coordinated Universal Time)"
        }
    ]
}

Thank you😀


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@@ -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.

}
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 following error occurs. Because in Node.js 18 and later runtimes, AWS SDK v3 is bundled, so I rewrote it to v3. See articles below.

{"errorType":"Runtime.ImportModuleError","errorMessage":"Error: Cannot find module 'aws-sdk'\nRequire stack:\n- /var/task/app.js\n- /var/runtime/index.mjs","trace":["Runtime.ImportModuleError: Error: Cannot find module 'aws-sdk'","Require stack:","- /var/task/app.js","- /var/runtime/index.mjs","    at _loadUserApp (file:///var/runtime/index.mjs:1109:17)","    at async UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1148:21)","    at async start (file:///var/runtime/index.mjs:1332:23)","    at async file:///var/runtime/index.mjs:1339:1"]}%  

role = aws_iam_role.lambda_iam_role.name
policy_arn = aws_iam_policy.lambda_policy.arn
}

Copy link
Contributor Author

@kakakakakku kakakakakku Aug 4, 2025

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.

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants