-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathiam.tf
45 lines (42 loc) · 937 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
39
40
41
42
43
44
45
data "aws_iam_policy_document" "instance_permissions" {
statement {
actions = ["sts:GetCallerIdentity"]
resources = ["*"]
}
statement {
actions = [
"ec2:DescribeInstances",
]
resources = [
"*"
]
}
statement {
actions = [
"ec2:ModifyInstanceAttribute"
]
resources = [
"*"
]
condition {
test = "StringEquals"
values = [
aws_autoscaling_group.openvpn.name
]
variable = "ec2:ResourceTag/aws:autoscaling:groupName"
}
}
}
resource "random_string" "profile-suffix" {
length = 12
special = false
}
module "instance_profile" {
source = "registry.infrahouse.com/infrahouse/instance-profile/aws"
version = "1.4.0"
permissions = data.aws_iam_policy_document.instance_permissions.json
profile_name = "openvpn-${random_string.profile-suffix.result}"
extra_policies = merge(
var.extra_policies
)
}