-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiam.tf
More file actions
38 lines (34 loc) · 964 Bytes
/
iam.tf
File metadata and controls
38 lines (34 loc) · 964 Bytes
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" "instance_profile" {
name = local.instance_profile_role_name
role = aws_iam_role.imagebuilder_role.name
}
resource "aws_iam_role_policy_attachment" "instance_role_managed_policy_attachment" {
role = aws_iam_role.imagebuilder_role.name
count = length(var.iam_policy_arn)
policy_arn = var.iam_policy_arn[count.index]
}
resource "aws_iam_role" "imagebuilder_role" {
name = local.imagebuilder_role_name
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": [
"imagebuilder.amazonaws.com",
"ec2.amazonaws.com"
]
},
"Effect": "Allow"
}
]
}
EOF
}
resource "aws_iam_role_policy_attachment" "managed_policy_attachment" {
role = aws_iam_role.imagebuilder_role.name
count = length(var.iam_policy_arn)
policy_arn = var.iam_policy_arn[count.index]
}