-
Notifications
You must be signed in to change notification settings - Fork 51
/
iam.tf
63 lines (52 loc) · 2.44 KB
/
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
59
60
61
62
63
locals {
cluster_instance_policy_contents = coalesce(
var.cluster_instance_iam_policy_contents,
file("${path.module}/policies/cluster-instance-policy.json"))
}
resource "aws_iam_role" "cluster_instance_role" {
description = "cluster-instance-role-${var.component}-${var.deployment_identifier}-${var.cluster_name}"
assume_role_policy = file("${path.module}/policies/cluster-instance-role.json")
tags = local.tags
}
resource "aws_iam_policy" "cluster_instance_policy" {
description = "cluster-instance-policy-${var.component}-${var.deployment_identifier}-${var.cluster_name}"
policy = local.cluster_instance_policy_contents
}
resource "aws_iam_policy_attachment" "cluster_instance_policy_attachment" {
name = "cluster-instance-policy-attachment-${var.component}-${var.deployment_identifier}-${var.cluster_name}"
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.component}-${var.deployment_identifier}-${var.cluster_name}"
path = "/"
role = aws_iam_role.cluster_instance_role.name
}
resource "aws_iam_role" "cluster_service_role" {
description = "cluster-service-role-${var.component}-${var.deployment_identifier}-${var.cluster_name}"
assume_role_policy = file("${path.module}/policies/cluster-service-role.json")
tags = local.tags
}
resource "aws_iam_policy" "cluster_service_policy" {
description = "cluster-service-policy-${var.component}-${var.deployment_identifier}-${var.cluster_name}"
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.component}-${var.deployment_identifier}-${var.cluster_name}"
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"
}
}