-
Notifications
You must be signed in to change notification settings - Fork 10
/
variables.tf
723 lines (632 loc) · 22.8 KB
/
variables.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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
# ##################################################
# # VARIABLES #
# ##################################################
### 01 common + Resource Group ###
variable "location" {
type = string
default = "uksouth"
description = "Azure region where resources will be hosted."
}
variable "tags" {
type = map(string)
default = {}
description = "A map of key value pairs that is used to tag resources created."
}
variable "resource_group_name" {
type = string
description = "Name of the resource group to create the OpenAI service / or where an existing service is hosted."
nullable = false
}
### 02 Networking ###
variable "virtual_network_name" {
type = string
default = "openai-vnet-9000"
description = "Name of the virtual network where resources are attached."
}
variable "vnet_address_space" {
type = list(string)
default = ["10.4.0.0/24"]
description = "value of the address space for the virtual network."
}
variable "subnet_config" {
type = object({
subnet_name = string
subnet_address_space = list(string)
service_endpoints = list(string)
private_endpoint_network_policies_enabled = bool
private_link_service_network_policies_enabled = bool
subnets_delegation_settings = map(list(object({
name = string
actions = list(string)
})))
})
default = {
subnet_name = "app-cosmos-sub"
subnet_address_space = ["10.4.0.0/24"]
service_endpoints = ["Microsoft.AzureCosmosDB", "Microsoft.Web"]
private_endpoint_network_policies_enabled = false
private_link_service_network_policies_enabled = false
subnets_delegation_settings = {
app-service-plan = [
{
name = "Microsoft.Web/serverFarms"
actions = ["Microsoft.Network/virtualNetworks/subnets/action"]
}
]
}
}
description = "A list of subnet configuration objects to create subnets in the virtual network."
}
### 03 key vault ###
variable "kv_name" {
type = string
description = "Name of the Key Vault to create (solution secrets)."
default = "openaikv9000"
}
variable "kv_sku" {
type = string
description = "SKU of the Key Vault to create."
default = "standard"
}
variable "kv_fw_default_action" {
type = string
default = "Deny"
description = "Default action for key vault firewall rules."
}
variable "kv_fw_bypass" {
type = string
default = "AzureServices"
description = "List of key vault firewall rules to bypass."
}
variable "kv_fw_allowed_ips" {
type = list(string)
default = []
description = "value of key vault firewall allowed ip rules."
}
variable "kv_fw_network_subnet_ids" {
description = "The virtual network subnets to associate with the Cosmos DB account (Service Endpoint). If networking is created as part of the module, this will be automatically populated."
type = list(string)
default = null
}
### 04 OpenAI service ###
variable "oai_account_name" {
type = string
default = "az-openai-account"
description = "The name of the OpenAI service."
}
variable "oai_sku_name" {
type = string
description = "SKU name of the OpenAI service."
default = "S0"
}
variable "oai_custom_subdomain_name" {
type = string
description = "The subdomain name used for token-based authentication. Changing this forces a new resource to be created. (normally the same as the account name)"
default = "demo-account"
}
variable "oai_dynamic_throttling_enabled" {
type = bool
default = true
description = "Whether or not dynamic throttling is enabled. Defaults to `true`."
}
variable "oai_fqdns" {
type = list(string)
default = []
description = "A list of FQDNs to be used for token-based authentication. Changing this forces a new resource to be created."
}
variable "oai_local_auth_enabled" {
type = bool
default = true
description = "Whether local authentication methods is enabled for the Cognitive Account. Defaults to `true`."
}
variable "oai_outbound_network_access_restricted" {
type = bool
default = false
description = "Whether or not outbound network access is restricted. Defaults to `false`."
}
variable "oai_public_network_access_enabled" {
type = bool
default = true
description = "Whether or not public network access is enabled. Defaults to `false`."
}
variable "oai_customer_managed_key" {
type = object({
key_vault_key_id = string
identity_client_id = optional(string)
})
default = null
description = <<-DESCRIPTION
type = object({
key_vault_key_id = (Required) The ID of the Key Vault Key which should be used to Encrypt the data in this OpenAI Account.
identity_client_id = (Optional) The Client ID of the User Assigned Identity that has access to the key. This property only needs to be specified when there're multiple identities attached to the OpenAI Account.
})
DESCRIPTION
}
variable "oai_identity" {
type = object({
type = string
identity_ids = optional(list(string))
})
default = {
type = "SystemAssigned"
}
description = <<-DESCRIPTION
type = object({
type = (Required) The type of the Identity. Possible values are `SystemAssigned`, `UserAssigned`, `SystemAssigned, UserAssigned`.
identity_ids = (Optional) Specifies a list of User Assigned Managed Identity IDs to be assigned to this OpenAI Account.
})
DESCRIPTION
}
variable "oai_network_acls" {
type = set(object({
default_action = string
ip_rules = optional(set(string))
virtual_network_rules = optional(set(object({
subnet_id = string
ignore_missing_vnet_service_endpoint = optional(bool, false)
})))
}))
default = null
description = <<-DESCRIPTION
type = set(object({
default_action = (Required) The Default Action to use when no rules match from ip_rules / virtual_network_rules. Possible values are `Allow` and `Deny`.
ip_rules = (Optional) One or more IP Addresses, or CIDR Blocks which should be able to access the Cognitive Account.
virtual_network_rules = optional(set(object({
subnet_id = (Required) The ID of a Subnet which should be able to access the OpenAI Account.
ignore_missing_vnet_service_endpoint = (Optional) Whether ignore missing vnet service endpoint or not. Default to `false`.
})))
}))
DESCRIPTION
}
variable "oai_storage" {
type = list(object({
storage_account_id = string
identity_client_id = optional(string)
}))
default = []
description = <<-DESCRIPTION
type = list(object({
storage_account_id = (Required) Full resource id of a Microsoft.Storage resource.
identity_client_id = (Optional) The client ID of the managed identity associated with the storage resource.
}))
DESCRIPTION
nullable = false
}
variable "oai_model_deployment" {
type = list(object({
deployment_id = string
model_name = string
model_format = string
model_version = string
scale_type = string
scale_tier = optional(string)
scale_size = optional(number)
scale_family = optional(string)
scale_capacity = optional(number)
rai_policy_name = optional(string)
}))
default = []
description = <<-DESCRIPTION
type = list(object({
deployment_id = (Required) The name of the Cognitive Services Account `Model Deployment`. Changing this forces a new resource to be created.
model_name = {
model_format = (Required) The format of the Cognitive Services Account Deployment model. Changing this forces a new resource to be created. Possible value is OpenAI.
model_name = (Required) The name of the Cognitive Services Account Deployment model. Changing this forces a new resource to be created.
model_version = (Required) The version of Cognitive Services Account Deployment model.
}
scale = {
scale_type = (Required) Deployment scale type. Possible value is Standard. Changing this forces a new resource to be created.
scale_tier = (Optional) Possible values are Free, Basic, Standard, Premium, Enterprise. Changing this forces a new resource to be created.
scale_size = (Optional) The SKU size. When the name field is the combination of tier and some other value, this would be the standalone code. Changing this forces a new resource to be created.
scale_family = (Optional) If the service has different generations of hardware, for the same SKU, then that can be captured here. Changing this forces a new resource to be created.
scale_capacity = (Optional) Tokens-per-Minute (TPM). If the SKU supports scale out/in then the capacity integer should be included. If scale out/in is not possible for the resource this may be omitted. Default value is 1. Changing this forces a new resource to be created.
}
rai_policy_name = (Optional) The name of RAI policy. Changing this forces a new resource to be created.
}))
DESCRIPTION
nullable = false
}
### 05 OpenAI CosmosDB ###
variable "cosmosdb_name" {
description = "The name of the Cosmos DB account"
type = string
default = "openaicosmosdb"
}
variable "cosmosdb_offer_type" {
description = "The offer type to use for the Cosmos DB account"
type = string
default = "Standard"
}
variable "cosmosdb_kind" {
description = "The kind of Cosmos DB to create"
type = string
default = "MongoDB"
}
variable "cosmosdb_automatic_failover" {
description = "Whether to enable automatic failover for the Cosmos DB account"
type = bool
default = false
}
variable "use_cosmosdb_free_tier" {
description = "Whether to enable the free tier for the Cosmos DB account. This needs to be false if another instance already uses free tier."
type = bool
default = true
}
variable "cosmosdb_consistency_level" {
description = "The consistency level of the Cosmos DB account"
type = string
default = "BoundedStaleness"
}
variable "cosmosdb_max_interval_in_seconds" {
description = "The maximum staleness interval in seconds for the Cosmos DB account"
type = number
default = 10
}
variable "cosmosdb_max_staleness_prefix" {
description = "The maximum staleness prefix for the Cosmos DB account"
type = number
default = 200
}
variable "cosmosdb_geo_locations" {
description = "The geo-locations for the Cosmos DB account"
type = list(object({
location = string
failover_priority = number
}))
default = [
{
location = "uksouth"
failover_priority = 0
}
]
}
variable "cosmosdb_capabilities" {
description = "The capabilities for the Cosmos DB account"
type = list(string)
default = ["EnableMongo", "MongoDBv3.4"]
}
variable "cosmosdb_virtual_network_subnets" {
description = "The virtual network subnets to associate with the Cosmos DB account (Service Endpoint). If networking is created as part of the module, this will be automatically populated."
type = list(string)
default = null
}
variable "cosmosdb_is_virtual_network_filter_enabled" {
description = "Whether to enable virtual network filtering for the Cosmos DB account"
type = bool
default = true
}
variable "cosmosdb_public_network_access_enabled" {
description = "Whether to enable public network access for the Cosmos DB account"
type = bool
default = true
}
### 06 LibreChat App Services ###
# App Service Plan
variable "app_service_name" {
type = string
description = "Name of the Linux App Service Plan."
default = "openaiasp9000"
}
variable "app_service_sku_name" {
type = string
description = "The SKU name of the App Service Plan."
default = "B1"
}
#TODO
# Meilisearch App Service
# variable "meilisearch_app_name" {
# type = string
# description = "Name of the meilisearch App Service."
# default = "meilisearchapp9000"
# }
# variable "meilisearch_app_virtual_network_subnet_id" {
# type = string
# description = "The ID of the subnet to deploy the meilisearch App Service in."
# default = null
# }
# variable "meilisearch_app_key" {
# type = string
# description = "The Meilisearch API Key to use for authentication."
# default = null
# sensitive = true
# }
# LibreChat App Service
variable "libre_app_name" {
type = string
description = "Name of the LibreChat App Service."
default = "librechatapp9000"
}
variable "libre_app_public_network_access_enabled" {
type = bool
description = "Whether or not public network access is enabled. Defaults to `false`."
default = true
}
variable "libre_app_virtual_network_subnet_id" {
type = string
description = "The ID of the subnet, used to allow access to the App Service (priority 100), e.g. cosmosdb, meilisearch etc. If networking is created as part of the module, this will be automatically populated if value is 'null'."
default = null
}
variable "libre_app_allowed_subnets" {
description = "Allowed Subnets (By default the subnet the app service is deployed in is allowed access already as priority 100). Add any additionals here"
type = list(object({
virtual_network_subnet_id = string
priority = number
name = string
action = string
}))
default = [
{
virtual_network_subnet_id = "subnet_id1"
priority = 200
name = "subnet-access-rule1" # "Allow from LibreChat app subnet and hosted services e.g. cosmosdb, meilisearch etc."
action = "Allow"
}
]
}
variable "libre_app_allowed_ip_addresses" {
description = "Allowed IP Addresses. The CIDR notation of the IP or IP Range to match to allow. For example: 10.0.0.0/24 or 192.168.10.1/32"
type = list(object({
ip_address = string
priority = number
name = string
action = string
}))
default = [
{
ip_address = "0.0.0.0/0" # Allow all IP Addresses (change to your IP range)
priority = 300
name = "ip-access-rule1"
action = "Allow"
}
]
}
# LibreChat App Service App Settings
# Server Config
variable "libre_app_title" {
type = string
description = "Add a custom title for the App."
default = "PrivateGPT"
}
variable "libre_app_custom_footer" {
type = string
description = "Add a custom footer for the App."
default = "Privately hosted chat app powered by Azure OpenAI and LibreChat."
}
variable "libre_app_host" {
type = string
description = "he server will listen to localhost:3080 by default. You can change the target IP as you want. If you want to make this server available externally, for example to share the server with others or expose this from a Docker container, set host to 0.0.0.0 or your external IP interface."
default = "0.0.0.0"
}
variable "libre_app_port" {
type = number
description = "The host port to listen on."
default = 3080
}
variable "libre_app_docker_image" {
type = string
description = "The Docker Image to use for the App Service."
default = "ghcr.io/danny-avila/librechat-dev-api:latest"
}
variable "libre_app_mongo_uri" {
type = string
description = "The MongoDB Connection String to connect to."
default = null
sensitive = true
}
variable "libre_app_domain_client" {
type = string
description = "To use locally, set DOMAIN_CLIENT and DOMAIN_SERVER to http://localhost:3080 (3080 being the port previously configured).When deploying to a custom domain, set DOMAIN_CLIENT and DOMAIN_SERVER to your deployed URL, e.g. https://mydomain.example.com"
default = "http://localhost:3080"
}
variable "libre_app_domain_server" {
type = string
description = "To use locally, set DOMAIN_CLIENT and DOMAIN_SERVER to http://localhost:3080 (3080 being the port previously configured).When deploying to a custom domain, set DOMAIN_CLIENT and DOMAIN_SERVER to your deployed URL, e.g. https://mydomain.example.com"
default = "http://localhost:3080"
}
# Debug logging
variable "libre_app_debug_logging" {
type = bool
description = "LibreChat has central logging built into its backend (api). Log files are saved in /api/logs. Error logs are saved by default. Debug logs are enabled by default but can be turned off if not desired."
default = false
}
variable "libre_app_debug_console" {
type = bool
description = "Enable verbose server output in the console, though it's not recommended due to high verbosity."
default = false
}
# Endpoints
variable "libre_app_endpoints" {
type = string
description = "endpoints and models selection. E.g. 'openAI,azureOpenAI,bingAI,chatGPTBrowser,google,gptPlugins,anthropic'"
default = "azureOpenAI"
}
# Azure OpenAI
variable "libre_app_az_oai_api_key" {
type = string
description = "Azure OpenAI API Key"
default = null
sensitive = true
}
variable "libre_app_az_oai_models" {
type = string
description = "Azure OpenAI Models. E.g. 'gpt-4-1106-preview,gpt-4,gpt-3.5-turbo,gpt-3.5-turbo-1106,gpt-4-vision-preview'"
default = "gpt-4-1106-preview"
}
variable "libre_app_az_oai_use_model_as_deployment_name" {
type = bool
description = "Azure OpenAI Use Model as Deployment Name"
default = true
}
variable "libre_app_az_oai_instance_name" {
type = string
description = "Azure OpenAI Instance Name"
default = null
}
variable "libre_app_az_oai_api_version" {
type = string
description = "Azure OpenAI API Version"
default = "2023-07-01-preview"
}
variable "libre_app_az_oai_dall3_api_version" {
type = string
description = "Azure OpenAI DALL-E API Version"
default = "2023-12-01-preview"
}
variable "libre_app_az_oai_dall3_deployment_name" {
type = string
description = "Azure OpenAI DALL-E Deployment Name"
default = "dall-e-3"
}
# Plugins
variable "libre_app_debug_plugins" {
type = bool
description = "Enable debug mode for Libre App plugins."
default = false
}
variable "libre_app_plugins_creds_key" {
type = string
description = "Libre App Plugins Creds Key"
default = null
sensitive = true
}
variable "libre_app_plugins_creds_iv" {
type = string
description = "Libre App Plugins Creds IV"
default = null
sensitive = true
}
# variable "libre_app_plugin_models" {
# type = string
# description = "Libre App Plugin Models e.g. 'gpt-4,dall-e-3'"
# default = "gpt-4,dall-e-3"
# }
# variable "libre_app_plugins_use_azure" {
# type = bool
# description = "Libre App Plugins Use Azure, required for Azure OpenAI Plugins e.g. 'dall-e-3'"
# default = true
# }
#TODO
# Search
variable "libre_app_enable_meilisearch" {
type = bool
description = "Enable Meilisearch"
default = false
}
# variable "libre_app_disable_meilisearch_analytics" {
# type = bool
# description = "Disable Meilisearch Analytics"
# default = true
# }
# variable "libre_app_meili_host" {
# type = string
# description = "For the API server to connect to the search server. E.g. https://meilisearch.example.com"
# default = null
# }
# variable "libre_app_meili_key" {
# type = string
# description = "Meilisearch API Key"
# default = null
# sensitive = true
# }
# User Registration
variable "libre_app_allow_email_login" {
type = bool
description = "Allow Email Login"
default = true
}
variable "libre_app_allow_registration" {
type = bool
description = "Allow Registration"
default = true
}
variable "libre_app_allow_social_login" {
type = bool
description = "Allow Social Login"
default = false
}
variable "libre_app_allow_social_registration" {
type = bool
description = "Allow Social Registration"
default = false
}
variable "libre_app_jwt_secret" {
type = string
description = "JWT Secret"
default = null
sensitive = true
}
variable "libre_app_jwt_refresh_secret" {
type = string
description = "JWT Refresh Secret"
default = null
sensitive = true
}
# Violations
variable "libre_app_violations" {
description = "Configuration for violations"
type = object({
enabled = bool
ban_duration = number
ban_interval = number
login_violation_score = number
registration_violation_score = number
concurrent_violation_score = number
message_violation_score = number
non_browser_violation_score = number
login_max = number
login_window = number
register_max = number
register_window = number
limit_concurrent_messages = bool
concurrent_message_max = number
limit_message_ip = bool
message_ip_max = number
message_ip_window = number
limit_message_user = bool
message_user_max = number
message_user_window = number
})
default = {
enabled = true
ban_duration = 1000 * 60 * 60 * 2
ban_interval = 20
login_violation_score = 1
registration_violation_score = 1
concurrent_violation_score = 1
message_violation_score = 1
non_browser_violation_score = 20
login_max = 7
login_window = 5
register_max = 5
register_window = 60
limit_concurrent_messages = true
concurrent_message_max = 2
limit_message_ip = true
message_ip_max = 40
message_ip_window = 1
limit_message_user = false
message_user_max = 40
message_user_window = 1
}
}
# Custom Domain and Managed Certificate (Optional)
variable "libre_app_custom_domain_create" {
type = bool
description = "Create a custom domain and managed certificate for the App Service."
default = false
}
variable "librechat_app_custom_domain_name" {
type = string
description = "The custom domain to use for the App Service."
default = "privategpt"
}
variable "librechat_app_custom_dns_zone_name" {
type = string
description = "The DNS Zone to use for the App Service."
default = "domain.com"
}
variable "dns_resource_group_name" {
type = string
description = "The Resource Group that contains the custom DNS Zone to use for the App Service"
default = "dns-rg"
}