-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiam.tf
45 lines (39 loc) · 1.01 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
data "aws_iam_policy_document" "tdbot_assume_role" {
statement {
effect = "Allow"
actions = ["sts:AssumeRole"]
principals {
identifiers = [
"ecs.amazonaws.com",
"ecs-tasks.amazonaws.com",
"events.amazonaws.com",
]
type = "Service"
}
}
}
data "aws_iam_policy_document" "tdbot" {
statement {
effect = "Allow"
actions = ["ecs:RunTask", "logs:CreateLogStream", "logs:PutLogEvents"]
resources = ["*"]
}
statement {
actions = ["iam:PassRole"]
resources = [aws_iam_role.tdbot.arn]
}
statement {
effect = "Allow"
actions = ["secretsmanager:*"]
resources = [local.secrets_arn]
}
}
resource "aws_iam_role" "tdbot" {
name = "${local.name_prefix}tdbot-role"
assume_role_policy = data.aws_iam_policy_document.tdbot_assume_role.json
}
resource "aws_iam_role_policy" "tdbot" {
name = "${local.name_prefix}tdbot-policy"
role = aws_iam_role.tdbot.id
policy = data.aws_iam_policy_document.tdbot.json
}