-
Notifications
You must be signed in to change notification settings - Fork 0
/
main-iam.tf
40 lines (36 loc) · 947 Bytes
/
main-iam.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
data aws_region current {
}
data aws_iam_policy_document assume_role_policy {
version = "2012-10-17"
statement {
actions = ["sts:AssumeRole"]
effect = "Allow"
principals {
identifiers = ["lambda.amazonaws.com", "edgelambda.amazonaws.com"]
type = "Service"
}
}
}
data aws_iam_policy_document role_policy {
version = "2012-10-17"
statement {
effect = "Allow"
actions = [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
]
resources = [
"arn:aws:logs:*:*:*"]
}
}
resource aws_iam_role lambda {
name = "${local.lambda_name}-${data.aws_region.current.name}"
assume_role_policy = data.aws_iam_policy_document.assume_role_policy.json
tags = local.tags
}
resource aws_iam_role_policy cloudwatch {
name = "cloudwatch"
role = aws_iam_role.lambda.id
policy = data.aws_iam_policy_document.role_policy.json
}