-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathiam.tf
37 lines (30 loc) · 846 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
#AWS SSM resources
resource "aws_iam_role" "this" {
count = var.asg_enabled ? 0 : 1
name = "${var.env}-${var.name}"
assume_role_policy = data.aws_iam_policy_document.this[count.index].json
}
resource "aws_iam_role_policy_attachment" "this" {
count = var.asg_enabled ? 0 : 1
role = aws_iam_role.this[count.index].name
policy_arn = var.ssm_role
}
resource "aws_iam_instance_profile" "this" {
count = var.asg_enabled ? 0 : 1
name = "${var.env}-${var.name}"
role = aws_iam_role.this[count.index].name
}
data "aws_iam_policy_document" "this" {
count = var.asg_enabled ? 0 : 1
statement {
effect = "Allow"
principals {
type = "Service"
identifiers = [
"ec2.amazonaws.com",
"ssm.amazonaws.com",
]
}
actions = ["sts:AssumeRole"]
}
}