-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcluster-execution-role.tf
58 lines (55 loc) · 1.32 KB
/
cluster-execution-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
###### TASK EXECUTION ROLE ###### Identical for all tasks #########
resource "aws_iam_role" "task_exe" {
name = "${local.resources_prefix}-taskexec-role"
assume_role_policy = jsonencode(
{
Version = "2012-10-17",
Statement = [
{
Action = "sts:AssumeRole",
Principal = {
Service = [
"ecs-tasks.amazonaws.com"
]
},
Effect = "Allow"
}
]
})
}
resource "aws_iam_policy" "task_exe" {
name = "${local.resources_prefix}-taskexec-policy"
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Effect = "Allow",
Action = [
"ecr:GetAuthorizationToken",
"ecr:BatchCheckLayerAvailability",
"ecr:GetDownloadUrlForLayer",
"ecr:BatchGetImage",
"logs:CreateLogStream",
"logs:PutLogEvents",
"ssm:GetParameters"
],
Resource = "*"
},
{
Effect = "Allow",
Action = [
"kms:Decrypt*",
"kms:Describe*"
],
Resource = [
aws_kms_key.cluster.arn,
aws_kms_key.registry.arn
]
}
]
})
}
resource "aws_iam_role_policy_attachment" "task_exe" {
role = aws_iam_role.task_exe.id
policy_arn = aws_iam_policy.task_exe.arn
}