Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add performance_diagnostics, backup_window_start #14

Merged
merged 1 commit into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,22 @@ No modules.

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_access"></a> [access](#input\_access) | Access policy to the MongoDB cluster | <pre>object({<br> data_lens = optional(bool)<br> data_transfer = optional(bool)<br> })</pre> | `null` | no |
| <a name="input_backup_window_start"></a> [backup\_window\_start](#input\_backup\_window\_start) | Time to start the daily backup, in the UTC timezone | <pre>object({<br> hours = optional(number)<br> minutes = optional(number)<br> })</pre> | `null` | no |
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | Name of the MongoDB cluster | `string` | n/a | yes |
| <a name="input_database_name"></a> [database\_name](#input\_database\_name) | Name of the database | `string` | n/a | yes |
| <a name="input_deletion_protection"></a> [deletion\_protection](#input\_deletion\_protection) | Inhibits deletion of the cluster | `bool` | `false` | no |
| <a name="input_environment"></a> [environment](#input\_environment) | Deployment environment of the MongoDB cluster | `string` | n/a | yes |
| <a name="input_feature_compatibility_version"></a> [feature\_compatibility\_version](#input\_feature\_compatibility\_version) | Feature compatibility version of MongoDB | `string` | `null` | no |
| <a name="input_labels"></a> [labels](#input\_labels) | A set of key/value label pairs to assign to the MongoDB cluster | `map(string)` | `{}` | no |
| <a name="input_mongod_hosts"></a> [mongod\_hosts](#input\_mongod\_hosts) | List of hosts in MongoDB cluster. | <pre>list(object({<br> zone_id = optional(string, "ru-central1-a")<br> subnet_id = string<br> }))</pre> | n/a | yes |
| <a name="input_mongodb_version"></a> [mongodb\_version](#input\_mongodb\_version) | Version of the MongoDB server software | `string` | n/a | yes |
| <a name="input_network_id"></a> [network\_id](#input\_network\_id) | ID of the network, to which the Redis cluster belongs | `string` | n/a | yes |
| <a name="input_performance_diagnostics"></a> [performance\_diagnostics](#input\_performance\_diagnostics) | Performance diagnostics to the MongoDB cluster | <pre>object({<br> enabled = optional(bool)<br> })</pre> | `null` | no |
| <a name="input_resources_mongod_disk_size"></a> [resources\_mongod\_disk\_size](#input\_resources\_mongod\_disk\_size) | Volume of the storage available to a MongoDB host, in gigabytes | `number` | n/a | yes |
| <a name="input_resources_mongod_disk_type"></a> [resources\_mongod\_disk\_type](#input\_resources\_mongod\_disk\_type) | Type of the storage of MongoDB hosts | `string` | n/a | yes |
| <a name="input_resources_mongod_preset"></a> [resources\_mongod\_preset](#input\_resources\_mongod\_preset) | The ID of the preset for computational resources available to a MongoDB host | `string` | n/a | yes |
| <a name="input_security_group_ids"></a> [security\_group\_ids](#input\_security\_group\_ids) | A set of ids of security groups assigned to hosts of the cluster | `list(string)` | `[]` | no |
| <a name="input_subnet_id"></a> [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 |
| <a name="input_user_name"></a> [user\_name](#input\_user\_name) | Name of the user | `string` | n/a | yes |
| <a name="input_user_password"></a> [user\_password](#input\_user\_password) | Password of the user | `string` | n/a | yes |
Expand Down
30 changes: 27 additions & 3 deletions examples/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Expand Down
29 changes: 28 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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" {
Expand Down
44 changes: 44 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
Loading