-
Notifications
You must be signed in to change notification settings - Fork 0
/
iam.tf
164 lines (136 loc) · 3.45 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
resource "aws_iam_role" "clause_recommendation" {
name_prefix = "clause-recommendation-"
assume_role_policy = "${data.aws_iam_policy_document.clause_recommendation_trust_policy.json}"
}
resource "aws_iam_policy" "clause_recommendation" {
name_prefix = "clause-recommendation-"
policy = "${data.aws_iam_policy_document.clause_recommendation.json}"
}
resource "aws_iam_role_policy_attachment" "clause_recommendation" {
role = "${aws_iam_role.clause_recommendation.name}"
policy_arn = "${aws_iam_policy.clause_recommendation.arn}"
}
data "aws_iam_policy_document" "clause_recommendation" {
statement {
actions = [
"s3:ListBucket",
]
resources = [
"${aws_s3_bucket.models.arn}",
]
}
statement {
actions = [
"s3:PutObject",
"s3:GetObject",
"s3:DeleteObject",
]
resources = [
"${aws_s3_bucket.models.arn}/*",
]
}
}
data "aws_iam_policy_document" "clause_recommendation_trust_policy" {
statement {
actions = ["sts:AssumeRole"]
principals {
type = "AWS"
identifiers = ["${module.eks.worker_iam_role_arn}"]
}
}
}
resource "aws_iam_role" "contract_processor" {
name_prefix = "contract-processor-"
assume_role_policy = "${data.aws_iam_policy_document.contract_processor_trust_policy.json}"
}
resource "aws_iam_policy" "contract_processor" {
name_prefix = "contract-processor-"
policy = "${data.aws_iam_policy_document.contract_processor.json}"
}
resource "aws_iam_role_policy_attachment" "contract_processor" {
role = "${aws_iam_role.contract_processor.name}"
policy_arn = "${aws_iam_policy.contract_processor.arn}"
}
data "aws_iam_policy_document" "contract_processor" {
statement {
actions = [
"s3:ListBucket",
]
resources = [
"${aws_s3_bucket.documents.arn}",
]
}
statement {
actions = [
"s3:PutObject",
"s3:GetObject",
"s3:DeleteObject",
]
resources = [
"${aws_s3_bucket.documents.arn}/*",
]
}
}
data "aws_iam_policy_document" "contract_processor_trust_policy" {
statement {
actions = ["sts:AssumeRole"]
principals {
type = "AWS"
identifiers = ["${module.eks.worker_iam_role_arn}"]
}
}
}
resource "aws_iam_role" "graphql" {
name_prefix = "graphql-"
assume_role_policy = "${data.aws_iam_policy_document.graphql_trust_policy.json}"
}
resource "aws_iam_policy" "graphql" {
name_prefix = "graphql-"
policy = "${data.aws_iam_policy_document.graphql.json}"
}
resource "aws_iam_role_policy_attachment" "graphql" {
role = "${aws_iam_role.graphql.name}"
policy_arn = "${aws_iam_policy.graphql.arn}"
}
data "aws_iam_policy_document" "graphql" {
statement {
actions = [
"s3:ListBucket",
]
resources = [
"${aws_s3_bucket.sdfdocuments.arn}",
]
}
statement {
actions = [
"s3:PutObject",
"s3:GetObject",
"s3:DeleteObject",
]
resources = [
"${aws_s3_bucket.sdfdocuments.arn}/*",
]
}
statement {
actions = [
"SES:SendEmail",
"SES:SendRawEmail"
# ],
]
resources = ["*"]
condition {
test = "StringEquals"
variable = "ses:FromAddress"
values = ["support@genieai.co"]
}
}
}
data "aws_iam_policy_document" "graphql_trust_policy" {
statement {
actions = ["sts:AssumeRole"]
principals {
type = "AWS"
identifiers = ["${module.eks.worker_iam_role_arn}"]
}
}
}