Skip to content

Commit 7998349

Browse files
authored
fix: add fix for autoscale bug (#163)
1 parent 4a8502b commit 7998349

File tree

12 files changed

+53
-77
lines changed

12 files changed

+53
-77
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ You need the following permissions to run this module.
3838
## Examples
3939

4040
- [ Basic example](examples/basic)
41-
- [ Complete example with encryption, autoscaling, and CBR rules](examples/complete)
42-
- [ Financial Services Cloud profile example](examples/fscloud)
41+
- [ Complete example with BYOK encryption and CBR rules](examples/complete)
42+
- [ Financial Services Cloud profile example with autoscaling enabled](examples/fscloud)
4343
<!-- END EXAMPLES HOOK -->
4444
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
4545
## Requirements
@@ -67,7 +67,7 @@ You need the following permissions to run this module.
6767

6868
| Name | Description | Type | Default | Required |
6969
|------|-------------|------|---------|:--------:|
70-
| <a name="input_auto_scaling"></a> [auto\_scaling](#input\_auto\_scaling) | Optional rules to allow the database to increase resources in response to usage. Only a single autoscaling block is allowed. Make sure you understand the effects of autoscaling, especially for production environments. See https://cloud.ibm.com/docs/databases-for-mongodb?topic=databases-for-mongodb-autoscaling&interface=cli#autoscaling-considerations in the IBM Cloud Docs. | <pre>object({<br> cpu = object({<br> rate_increase_percent = optional(number, 10)<br> rate_limit_count_per_member = optional(number, 30)<br> rate_period_seconds = optional(number, 900)<br> rate_units = optional(string, "count")<br> })<br> disk = object({<br> capacity_enabled = optional(bool, false)<br> free_space_less_than_percent = optional(number, 10)<br> io_above_percent = optional(number, 90)<br> io_enabled = optional(bool, false)<br> io_over_period = optional(string, "15m")<br> rate_increase_percent = optional(number, 10)<br> rate_limit_mb_per_member = optional(number, 3670016)<br> rate_period_seconds = optional(number, 900)<br> rate_units = optional(string, "mb")<br> })<br> memory = object({<br> io_above_percent = optional(number, 90)<br> io_enabled = optional(bool, false)<br> io_over_period = optional(string, "15m")<br> rate_increase_percent = optional(number, 10)<br> rate_limit_mb_per_member = optional(number, 114688)<br> rate_period_seconds = optional(number, 900)<br> rate_units = optional(string, "mb")<br> })<br> })</pre> | `null` | no |
70+
| <a name="input_auto_scaling"></a> [auto\_scaling](#input\_auto\_scaling) | Optional rules to allow the database to increase resources in response to usage. Only a single autoscaling block is allowed. Make sure you understand the effects of autoscaling, especially for production environments. See https://cloud.ibm.com/docs/databases-for-mongodb?topic=databases-for-mongodb-autoscaling&interface=cli#autoscaling-considerations in the IBM Cloud Docs. | <pre>object({<br> disk = object({<br> capacity_enabled = optional(bool, false)<br> free_space_less_than_percent = optional(number, 10)<br> io_above_percent = optional(number, 90)<br> io_enabled = optional(bool, false)<br> io_over_period = optional(string, "15m")<br> rate_increase_percent = optional(number, 10)<br> rate_limit_mb_per_member = optional(number, 3670016)<br> rate_period_seconds = optional(number, 900)<br> rate_units = optional(string, "mb")<br> })<br> memory = object({<br> io_above_percent = optional(number, 90)<br> io_enabled = optional(bool, false)<br> io_over_period = optional(string, "15m")<br> rate_increase_percent = optional(number, 10)<br> rate_limit_mb_per_member = optional(number, 114688)<br> rate_period_seconds = optional(number, 900)<br> rate_units = optional(string, "mb")<br> })<br> })</pre> | `null` | no |
7171
| <a name="input_backup_encryption_key_crn"></a> [backup\_encryption\_key\_crn](#input\_backup\_encryption\_key\_crn) | The CRN of a Key Protect key that you want to use for encrypting the disk that holds deployment backups. Only used if var.kms\_encryption\_enabled is set to true. BYOK for backups is available only in US regions us-south and us-east, and in eu-de. Only keys in the us-south and eu-de are durable to region failures. To ensure that your backups are available even if a region failure occurs, use a key from us-south or eu-de. Hyper Protect Crypto Services for IBM Cloud Databases backups is not currently supported. If no value is passed here, the value passed for the 'kms\_key\_crn' variable is used. And if a HPCS value is passed for var.kms\_key\_crn, the database backup encryption uses the default encryption keys. | `string` | `null` | no |
7272
| <a name="input_cbr_rules"></a> [cbr\_rules](#input\_cbr\_rules) | (Optional, list) List of CBR rules to create | <pre>list(object({<br> description = string<br> account_id = string<br> rule_contexts = list(object({<br> attributes = optional(list(object({<br> name = string<br> value = string<br> }))) }))<br> enforcement_mode = string<br> }))</pre> | `[]` | no |
7373
| <a name="input_configuration"></a> [configuration](#input\_configuration) | Database Configuration. | <pre>object({<br> maxmemory = optional(number)<br> maxmemory-policy = optional(string)<br> appendonly = optional(string)<br> maxmemory-samples = optional(number)<br> stop-writes-on-bgsave-error = optional(string)<br> })</pre> | `null` | no |

examples/complete/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# Complete example with encryption, autoscaling, and CBR rules
1+
# Complete example with BYOK encryption and CBR rules
22

33
An end-to-end example that uses the IBM Cloud Terraform provider to create the following infrastructure:
44

55
- A resource group, if one is not passed in.
66
- A Key Protect instance with a root key.
7-
- An instance of Databases for MongoDB with BYOK encryption and autoscaling enabled (automatically increases resources).
7+
- An instance of Databases for MongoDB with BYOK encryption.
88
- Service credentials for the database instance.
99
- A sample virtual private cloud (VPC).
1010
- A context-based restriction (CBR) rule to only allow MongoDB to be accessible from within the VPC.

examples/complete/main.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ module "mongodb" {
7676
region = var.region
7777
kms_key_crn = module.key_protect_all_inclusive.keys["icd.${var.prefix}-mongodb"].crn
7878
tags = var.resource_tags
79-
auto_scaling = var.auto_scaling
8079
service_credential_names = var.service_credential_names
8180
cbr_rules = [
8281
{

examples/complete/variables.tf

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -44,45 +44,3 @@ variable "service_credential_names" {
4444
"mongodb_viewer" : "Editor",
4545
}
4646
}
47-
48-
variable "auto_scaling" {
49-
type = object({
50-
cpu = object({
51-
rate_increase_percent = optional(number)
52-
rate_limit_count_per_member = optional(number)
53-
rate_period_seconds = optional(number)
54-
rate_units = optional(string)
55-
})
56-
disk = object({
57-
capacity_enabled = optional(bool)
58-
free_space_less_than_percent = optional(number)
59-
io_above_percent = optional(number)
60-
io_enabled = optional(bool)
61-
io_over_period = optional(string)
62-
rate_increase_percent = optional(number)
63-
rate_limit_mb_per_member = optional(number)
64-
rate_period_seconds = optional(number)
65-
rate_units = optional(string)
66-
})
67-
memory = object({
68-
io_above_percent = optional(number)
69-
io_enabled = optional(bool)
70-
io_over_period = optional(string)
71-
rate_increase_percent = optional(number)
72-
rate_limit_mb_per_member = optional(number)
73-
rate_period_seconds = optional(number)
74-
rate_units = optional(string)
75-
})
76-
})
77-
description = "Optional rules to allow the database to increase resources in response to usage. Only a single autoscaling block is allowed. Make sure you understand the effects of autoscaling, especially for production environments. See https://cloud.ibm.com/docs/databases-for-mongodb?topic=databases-for-mongodb-autoscaling&interface=cli#autoscaling-considerations in the IBM Cloud Docs."
78-
default = {
79-
cpu = {}
80-
disk = {
81-
capacity_enabled : true,
82-
io_enabled : true
83-
}
84-
memory = {
85-
io_enabled : true,
86-
}
87-
}
88-
}

examples/fscloud/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Financial Services Cloud profile example
1+
# Financial Services Cloud profile example with autoscaling enabled
22

33
An end-to-end example that uses the [Profile for IBM Cloud Framework for Financial Services](../../profiles/fscloud/) to deploy an instance of IBM Cloud Databases for MongoDB.
44

@@ -7,6 +7,7 @@ The example uses the IBM Cloud Terraform provider to create the following infras
77
- A resource group, if one is not passed in.
88
- An IAM authorization between all MongoDB database instances in the given resource group, and the Hyper Protect Crypto Services instance that is passed in.
99
- An IBM Cloud Databases MongoDB database instance that is encrypted with the Hyper Protect Crypto Services root key that is passed in.
10+
- Autoscaling rules for the IBM Cloud Databases MongoDB database instance.
1011
- Service Credentials for the MongoDB database instance.
1112
- A sample virtual private cloud (VPC).
1213
- A context-based restriction (CBR) rule to only allow MongoDB to be accessible from within the VPC.

examples/fscloud/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ module "mongodb" {
6161
existing_kms_instance_guid = var.existing_kms_instance_guid
6262
mongodb_version = var.mongodb_version
6363
service_credential_names = var.service_credential_names
64+
auto_scaling = var.auto_scaling
6465
cbr_rules = [
6566
{
6667
description = "${var.prefix}-mongodb access only from vpc"

examples/fscloud/variables.tf

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,38 @@ variable "service_credential_names" {
5454
"mongodb_editor" : "Editor",
5555
}
5656
}
57+
58+
variable "auto_scaling" {
59+
type = object({
60+
disk = object({
61+
capacity_enabled = optional(bool)
62+
free_space_less_than_percent = optional(number)
63+
io_above_percent = optional(number)
64+
io_enabled = optional(bool)
65+
io_over_period = optional(string)
66+
rate_increase_percent = optional(number)
67+
rate_limit_mb_per_member = optional(number)
68+
rate_period_seconds = optional(number)
69+
rate_units = optional(string)
70+
})
71+
memory = object({
72+
io_above_percent = optional(number)
73+
io_enabled = optional(bool)
74+
io_over_period = optional(string)
75+
rate_increase_percent = optional(number)
76+
rate_limit_mb_per_member = optional(number)
77+
rate_period_seconds = optional(number)
78+
rate_units = optional(string)
79+
})
80+
})
81+
description = "Optional rules to allow the database to increase resources in response to usage. Only a single autoscaling block is allowed. Make sure you understand the effects of autoscaling, especially for production environments. See https://cloud.ibm.com/docs/databases-for-mongodb?topic=databases-for-mongodb-autoscaling&interface=cli#autoscaling-considerations in the IBM Cloud Docs."
82+
default = {
83+
disk = {
84+
capacity_enabled : true,
85+
io_enabled : true
86+
}
87+
memory = {
88+
io_enabled : true,
89+
}
90+
}
91+
}

main.tf

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,6 @@ resource "ibm_database" "mongodb" {
7575
dynamic "auto_scaling" {
7676
for_each = local.auto_scaling_enabled
7777
content {
78-
cpu {
79-
rate_increase_percent = var.auto_scaling.cpu.rate_increase_percent
80-
rate_limit_count_per_member = var.auto_scaling.cpu.rate_limit_count_per_member
81-
rate_period_seconds = var.auto_scaling.cpu.rate_period_seconds
82-
rate_units = var.auto_scaling.cpu.rate_units
83-
}
8478
disk {
8579
capacity_enabled = var.auto_scaling.disk.capacity_enabled
8680
free_space_less_than_percent = var.auto_scaling.disk.free_space_less_than_percent

module-metadata.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"variables": {
44
"auto_scaling": {
55
"name": "auto_scaling",
6-
"type": "object({\n cpu = object({\n rate_increase_percent = optional(number, 10)\n rate_limit_count_per_member = optional(number, 30)\n rate_period_seconds = optional(number, 900)\n rate_units = optional(string, \"count\")\n })\n disk = object({\n capacity_enabled = optional(bool, false)\n free_space_less_than_percent = optional(number, 10)\n io_above_percent = optional(number, 90)\n io_enabled = optional(bool, false)\n io_over_period = optional(string, \"15m\")\n rate_increase_percent = optional(number, 10)\n rate_limit_mb_per_member = optional(number, 3670016)\n rate_period_seconds = optional(number, 900)\n rate_units = optional(string, \"mb\")\n })\n memory = object({\n io_above_percent = optional(number, 90)\n io_enabled = optional(bool, false)\n io_over_period = optional(string, \"15m\")\n rate_increase_percent = optional(number, 10)\n rate_limit_mb_per_member = optional(number, 114688)\n rate_period_seconds = optional(number, 900)\n rate_units = optional(string, \"mb\")\n })\n })",
6+
"type": "object({\n disk = object({\n capacity_enabled = optional(bool, false)\n free_space_less_than_percent = optional(number, 10)\n io_above_percent = optional(number, 90)\n io_enabled = optional(bool, false)\n io_over_period = optional(string, \"15m\")\n rate_increase_percent = optional(number, 10)\n rate_limit_mb_per_member = optional(number, 3670016)\n rate_period_seconds = optional(number, 900)\n rate_units = optional(string, \"mb\")\n })\n memory = object({\n io_above_percent = optional(number, 90)\n io_enabled = optional(bool, false)\n io_over_period = optional(string, \"15m\")\n rate_increase_percent = optional(number, 10)\n rate_limit_mb_per_member = optional(number, 114688)\n rate_period_seconds = optional(number, 900)\n rate_units = optional(string, \"mb\")\n })\n })",
77
"description": "Optional rules to allow the database to increase resources in response to usage. Only a single autoscaling block is allowed. Make sure you understand the effects of autoscaling, especially for production environments. See https://cloud.ibm.com/docs/databases-for-mongodb?topic=databases-for-mongodb-autoscaling\u0026interface=cli#autoscaling-considerations in the IBM Cloud Docs.",
88
"pos": {
99
"filename": "variables.tf",
@@ -16,7 +16,7 @@
1616
"description": "The CRN of a Key Protect key that you want to use for encrypting the disk that holds deployment backups. Only used if var.kms_encryption_enabled is set to true. BYOK for backups is available only in US regions us-south and us-east, and in eu-de. Only keys in the us-south and eu-de are durable to region failures. To ensure that your backups are available even if a region failure occurs, use a key from us-south or eu-de. Hyper Protect Crypto Services for IBM Cloud Databases backups is not currently supported. If no value is passed here, the value passed for the 'kms_key_crn' variable is used. And if a HPCS value is passed for var.kms_key_crn, the database backup encryption uses the default encryption keys.",
1717
"pos": {
1818
"filename": "variables.tf",
19-
"line": 179
19+
"line": 173
2020
}
2121
},
2222
"cbr_rules": {
@@ -33,7 +33,7 @@
3333
],
3434
"pos": {
3535
"filename": "variables.tf",
36-
"line": 205
36+
"line": 199
3737
}
3838
},
3939
"configuration": {
@@ -91,7 +91,7 @@
9191
],
9292
"pos": {
9393
"filename": "variables.tf",
94-
"line": 195
94+
"line": 189
9595
},
9696
"immutable": true,
9797
"computed": true
@@ -119,7 +119,7 @@
119119
],
120120
"pos": {
121121
"filename": "variables.tf",
122-
"line": 159
122+
"line": 153
123123
}
124124
},
125125
"kms_key_crn": {
@@ -131,7 +131,7 @@
131131
],
132132
"pos": {
133133
"filename": "variables.tf",
134-
"line": 165
134+
"line": 159
135135
},
136136
"immutable": true
137137
},
@@ -253,7 +253,7 @@
253253
"default": false,
254254
"pos": {
255255
"filename": "variables.tf",
256-
"line": 189
256+
"line": 183
257257
}
258258
},
259259
"tags": {
@@ -406,7 +406,7 @@
406406
},
407407
"pos": {
408408
"filename": "main.tf",
409-
"line": 164
409+
"line": 158
410410
}
411411
}
412412
},
@@ -485,7 +485,7 @@
485485
},
486486
"pos": {
487487
"filename": "main.tf",
488-
"line": 125
488+
"line": 119
489489
}
490490
}
491491
}

0 commit comments

Comments
 (0)