-
Notifications
You must be signed in to change notification settings - Fork 0
/
iam.tf
32 lines (27 loc) · 982 Bytes
/
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
data "aws_iam_policy_document" "ecs_node_doc" {
statement {
actions = ["sts:AssumeRole"]
effect = "Allow"
principals {
type = "Service"
identifiers = ["ec2.amazonaws.com"]
}
}
}
resource "aws_iam_role" "ecs_node_role" {
name_prefix = "${local.identifier}-ecs-node-role"
assume_role_policy = data.aws_iam_policy_document.ecs_node_doc.json
}
resource "aws_iam_role_policy_attachment" "ecs_node_role_policy" {
role = aws_iam_role.ecs_node_role.name
policy_arn = "arn:aws:iam::aws:policy/service-role/AmazonEC2ContainerServiceforEC2Role"
}
resource "aws_iam_role_policy_attachment" "ssm_managed_instance_policy" {
role = aws_iam_role.ecs_node_role.name
policy_arn = "arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore"
}
resource "aws_iam_instance_profile" "ecs_node" {
name_prefix = "${local.identifier}-ecs-node-profile"
path = "/ecs/instance/"
role = aws_iam_role.ecs_node_role.name
}