forked from springload/terraform-aws-ecs-cluster
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathiam.tf
39 lines (32 loc) · 802 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
33
34
35
36
37
38
resource "aws_iam_role" "ec2-role" {
name = var.cluster_name
assume_role_policy = <<-EOT
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "ec2.amazonaws.com"
},
"Effect": "Allow",
"Sid": ""
}
]
}
EOT
}
locals {
managed_roles = [
"arn:aws:iam::aws:policy/service-role/AmazonEC2ContainerServiceforEC2Role",
]
}
resource "aws_iam_role_policy_attachment" "ec2-role-attach" {
role = aws_iam_role.ec2-role.name
count = length(local.managed_roles)
policy_arn = element(local.managed_roles, count.index)
}
resource "aws_iam_instance_profile" "ec2-instance-role" {
name = var.cluster_name
role = aws_iam_role.ec2-role.name
}