Skip to content

Commit

Permalink
Added new MongoDB collections.
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniotarricone committed Jul 10, 2024
1 parent a0b2400 commit 4d40d29
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 2 deletions.
98 changes: 98 additions & 0 deletions src/core/09_mil_auth.tf
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,21 @@ variable "mil_auth_keyvault_backoff_num_of_attempts" {
default = 3
}

variable "mil_auth_mongodb_connect_timeout" {
type = string
default = "5s"
}

variable "mil_auth_mongodb_read_timeout" {
type = string
default = "10s"
}

variable "mil_auth_mongodb_server_selection_timeout" {
type = string
default = "5s"
}

# ------------------------------------------------------------------------------
# Storage account containing configuration files.
# ------------------------------------------------------------------------------
Expand Down Expand Up @@ -156,6 +171,54 @@ resource "azurerm_private_endpoint" "auth_storage" {
}
}

# ------------------------------------------------------------------------------
# CosmosDB Mongo collection.
# ------------------------------------------------------------------------------
resource "azurerm_cosmosdb_mongo_collection" "clients" {
account_name = azurerm_cosmosdb_mongo_database.mil.account_name
database_name = azurerm_cosmosdb_mongo_database.mil.name
name = "clients"
resource_group_name = azurerm_cosmosdb_mongo_database.mil.resource_group_name

index {
keys = ["_id"]
unique = true
}

index {
keys = [
"clientId"
]
unique = true
}
}

# ------------------------------------------------------------------------------
# CosmosDB Mongo collection.
# ------------------------------------------------------------------------------
resource "azurerm_cosmosdb_mongo_collection" "roles" {
account_name = azurerm_cosmosdb_mongo_database.mil.account_name
database_name = azurerm_cosmosdb_mongo_database.mil.name
name = "roles"
resource_group_name = azurerm_cosmosdb_mongo_database.mil.resource_group_name

index {
keys = ["_id"]
unique = true
}

index {
keys = [
"acquirerId",
"channel",
"clientId",
"merchantId",
"terminalId"
]
unique = true
}
}

# ------------------------------------------------------------------------------
# Key vault for cryptographics operations.
# ------------------------------------------------------------------------------
Expand Down Expand Up @@ -291,12 +354,47 @@ resource "azurerm_container_app" "auth" {
name = "jwt-publickey-location"
value = "http://127.0.0.1:8080/.well-known/jwks.json"
}

env {
name = "mongodb.connect-timeout"
value = var.mil_auth_mongodb_connect_timeout
}

env {
name = "mongodb.read-timeout"
value = var.mil_auth_mongodb_read_timeout
}

env {
name = "mongodb.server-selection-timeout"
value = var.mil_auth_mongodb_server_selection_timeout
}

env {
name = "mongodb.connection-string-1"
secret_name = "mongodb-connection-string-1"
}

env {
name = "mongodb.connection-string-2"
secret_name = "mongodb-connection-string-2"
}
}

max_replicas = var.mil_auth_max_replicas
min_replicas = var.mil_auth_min_replicas
}

secret {
name = "mongodb-connection-string-1"
value = azurerm_cosmosdb_account.mil.primary_mongodb_connection_string
}

secret {
name = "mongodb-connection-string-2"
value = azurerm_cosmosdb_account.mil.secondary_mongodb_connection_string
}

identity {
type = "SystemAssigned"
}
Expand Down
5 changes: 4 additions & 1 deletion src/core/env/dev/terraform.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,16 @@ mil_auth_keysize = 2048
mil_auth_access_duration = 900
mil_auth_refresh_duration = 3600
mil_auth_openapi_descriptor = "https://raw.githubusercontent.com/pagopa/mil-auth/main/src/main/resources/META-INF/openapi.yaml"
mil_auth_image = "ghcr.io/pagopa/mil-auth:latest"
mil_auth_image = "ghcr.io/pagopa/mil-auth:2.7.0-RC"
mil_auth_cpu = 1
mil_auth_memory = "2Gi"
mil_auth_max_replicas = 5
mil_auth_min_replicas = 0
mil_auth_keyvault_maxresults = 20
mil_auth_keyvault_backoff_num_of_attempts = 5
mil_auth_mongodb_connect_timeout = "5s"
mil_auth_mongodb_read_timeout = "10s"
mil_auth_mongodb_server_selection_timeout = "5s"

#
# mil-preset
Expand Down
5 changes: 4 additions & 1 deletion src/core/env/uat/terraform.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,16 @@ mil_auth_keysize = 2048
mil_auth_access_duration = 900
mil_auth_refresh_duration = 3600
mil_auth_openapi_descriptor = "https://raw.githubusercontent.com/pagopa/mil-auth/main/src/main/resources/META-INF/openapi.yaml"
mil_auth_image = "ghcr.io/pagopa/mil-auth:latest"
mil_auth_image = "ghcr.io/pagopa/mil-auth:2.7.0-RC"
mil_auth_cpu = 1
mil_auth_memory = "2Gi"
mil_auth_max_replicas = 5
mil_auth_min_replicas = 1
mil_auth_keyvault_maxresults = 20
mil_auth_keyvault_backoff_num_of_attempts = 5
mil_auth_mongodb_connect_timeout = "5s"
mil_auth_mongodb_read_timeout = "10s"
mil_auth_mongodb_server_selection_timeout = "5s"

#
# mil-preset
Expand Down

0 comments on commit 4d40d29

Please sign in to comment.