-
Notifications
You must be signed in to change notification settings - Fork 7
/
iam.tf
46 lines (38 loc) · 1.07 KB
/
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
41
42
43
44
45
46
resource "aws_iam_role" "lambda_role" {
name = "${var.name_prefix}_lambda_role${var.has_random_postfix ? "_${random_string.lambda_postfix_generator.result}" : ""}"
assume_role_policy = data.aws_iam_policy_document.lambda_assume.json
}
data "aws_iam_policy_document" "lambda_assume" {
statement {
effect = "Allow"
actions = [
"sts:AssumeRole",
]
principals {
type = "Service"
identifiers = [
"lambda.amazonaws.com",
]
}
}
}
resource "aws_iam_role_policy" "lambda_main" {
name = "${var.name_prefix}_lambda_policy${var.has_random_postfix ? "_${random_string.lambda_postfix_generator.result}" : ""}"
role = aws_iam_role.lambda_role.name
policy = data.aws_iam_policy_document.lambda_services_dashboard.json
}
data "aws_iam_policy_document" "lambda_services_dashboard" {
statement {
effect = "Allow"
actions = [
"ecs:*",
"cloudwatch:*",
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents",
]
resources = [
"arn:aws:logs:*:*:*",
]
}
}