diff --git a/README.md b/README.md index 368f15b..af63586 100644 --- a/README.md +++ b/README.md @@ -41,16 +41,22 @@ No modules. | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| +| [access](#input\_access) | Access policy to the MongoDB cluster |
object({
data_lens = optional(bool)
data_transfer = optional(bool)
})
| `null` | no | +| [backup\_window\_start](#input\_backup\_window\_start) | Time to start the daily backup, in the UTC timezone |
object({
hours = optional(number)
minutes = optional(number)
})
| `null` | no | | [cluster\_name](#input\_cluster\_name) | Name of the MongoDB cluster | `string` | n/a | yes | | [database\_name](#input\_database\_name) | Name of the database | `string` | n/a | yes | +| [deletion\_protection](#input\_deletion\_protection) | Inhibits deletion of the cluster | `bool` | `false` | no | | [environment](#input\_environment) | Deployment environment of the MongoDB cluster | `string` | n/a | yes | +| [feature\_compatibility\_version](#input\_feature\_compatibility\_version) | Feature compatibility version of MongoDB | `string` | `null` | no | | [labels](#input\_labels) | A set of key/value label pairs to assign to the MongoDB cluster | `map(string)` | `{}` | no | | [mongod\_hosts](#input\_mongod\_hosts) | List of hosts in MongoDB cluster. |
list(object({
zone_id = optional(string, "ru-central1-a")
subnet_id = string
}))
| n/a | yes | | [mongodb\_version](#input\_mongodb\_version) | Version of the MongoDB server software | `string` | n/a | yes | | [network\_id](#input\_network\_id) | ID of the network, to which the Redis cluster belongs | `string` | n/a | yes | +| [performance\_diagnostics](#input\_performance\_diagnostics) | Performance diagnostics to the MongoDB cluster |
object({
enabled = optional(bool)
})
| `null` | no | | [resources\_mongod\_disk\_size](#input\_resources\_mongod\_disk\_size) | Volume of the storage available to a MongoDB host, in gigabytes | `number` | n/a | yes | | [resources\_mongod\_disk\_type](#input\_resources\_mongod\_disk\_type) | Type of the storage of MongoDB hosts | `string` | n/a | yes | | [resources\_mongod\_preset](#input\_resources\_mongod\_preset) | The ID of the preset for computational resources available to a MongoDB host | `string` | n/a | yes | +| [security\_group\_ids](#input\_security\_group\_ids) | A set of ids of security groups assigned to hosts of the cluster | `list(string)` | `[]` | no | | [subnet\_id](#input\_subnet\_id) | The ID of the subnet, to which the host belongs. The subnet must be a part of the network to which the cluster belongs | `string` | n/a | yes | | [user\_name](#input\_user\_name) | Name of the user | `string` | n/a | yes | | [user\_password](#input\_user\_password) | Password of the user | `string` | n/a | yes | diff --git a/examples/main.tf b/examples/main.tf index 7184ed7..1056e40 100644 --- a/examples/main.tf +++ b/examples/main.tf @@ -10,9 +10,9 @@ module "network" { repo = "terraform-yacloud-modules/terraform-yandex-vpc" } - azs = ["ru-central1-a"] + azs = ["ru-central1-a", "ru-central1-b"] - private_subnets = [["10.5.0.0/24"]] + private_subnets = [["10.5.0.0/24"], ["10.6.0.0/24"]] create_vpc = true create_nat_gateway = true @@ -34,7 +34,31 @@ module "mongodb_cluster" { resources_mongod_preset = "s2.small" resources_mongod_disk_size = 16 resources_mongod_disk_type = "network-hdd" - mongod_hosts = [{ subnet_id = module.network.private_subnets_ids[0] }, { subnet_id = module.network.private_subnets_ids[0] }] + + feature_compatibility_version = "5.0" + + mongod_hosts = [ + { + zone_id = "ru-central1-a" + subnet_id = module.network.private_subnets_ids[0] + }, + { + zone_id = "ru-central1-b" + subnet_id = module.network.private_subnets_ids[1] + } + ] + deletion_protection = false + backup_window_start = { + hours = 2 + minutes = 0 + } + performance_diagnostics = { + enabled = true + } + access = { + data_lens = true + data_transfer = true + } # maintenance_window_type = "ANYTIME" depends_on = [module.network] diff --git a/main.tf b/main.tf index ff45312..54a5866 100644 --- a/main.tf +++ b/main.tf @@ -7,7 +7,31 @@ resource "yandex_mdb_mongodb_cluster" "mongodb_cluster" { network_id = var.network_id cluster_config { - version = var.mongodb_version + version = var.mongodb_version + feature_compatibility_version = var.feature_compatibility_version + + dynamic "backup_window_start" { + for_each = var.backup_window_start != null ? [var.backup_window_start] : [] + content { + hours = backup_window_start.value.hours + minutes = backup_window_start.value.minutes + } + } + + dynamic "performance_diagnostics" { + for_each = var.performance_diagnostics != null ? [var.performance_diagnostics] : [] + content { + enabled = performance_diagnostics.value.enabled + } + } + + dynamic "access" { + for_each = var.access != null ? [var.access] : [] + content { + data_lens = access.value.data_lens + data_transfer = access.value.data_transfer + } + } } labels = var.labels @@ -30,6 +54,9 @@ resource "yandex_mdb_mongodb_cluster" "mongodb_cluster" { # maintenance_window { # type = var.maintenance_window_type # } + + security_group_ids = var.security_group_ids + deletion_protection = var.deletion_protection } resource "yandex_mdb_mongodb_database" "mongodb_database" { diff --git a/variables.tf b/variables.tf index d7004bb..2885c7f 100644 --- a/variables.tf +++ b/variables.tf @@ -33,6 +33,12 @@ variable "mongodb_version" { type = string } +variable "feature_compatibility_version" { + description = "Feature compatibility version of MongoDB" + type = string + default = null +} + variable "labels" { description = "A set of key/value label pairs to assign to the MongoDB cluster" type = map(string) @@ -86,3 +92,41 @@ variable "mongod_hosts" { # error_message = "The maintenance window type must be either ANYTIME or WEEKLY." # } # } + +variable "security_group_ids" { + description = "A set of ids of security groups assigned to hosts of the cluster" + type = list(string) + default = [] +} + +variable "deletion_protection" { + description = "Inhibits deletion of the cluster" + type = bool + default = false +} + +variable "backup_window_start" { + description = "Time to start the daily backup, in the UTC timezone" + type = object({ + hours = optional(number) + minutes = optional(number) + }) + default = null +} + +variable "performance_diagnostics" { + description = "Performance diagnostics to the MongoDB cluster" + type = object({ + enabled = optional(bool) + }) + default = null +} + +variable "access" { + description = "Access policy to the MongoDB cluster" + type = object({ + data_lens = optional(bool) + data_transfer = optional(bool) + }) + default = null +}