generated from CDCgov/template
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path_local.tf
230 lines (227 loc) · 8.47 KB
/
_local.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
222
223
224
225
226
227
228
229
230
resource "random_string" "s3_viewer" {
length = 8
special = false
upper = false
}
locals {
registry_url = var.disable_ecr == false ? "${data.aws_caller_identity.current.account_id}.dkr.ecr.${var.region}.amazonaws.com" : "ghcr.io/cdcgov/phdi"
registry_username = data.aws_ecr_authorization_token.this.user_name
registry_password = data.aws_ecr_authorization_token.this.password
phdi_repo = "ghcr.io/cdcgov/phdi"
database_data = var.postgres_database_data.non_integrated_viewer == "true" ? var.postgres_database_data : var.sqlserver_database_data
service_data = length(var.service_data) > 0 ? var.service_data : {
ecr-viewer = {
short_name = "ecrv",
fargate_cpu = 512,
fargate_memory = 1024,
min_capacity = 1,
max_capacity = 5,
app_repo = local.phdi_repo,
app_image = var.disable_ecr == false ? "${terraform.workspace}-ecr-viewer" : "ecr-viewer",
app_version = var.phdi_version,
container_port = 3000,
host_port = 3000,
public = true,
registry_url = local.registry_url,
env_vars = [
{
name = "AWS_REGION",
value = var.region
},
{
name = "ECR_BUCKET_NAME",
value = local.s3_viewer_bucket_name
},
{
name = "HOSTNAME",
value = "0.0.0.0"
},
{
name = "NEXT_PUBLIC_NON_INTEGRATED_VIEWER",
value = local.database_data.non_integrated_viewer
},
{
name = "SOURCE",
value = "s3"
},
{
name = "APP_ENV",
value = var.ecr_viewer_app_env
},
{
name = "NBS_PUB_KEY",
value = var.ecr_viewer_auth_pub_key
},
{
name = "METADATA_DATABASE_TYPE",
value = local.database_data.non_integrated_viewer == "true" ? local.database_data.metadata_database_type : ""
},
{
name = "METADATA_DATABASE_SCHEMA",
value = local.database_data.non_integrated_viewer == "true" ? local.database_data.metadata_database_schema : ""
},
{
name = "DATABASE_URL",
value = local.database_data.metadata_database_type == "postgres" ? data.aws_secretsmanager_secret_version.postgres_database_url[0].secret_string : ""
},
{
name = "SQL_SERVER_USER",
value = local.database_data.metadata_database_type == "sqlserver" ? data.aws_secretsmanager_secret_version.sqlserver_user[0].secret_string : ""
},
{
name = "SQL_SERVER_PASSWORD",
value = local.database_data.metadata_database_type == "sqlserver" ? data.aws_secretsmanager_secret_version.sqlserver_password[0].secret_string : ""
},
{
name = "SQL_SERVER_HOST",
value = local.database_data.metadata_database_type == "sqlserver" ? data.aws_secretsmanager_secret_version.sqlserver_host[0].secret_string : ""
}
]
},
fhir-converter = {
short_name = "fhirc",
fargate_cpu = 1024,
fargate_memory = 2048,
min_capacity = 1,
max_capacity = 5,
app_repo = local.phdi_repo,
app_image = var.disable_ecr == false ? "${terraform.workspace}-fhir-converter" : "fhir-converter",
app_version = var.phdi_version,
container_port = 8080,
host_port = 8080,
public = false,
registry_url = local.registry_url,
env_vars = []
},
ingestion = {
short_name = "inge",
fargate_cpu = 512,
fargate_memory = 1024,
min_capacity = 1,
max_capacity = 5,
app_repo = local.phdi_repo,
app_image = var.disable_ecr == false ? "${terraform.workspace}-ingestion" : "ingestion",
app_version = var.phdi_version,
container_port = 8080,
host_port = 8080,
public = false,
registry_url = local.registry_url,
env_vars = []
},
validation = {
short_name = "vali",
fargate_cpu = 512,
fargate_memory = 1024,
min_capacity = 1,
max_capacity = 5,
app_repo = local.phdi_repo,
app_image = var.disable_ecr == false ? "${terraform.workspace}-validation" : "validation",
app_version = var.phdi_version,
container_port = 8080,
host_port = 8080,
public = false,
registry_url = local.registry_url,
env_vars = []
},
trigger-code-reference = {
short_name = "trigcr",
fargate_cpu = 512,
fargate_memory = 1024,
min_capacity = 1,
max_capacity = 5,
app_repo = local.phdi_repo,
app_image = var.disable_ecr == false ? "${terraform.workspace}-trigger-code-reference" : "trigger-code-reference",
app_version = var.phdi_version,
container_port = 8080,
host_port = 8080,
public = false,
registry_url = local.registry_url,
env_vars = []
},
message-parser = {
short_name = "msgp",
fargate_cpu = 512,
fargate_memory = 1024,
min_capacity = 1,
max_capacity = 5,
app_repo = local.phdi_repo,
app_image = var.disable_ecr == false ? "${terraform.workspace}-message-parser" : "message-parser",
app_version = var.phdi_version,
container_port = 8080,
host_port = 8080,
public = false
registry_url = local.registry_url
env_vars = []
},
orchestration = {
short_name = "orch",
fargate_cpu = 512,
fargate_memory = 1024,
min_capacity = 1,
max_capacity = 5,
app_repo = local.phdi_repo,
app_image = var.disable_ecr == false ? "${terraform.workspace}-orchestration" : "orchestration",
app_version = var.phdi_version,
container_port = 8080,
host_port = 8080,
public = true,
registry_url = local.registry_url,
env_vars = [
{
name = "OTEL_METRICS",
value = "none"
},
{
name = "OTEL_METRICS_EXPORTER",
value = "none"
},
{
name = "INGESTION_URL",
value = "http://ingestion:8080"
},
{
name = "VALIDATION_URL",
value = "http://validation:8080"
},
{
name = "FHIR_CONVERTER_URL",
value = "http://fhir-converter:8080"
},
{
name = "ECR_VIEWER_URL",
value = "http://ecr-viewer:3000/ecr-viewer"
},
{
name = "MESSAGE_PARSER_URL",
value = "http://message-parser:8080"
},
{
name = "TRIGGER_CODE_REFERENCE_URL",
value = "http://trigger-code-reference:8080"
}
]
}
}
local_name = "${var.project}-${var.owner}-${terraform.workspace}"
appmesh_name = var.appmesh_name == "" ? local.local_name : var.appmesh_name
cloudmap_namespace_name = var.cloudmap_namespace_name == "" ? local.local_name : var.cloudmap_namespace_name
ecs_alb_name = var.ecs_alb_name == "" ? local.local_name : var.ecs_alb_name
ecs_alb_tg_name = var.ecs_alb_tg_name == "" ? local.local_name : var.ecs_alb_tg_name
ecs_task_execution_role_name = var.ecs_task_execution_role_name == "" ? "${local.local_name}-tern" : var.ecs_task_execution_role_name
ecs_task_role_name = var.ecs_task_role_name == "" ? "${local.local_name}-trn" : var.ecs_task_role_name
ecs_cloudwatch_group = var.ecs_cloudwatch_group == "" ? "/${local.local_name}" : var.ecs_cloudwatch_group
ecs_cluster_name = var.ecs_cluster_name == "" ? local.local_name : var.ecs_cluster_name
s3_viewer_bucket_name = var.s3_viewer_bucket_name == "" ? "${local.local_name}-${random_string.s3_viewer.result}" : var.s3_viewer_bucket_name
s3_viewer_bucket_role_name = var.s3_viewer_bucket_role_name == "" ? "${local.local_name}-ecrv" : var.s3_viewer_bucket_role_name
tags = var.tags
vpc_endpoints = [
"com.amazonaws.${var.region}.ecr.dkr",
"com.amazonaws.${var.region}.ecr.api",
"com.amazonaws.${var.region}.ecs",
"com.amazonaws.${var.region}.ecs-telemetry",
"com.amazonaws.${var.region}.logs",
"com.amazonaws.${var.region}.secretsmanager",
]
s3_service_name = "com.amazonaws.${var.region}.s3"
private_subnet_kvs = { for index, rt in var.private_subnet_ids : index => rt }
}