-
Notifications
You must be signed in to change notification settings - Fork 0
/
iam.tf
47 lines (43 loc) · 1.16 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
47
data "aws_iam_policy_document" "ecs_task_trust" {
statement {
effect = "Allow"
principals {
type = "Service"
identifiers = ["ecs-tasks.amazonaws.com"]
}
actions = ["sts:AssumeRole"]
}
}
data "aws_iam_policy_document" "ecs_task_policy" {
statement {
actions = [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
]
effect = "Allow"
resources = ["*"]
}
statement {
actions = ["secretsmanager:GetSecretValue"]
effect = "Allow"
resources = [ aws_secretsmanager_secret.wordpress.arn ]
}
statement {
actions = ["kms:Decrypt"]
effect = "Allow"
resources = [ aws_kms_key.wordpress.arn ]
}
}
resource "aws_iam_role" "ecs_task_role" {
name = "wordpressTaskRole"
assume_role_policy = data.aws_iam_policy_document.ecs_task_trust.json
}
resource "aws_iam_policy" "ecs_task_policy" {
name = "wordpressTaskPolicy"
policy = data.aws_iam_policy_document.ecs_task_policy.json
}
resource "aws_iam_role_policy_attachment" "ecs_role_attachment" {
role = aws_iam_role.ecs_task_role.name
policy_arn = aws_iam_policy.ecs_task_policy.arn
}