-
Notifications
You must be signed in to change notification settings - Fork 1
/
iam.tf
38 lines (32 loc) · 1.19 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
resource "aws_iam_instance_profile" "default" {
name = "${module.this.id}-ecsInstanceProfile"
role = aws_iam_role.default.name
tags = module.this.tags
}
data "aws_iam_policy_document" "assume_role" {
statement {
effect = "Allow"
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = ["ec2.amazonaws.com"]
}
}
}
resource "aws_iam_role" "default" {
name = "${module.this.id}-ecsInstanceRole"
assume_role_policy = join("", data.aws_iam_policy_document.assume_role[*].json)
tags = module.this.tags
}
resource "aws_iam_role_policy_attachment" "amazon_ec2_container_service_for_ec2_role" {
policy_arn = "arn:aws:iam::aws:policy/service-role/AmazonEC2ContainerServiceforEC2Role"
role = aws_iam_role.default.name
}
resource "aws_iam_role_policy_attachment" "amazon_ec2_container_registry_read_only" {
policy_arn = "arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly"
role = aws_iam_role.default.name
}
resource "aws_iam_role_policy_attachment" "amazon_ssm_managed_instance_core" {
policy_arn = "arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore"
role = aws_iam_role.default.name
}