-
Notifications
You must be signed in to change notification settings - Fork 4
/
iam.tf
executable file
·97 lines (80 loc) · 2.48 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# Render policies
data "aws_iam_policy_document" "DynDBPolicies" {
statement {
actions = [
"dynamodb:PutItem",
"dynamodb:DeleteItem",
"dynamodb:GetItem",
"dynamodb:UpdateItem",
"dynamodb:Query",
]
resources = [
"${aws_dynamodb_table.dyndb.arn}",
]
effect = "Allow"
}
}
data "aws_iam_policy_document" "SwarmSQSCleanupPolicy" {
statement {
actions = [
"sqs:*",
]
resources = [
"${aws_sqs_queue.swarm-cleanup.arn}",
]
effect = "Allow"
}
}
data "aws_iam_policy_document" "SwarmSQSPolicy" {
statement {
actions = [
"sqs:*",
]
resources = [
"${aws_sqs_queue.swarm-sqs.arn}",
]
effect = "Allow"
}
}
# Policies
resource "aws_iam_role" "ProxyRole" {
name = "${var.name}-tf-${var.environment}-ProxyRole"
assume_role_policy = "${file("${path.module}/policies/ProxyRole.json")}"
}
resource "aws_iam_instance_profile" "ProxyInstanceProfile" {
name = "${var.name}-tf-${var.environment}-ProxyInstanceProfile"
role = "${aws_iam_role.ProxyRole.name}"
}
resource "aws_iam_role_policy" "ProxyPolicies" {
name = "${var.name}-tf-${var.environment}-ProxyPolicies"
policy = "${file("${path.module}/policies/ProxyPolicies.json")}"
role = "${aws_iam_role.ProxyRole.name}"
}
resource "aws_iam_role_policy" "DynDBPolicies" {
name = "${var.name}-tf-${var.environment}-DynDBPolicies"
policy = "${data.aws_iam_policy_document.DynDBPolicies.json}"
role = "${aws_iam_role.ProxyRole.name}"
depends_on = [
"aws_dynamodb_table.dyndb",
]
}
resource "aws_iam_role_policy" "SwarmAPIPolicy" {
name = "${var.name}-tf-${var.environment}-SwarmAPIPolicy"
policy = "${file("${path.module}/policies/SwarmAPIPolicy.json")}"
role = "${aws_iam_role.ProxyRole.name}"
}
resource "aws_iam_role_policy" "SwarmAutoscalePolicy" {
name = "${var.name}-tf-${var.environment}-SwarmAutoscalePolicy"
policy = "${file("${path.module}/policies/SwarmAutoscalePolicy.json")}"
role = "${aws_iam_role.ProxyRole.name}"
}
resource "aws_iam_role_policy" "SwarmSQSCleanupPolicy" {
name = "${var.name}-tf-${var.environment}-SwarmSQSCleanupPolicy"
policy = "${data.aws_iam_policy_document.SwarmSQSCleanupPolicy.json}"
role = "${aws_iam_role.ProxyRole.name}"
}
resource "aws_iam_role_policy" "SwarmSQSPolicy" {
name = "${var.name}-tf-${var.environment}-SwarmSQSPolicy"
policy = "${data.aws_iam_policy_document.SwarmSQSPolicy.json}"
role = "${aws_iam_role.ProxyRole.name}"
}