-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.tf
221 lines (175 loc) · 8.6 KB
/
main.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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
resource "random_string" "solution_prefix" {
length = 4
special = false
upper = false
}
############################################################################################################
# Networking resources
############################################################################################################
module "networking_resources" {
source = "./modules/networking-resources"
solution_prefix = local.solution_prefix
vpc_props = var.vpc_props
tags = local.root_combined_tags
}
############################################################################################################
# Persistent resources
############################################################################################################
module "persistence_resources" {
source = "./modules/persistence-resources"
solution_prefix = local.solution_prefix
open_search_service_type = "aoss"
open_search_props = merge(
var.open_search_props,
{
"subnet_ids" = [for _, value in module.networking_resources.private_subnet_attributes_by_az : value.id]
},
{
"master_user_arn" = data.aws_caller_identity.current.arn
},
{
"open_search_vpc_endpoint_id" = module.networking_resources.open_search_vpc_endpoint_id
}
)
force_destroy = var.force_destroy
target_merge_apis = [
module.document_ingestion.ingestion_api_arn,
"${module.document_ingestion.ingestion_api_arn}/*",
module.summarization.summarization_api_arn,
"${module.summarization.summarization_api_arn}/*",
module.question_answering.question_answering_arn,
"${module.question_answering.question_answering_arn}/*",
]
tags = local.root_combined_tags
}
############################################################################################################
# Document Ingestion
############################################################################################################
module "document_ingestion" {
source = "./modules/document-ingestion"
solution_prefix = local.solution_prefix
cognito_user_pool_id = module.persistence_resources.cognito_user_pool_id
ecr_repository_id = module.persistence_resources.ecr_repository_id
lambda_ingestion_input_validation_prop = {
image_tag = "ingestion_input_validation"
src_path = "${path.module}/lambda/document-ingestion/input_validation/src"
subnet_ids = [for _, value in module.networking_resources.private_subnet_attributes_by_az : value.id]
security_group_ids = [module.networking_resources.lambda_sg]
}
lambda_file_transformer_prop = {
image_tag = "file_transformer"
src_path = "${path.module}/lambda/document-ingestion/s3_file_transformer/src"
subnet_ids = [for _, value in module.networking_resources.private_subnet_attributes_by_az : value.id]
security_group_ids = [module.networking_resources.lambda_sg]
}
lambda_embeddings_job_prop = {
image_tag = "embeddings_job"
src_path = "${path.module}/lambda/document-ingestion/embeddings_job/src"
subnet_ids = [for _, value in module.networking_resources.private_subnet_attributes_by_az : value.id]
security_group_ids = [module.networking_resources.lambda_sg]
}
input_assets_bucket_prop = {
bucket_arn = module.persistence_resources.input_assets_bucket_arn
bucket_name = module.persistence_resources.input_assets_bucket_name
}
processed_assets_bucket_prop = {
bucket_arn = module.persistence_resources.processed_assets_bucket_arn
bucket_name = module.persistence_resources.processed_assets_bucket_name
}
opensearch_prop = local.final_opensearch_prop
merged_api_arn = module.persistence_resources.merged_api_arn
merged_api_url = module.persistence_resources.merged_api_url
container_platform = var.container_platform
tags = local.root_combined_tags
}
resource "awscc_appsync_source_api_association" "document_ingestion_association" {
description = "Association for document ingestion"
merged_api_identifier = module.persistence_resources.merged_api_arn
source_api_identifier = module.document_ingestion.ingestion_api_arn
source_api_association_config = {
merge_type = "AUTO_MERGE"
}
depends_on = [module.persistence_resources, module.document_ingestion]
}
############################################################################################################
# Summarization
############################################################################################################
module "summarization" {
source = "./modules/summarization"
solution_prefix = local.solution_prefix
cognito_user_pool_id = module.persistence_resources.cognito_user_pool_id
ecr_repository_id = module.persistence_resources.ecr_repository_id
lambda_summarization_input_validation_prop = {
image_tag = "summarization_input_validation"
src_path = "${path.module}/lambda/summarization/input_validator"
subnet_ids = [for _, value in module.networking_resources.private_subnet_attributes_by_az : value.id]
security_group_ids = [module.networking_resources.lambda_sg]
}
lambda_summarization_doc_reader_prop = {
image_tag = "summarization_doc_reader"
src_path = "${path.module}/lambda/summarization/document_reader"
subnet_ids = [for _, value in module.networking_resources.private_subnet_attributes_by_az : value.id]
security_group_ids = [module.networking_resources.lambda_sg]
}
lambda_summarization_generator_prop = {
image_tag = "summarization_generator"
src_path = "${path.module}/lambda/summarization/summary_generator"
subnet_ids = [for _, value in module.networking_resources.private_subnet_attributes_by_az : value.id]
security_group_ids = [module.networking_resources.lambda_sg]
}
input_assets_bucket_prop = {
bucket_arn = module.persistence_resources.input_assets_bucket_arn
bucket_name = module.persistence_resources.input_assets_bucket_name
}
processed_assets_bucket_prop = {
bucket_arn = module.persistence_resources.processed_assets_bucket_arn
bucket_name = module.persistence_resources.processed_assets_bucket_name
}
merged_api_arn = module.persistence_resources.merged_api_arn
merged_api_url = module.persistence_resources.merged_api_url
is_file_transformation_required = true
container_platform = var.container_platform
tags = local.root_combined_tags
}
resource "awscc_appsync_source_api_association" "summarization_association" {
description = "Association for summarization"
merged_api_identifier = module.persistence_resources.merged_api_arn
source_api_identifier = module.summarization.summarization_api_arn
source_api_association_config = {
merge_type = "AUTO_MERGE"
}
depends_on = [module.persistence_resources, module.summarization]
}
############################################################################################################
# Question Answering
############################################################################################################
module "question_answering" {
source = "./modules/question-answering"
solution_prefix = local.solution_prefix
cognito_user_pool_id = module.persistence_resources.cognito_user_pool_id
ecr_repository_id = module.persistence_resources.ecr_repository_id
lambda_question_answering_prop = {
image_tag = "question_answering"
src_path = "${path.module}/lambda/aws-qa-appsync-opensearch/question_answering/src"
subnet_ids = [for _, value in module.networking_resources.private_subnet_attributes_by_az : value.id]
security_group_ids = [module.networking_resources.lambda_sg]
}
merged_api_arn = module.persistence_resources.merged_api_arn
merged_api_url = module.persistence_resources.merged_api_url
processed_assets_bucket_prop = {
bucket_arn = module.persistence_resources.processed_assets_bucket_arn
bucket_name = module.persistence_resources.processed_assets_bucket_name
}
opensearch_prop = local.final_opensearch_prop
container_platform = var.container_platform
tags = local.root_combined_tags
}
resource "awscc_appsync_source_api_association" "question_answering_association" {
description = "Association for question answering"
merged_api_identifier = module.persistence_resources.merged_api_arn
source_api_identifier = module.question_answering.question_answering_arn
source_api_association_config = {
merge_type = "AUTO_MERGE"
}
depends_on = [module.persistence_resources, module.question_answering]
}