-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsts_role.tf
62 lines (50 loc) · 1.04 KB
/
sts_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
57
58
59
60
61
data "aws_iam_policy_document" "sts" {
statement {
effect = "Allow"
actions = [
"sts:AssumeRole",
]
principals {
type = "Service"
identifiers = [
"lambda.amazonaws.com",
"edgelambda.amazonaws.com",
]
}
}
}
data "aws_iam_policy_document" "this" {
statement {
effect = "Allow"
actions = [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:DescribeLogGroups",
"logs:DescribeLogStreams",
"logs:PutLogEvents",
"logs:GetLogEvents",
"logs:FilterLogEvents",
]
resources = [
"arn:aws:logs:*:*:*",
]
}
statement {
effect = "Allow"
actions = [
"lambda:GetFunction",
]
resources = [
aws_lambda_function.this.arn,
]
}
}
resource "aws_iam_role_policy" "this" {
name = var.name
role = aws_iam_role.this.id
policy = data.aws_iam_policy_document.this.json
}
resource "aws_iam_role" "this" {
name = var.name
assume_role_policy = data.aws_iam_policy_document.sts.json
}