Skip to content

Commit 5cc1cbd

Browse files
committed
feat: switch from attaching policies in role resource
1 parent 24183bb commit 5cc1cbd

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

main.tf

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,22 +159,22 @@ resource "aws_iam_role" "this" {
159159
}]
160160
})
161161

162-
managed_policy_arns = [
163-
"arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
164-
]
162+
tags = module.eip_manager_label.tags
163+
}
165164

166-
inline_policy {
167-
name = "access"
168-
policy = data.aws_iam_policy_document.this[0].json
169-
}
165+
resource "aws_iam_role_policy" "this" {
166+
count = module.this.enabled ? 1 : 0
170167

171-
tags = module.eip_manager_label.tags
168+
name = "service-access"
169+
role = aws_iam_role.this[0].name
170+
policy = data.aws_iam_policy_document.this[0].json
172171
}
173172

174173
data "aws_iam_policy_document" "this" {
175174
count = module.this.enabled ? 1 : 0
176175

177176
statement {
177+
sid = "AllowManagingEc2InstanceEIP"
178178
effect = "Allow"
179179
actions = [
180180
"ec2:DescribeAddresses",
@@ -187,4 +187,17 @@ data "aws_iam_policy_document" "this" {
187187
"*",
188188
]
189189
}
190+
191+
statement {
192+
sid = "AllowLambdaBasicExecution"
193+
effect = "Allow"
194+
actions = [
195+
"logs:CreateLogGroup",
196+
"logs:CreateLogStream",
197+
"logs:PutLogEvents"
198+
]
199+
resources = [
200+
"*"
201+
]
202+
}
190203
}

0 commit comments

Comments
 (0)