-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5d889ef
commit 8701942
Showing
10 changed files
with
455 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Module: Azure CosmosDB (Optional) | ||
|
||
Create a new CosmosDB. (Optional) | ||
If existing an existing CosmosDB instance is to be used, then the variables/names of the existing DB must be provided as input variables to root the module (data sources): | ||
|
||
- Create an Azure CosmosDB instance running MongoDB API. | ||
|
||
<!-- BEGIN_TF_DOCS --> | ||
|
||
<!-- END_TF_DOCS --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
resource "azurerm_cosmosdb_account" "mongo" { | ||
name = var.cosmosdb_name | ||
resource_group_name = var.cosmosdb_resource_group_name | ||
location = var.location | ||
offer_type = var.cosmosdb_offer_type | ||
kind = var.cosmosdb_kind | ||
enable_automatic_failover = var.cosmosdb_automatic_failover | ||
enable_free_tier = var.use_cosmosdb_free_tier | ||
tags = var.tags | ||
|
||
consistency_policy { | ||
consistency_level = var.cosmosdb_consistency_level | ||
max_interval_in_seconds = var.cosmosdb_max_interval_in_seconds | ||
max_staleness_prefix = var.cosmosdb_max_staleness_prefix | ||
} | ||
|
||
dynamic "geo_location" { | ||
for_each = var.geo_locations | ||
content { | ||
location = geo_location.value.location | ||
failover_priority = geo_location.value.failover_priority | ||
} | ||
} | ||
|
||
dynamic "capabilities" { | ||
for_each = var.capabilities | ||
content { | ||
name = capabilities.value | ||
} | ||
} | ||
|
||
dynamic "virtual_network_rule" { | ||
for_each = var.virtual_network_subnets | ||
content { | ||
id = virtual_network_rule.value | ||
} | ||
} | ||
|
||
is_virtual_network_filter_enabled = var.is_virtual_network_filter_enabled | ||
public_network_access_enabled = var.public_network_access_enabled | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
output "cosmosdb_account_id" { | ||
description = "The ID of the Cosmos DB account" | ||
value = azurerm_cosmosdb_account.mongo.id | ||
} | ||
|
||
output "cosmosdb_account_endpoint" { | ||
description = "The endpoint of the Cosmos DB account" | ||
value = azurerm_cosmosdb_account.mongo.endpoint | ||
} | ||
|
||
output "cosmosdb_account_primary_master_key" { | ||
description = "The primary master key of the Cosmos DB account" | ||
value = azurerm_cosmosdb_account.mongo.primary_key | ||
sensitive = true | ||
} | ||
|
||
output "cosmosdb_account_read_endpoints" { | ||
description = "The read endpoints of the Cosmos DB account" | ||
value = azurerm_cosmosdb_account.mongo.read_endpoints | ||
} | ||
|
||
output "cosmosdb_account_write_endpoints" { | ||
description = "The write endpoints of the Cosmos DB account" | ||
value = azurerm_cosmosdb_account.mongo.write_endpoints | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
variable "cosmosdb_name" { | ||
description = "The name of the Cosmos DB account" | ||
type = string | ||
default = "openaicosmosdb" | ||
} | ||
|
||
variable "cosmosdb_resource_group_name" { | ||
description = "The name of the resource group in which to create the Cosmos DB account" | ||
type = string | ||
nullable = false | ||
} | ||
|
||
variable "location" { | ||
description = "The location/region in which to create the Cosmos DB account" | ||
type = string | ||
default = "uksouth" | ||
} | ||
|
||
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 "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 "capabilities" { | ||
description = "The capabilities for the Cosmos DB account" | ||
type = list(string) | ||
default = [ | ||
"MongoDB" | ||
] | ||
} | ||
|
||
variable "virtual_network_subnets" { | ||
description = "The virtual network subnet ID for the Cosmos DB account" | ||
type = list(string) | ||
default = [] | ||
} | ||
|
||
variable "is_virtual_network_filter_enabled" { | ||
description = "Whether to enable virtual network filtering for the Cosmos DB account" | ||
type = bool | ||
default = true | ||
} | ||
|
||
variable "public_network_access_enabled" { | ||
description = "Whether to enable public network access for the Cosmos DB account" | ||
type = bool | ||
default = true | ||
} | ||
|
||
variable "tags" { | ||
type = map(string) | ||
default = { | ||
Terraform = "True" | ||
Description = "OpenAI CosmosDB Resource." | ||
Author = "Marcel Lupo" | ||
GitHub = "https://github.com/Pwd9000-ML/terraform-azurerm-openai-private-chatgpt" | ||
} | ||
description = "A map of key value pairs that is used to tag resources created." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.