-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtf-lambda-iam-role.tf
56 lines (48 loc) · 1.24 KB
/
tf-lambda-iam-role.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
resource "aws_iam_role" "log_retention" {
name = local.iam_role_name
assume_role_policy = data.aws_iam_policy_document.lambda_assume.json
permissions_boundary = var.permissions_boundary_arn
inline_policy {
name = "log_retention"
policy = data.aws_iam_policy_document.log_retention.json
}
tags = var.tags
}
data "aws_iam_policy_document" "log_retention" {
statement {
actions = [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents",
"logs:ListTagsForResource",
"logs:TagResource",
"logs:PutRetentionPolicy",
"logs:DescribeLogGroups"
]
resources = ["arn:${data.aws_partition.current.partition}:logs:*:*:*"]
}
statement {
actions = ["tag:GetResources"]
resources = ["*"]
}
dynamic "statement" {
for_each = var.kms_key_arn == null ? [] : [var.kms_key_arn]
content {
actions = ["kms:Decrypt"]
resources = [statement.value]
}
}
statement {
actions = ["ec2:*NetworkInterface*"]
resources = ["*"]
}
}
data "aws_iam_policy_document" "lambda_assume" {
statement {
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = ["lambda.amazonaws.com"]
}
}
}