forked from aws-samples/aws-mainframe-modernization-carddemo
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathiam.tf
More file actions
47 lines (41 loc) · 1.39 KB
/
Copy pathiam.tf
File metadata and controls
47 lines (41 loc) · 1.39 KB
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_assume" {
statement {
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = ["ecs-tasks.amazonaws.com"]
}
}
}
# Execution role: pull images from ECR, write logs.
resource "aws_iam_role" "execution" {
name = "${local.name_prefix}-ecs-execution"
assume_role_policy = data.aws_iam_policy_document.ecs_assume.json
tags = { Name = "${local.name_prefix}-ecs-execution" }
}
resource "aws_iam_role_policy_attachment" "execution" {
role = aws_iam_role.execution.name
policy_arn = "arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy"
}
# Task role: the running container's identity. EFS access via IAM authorization.
resource "aws_iam_role" "task" {
name = "${local.name_prefix}-ecs-task"
assume_role_policy = data.aws_iam_policy_document.ecs_assume.json
tags = { Name = "${local.name_prefix}-ecs-task" }
}
data "aws_iam_policy_document" "task_efs" {
statement {
sid = "EfsClientAccess"
actions = [
"elasticfilesystem:ClientMount",
"elasticfilesystem:ClientWrite",
"elasticfilesystem:ClientRootAccess",
]
resources = ["*"]
}
}
resource "aws_iam_role_policy" "task_efs" {
name = "${local.name_prefix}-task-efs"
role = aws_iam_role.task.id
policy = data.aws_iam_policy_document.task_efs.json
}