Skip to content

Commit a20c102

Browse files
committed
eventbridge-sns-lambda-terraform: Fix deprecated managed_policy_arns argument
1 parent 7de42df commit a20c102

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

  • eventbridge-sns-lambda-terraform

eventbridge-sns-lambda-terraform/main.tf

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,8 @@ resource "aws_lambda_function" "lambda_function" {
106106
runtime = "nodejs22.x"
107107
}
108108

109-
110109
resource "aws_iam_role" "lambda_iam_role" {
111-
name_prefix = "LambdaSNSRole-"
112-
managed_policy_arns = [
113-
data.aws_iam_policy.lambda_basic_execution_role_policy.arn
114-
]
110+
name_prefix = "LambdaSNSRole-"
115111

116112
assume_role_policy = <<EOF
117113
{
@@ -130,6 +126,11 @@ resource "aws_iam_role" "lambda_iam_role" {
130126
EOF
131127
}
132128

129+
resource "aws_iam_role_policy_attachment" "lambda_basic_execution" {
130+
role = aws_iam_role.lambda_iam_role.name
131+
policy_arn = data.aws_iam_policy.lambda_basic_execution_role_policy.arn
132+
}
133+
133134
resource "aws_lambda_permission" "with_sns" {
134135
statement_id = "AllowExecutionFromSNS"
135136
action = "lambda:InvokeFunction"
@@ -138,10 +139,6 @@ resource "aws_lambda_permission" "with_sns" {
138139
source_arn = aws_sns_topic.MySNSTopic.arn
139140
}
140141

141-
142-
143-
144-
145142
//---------------------------------------------------------
146143
// Output
147144
//---------------------------------------------------------

0 commit comments

Comments
 (0)