diff --git a/lambda-sns-terraform/.gitignore b/lambda-sns-terraform/.gitignore new file mode 100644 index 000000000..fb7595fad --- /dev/null +++ b/lambda-sns-terraform/.gitignore @@ -0,0 +1 @@ +lambda.zip diff --git a/lambda-sns-terraform/main.tf b/lambda-sns-terraform/main.tf index a8ba2622e..b071dbcab 100644 --- a/lambda-sns-terraform/main.tf +++ b/lambda-sns-terraform/main.tf @@ -2,7 +2,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = "~> 4.22" + version = "~> 5.0" } } @@ -22,7 +22,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" environment { variables = { SNStopic = aws_sns_topic.sns_topic.arn @@ -41,11 +41,7 @@ data "aws_iam_policy" "lambda_basic_execution_role_policy" { } resource "aws_iam_role" "lambda_iam_role" { - name_prefix = "LambdaSNSRole-" - managed_policy_arns = [ - data.aws_iam_policy.lambda_basic_execution_role_policy.arn, - aws_iam_policy.lambda_policy.arn - ] + name_prefix = "LambdaSNSRole-" assume_role_policy = < { @@ -16,6 +18,6 @@ exports.handler = async (event) => { } // Send to SNS - const result = await sns.publish(params).promise() + const result = await snsClient.send(new PublishCommand(params)) console.log(result) -} \ No newline at end of file +}