-
Notifications
You must be signed in to change notification settings - Fork 0
/
iam_policy.tf
44 lines (40 loc) · 1.1 KB
/
iam_policy.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
39
40
41
42
43
44
resource "aws_iam_role" "role" {
name = join("_", [var.name, "role"])
assume_role_policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = "sts:AssumeRole"
Effect = "Allow"
Principal = {
Service = "ec2.amazonaws.com"
}
}
]
})
}
resource "aws_iam_role_policy" "rl_policy" {
name = join("_", [var.name, "role_policy"])
role = aws_iam_role.role.id
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Effect = "Allow"
Action = [
"ssm:GetParameter"
]
Resource = "*"
}
]
})
}
resource "aws_iam_role_policy_attachment" "attachment" {
count = length(local.role_policy_arns)
role = aws_iam_role.role.name
policy_arn = element(local.role_policy_arns, count.index)
}
resource "aws_iam_instance_profile" "profile" {
name = join("_", [var.name, "instance_profile"])
role = aws_iam_role.role.name
}