@@ -2,7 +2,7 @@ terraform {
22 required_providers {
33 aws = {
44 source = " hashicorp/aws"
5- version = " ~> 4.22 "
5+ version = " ~> 5.0 "
66 }
77 }
88
@@ -29,7 +29,7 @@ resource "aws_lambda_function" "publisher_function" {
2929 source_code_hash = data. archive_file . lambda_zip_file . output_base64sha256
3030 handler = " app.handler"
3131 role = aws_iam_role. iam_for_lambda . arn
32- runtime = " nodejs16 .x"
32+ runtime = " nodejs22 .x"
3333}
3434
3535data "archive_file" "lambda_zip_file" {
@@ -43,11 +43,7 @@ data "aws_iam_policy" "lambda_basic_execution_role_policy" {
4343}
4444
4545resource "aws_iam_role" "iam_for_lambda" {
46- name_prefix = " PublisherFunctionRole-"
47- managed_policy_arns = [
48- data . aws_iam_policy . lambda_basic_execution_role_policy . arn ,
49- aws_iam_policy . event_bridge_put_events_policy . arn
50- ]
46+ name_prefix = " PublisherFunctionRole-"
5147
5248 assume_role_policy = << EOF
5349{
@@ -66,6 +62,16 @@ resource "aws_iam_role" "iam_for_lambda" {
6662EOF
6763}
6864
65+ resource "aws_iam_role_policy_attachment" "lambda_basic_execution" {
66+ role = aws_iam_role. iam_for_lambda . name
67+ policy_arn = data. aws_iam_policy . lambda_basic_execution_role_policy . arn
68+ }
69+
70+ resource "aws_iam_role_policy_attachment" "lambda_eventbridge" {
71+ role = aws_iam_role. iam_for_lambda . name
72+ policy_arn = aws_iam_policy. event_bridge_put_events_policy . arn
73+ }
74+
6975data "aws_iam_policy_document" "event_bridge_put_events_policy_document" {
7076 statement {
7177
0 commit comments