-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcluster_iam.tf
58 lines (48 loc) · 2.09 KB
/
cluster_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
46
47
48
49
50
51
52
53
54
55
56
57
58
resource "aws_iam_role" "cluster_instance_role" {
description = "cluster-instance-role-${var.env}-strata"
assume_role_policy = file("${path.module}/policies/cluster-instance-role.json")
}
data "template_file" "cluster_instance_policy" {
template = file("${path.module}/policies/cluster-instance-policy.json")
}
resource "aws_iam_policy" "cluster_instance_policy" {
description = "cluster-instance-policy-${var.env}-strata"
policy = coalesce(var.cluster_instance_iam_policy_contents, data.template_file.cluster_instance_policy.rendered)
}
resource "aws_iam_policy_attachment" "cluster_instance_policy_attachment" {
name = "cluster-instance-policy-attachment-${var.env}-strata"
roles = [aws_iam_role.cluster_instance_role.id]
policy_arn = aws_iam_policy.cluster_instance_policy.arn
}
resource "aws_iam_instance_profile" "cluster" {
name = "cluster-instance-profile-${var.env}-strata"
path = "/"
role = aws_iam_role.cluster_instance_role.name
}
resource "aws_iam_role" "cluster_service_role" {
description = "cluster-service-role-${var.env}-strata"
assume_role_policy = file("${path.module}/policies/cluster-service-role.json")
}
resource "aws_iam_policy" "cluster_service_policy" {
description = "cluster-service-policy-${var.env}-strata"
policy = coalesce(var.cluster_service_iam_policy_contents, file("${path.module}/policies/cluster-service-policy.json"))
}
resource "aws_iam_policy_attachment" "cluster_service_policy_attachment" {
name = "cluster-instance-policy-attachment-${var.env}-strata"
roles = [aws_iam_role.cluster_service_role.id]
policy_arn = aws_iam_policy.cluster_service_policy.arn
}
resource "null_resource" "iam_wait" {
depends_on = [
aws_iam_role.cluster_instance_role,
aws_iam_policy.cluster_instance_policy,
aws_iam_policy_attachment.cluster_instance_policy_attachment,
aws_iam_instance_profile.cluster,
aws_iam_role.cluster_service_role,
aws_iam_policy.cluster_service_policy,
aws_iam_policy_attachment.cluster_service_policy_attachment
]
provisioner "local-exec" {
command = "sleep 30"
}
}