Skip to content

Commit 64de201

Browse files
authored
fix: add fix for autoscale bug (#192)
1 parent 3c864fe commit 64de201

File tree

12 files changed

+57
-81
lines changed

12 files changed

+57
-81
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ You need the following permissions to run this module.
4141

4242
- [ Restore from backup example](examples/backup)
4343
- [ Basic with read-only replica example](examples/basic)
44-
- [ Complete example with BYOK encryption, autoscaling, CBR rules and VPE creation](examples/complete)
45-
- [ Financial Services Cloud profile example](examples/fscloud)
44+
- [ Complete example with BYOK encryption, CBR rules and VPE creation](examples/complete)
45+
- [ Financial Services Cloud profile example with autoscaling enabled](examples/fscloud)
4646
- [ Point in time recovery example (PITR)](examples/pitr)
4747
<!-- END EXAMPLES HOOK -->
4848
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
@@ -71,7 +71,7 @@ You need the following permissions to run this module.
7171

7272
| Name | Description | Type | Default | Required |
7373
|------|-------------|------|---------|:--------:|
74-
| <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://ibm.biz/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 |
74+
| <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://ibm.biz/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 |
7575
| <a name="input_backup_crn"></a> [backup\_crn](#input\_backup\_crn) | The CRN of a backup resource to restore from. The backup is created by a database deployment with the same service ID. The backup is loaded after provisioning and the new deployment starts up that uses that data. A backup CRN is in the format crn:v1:<…>:backup:. If omitted, the database is provisioned empty. | `string` | `null` | no |
7676
| <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 |
7777
| <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 |

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 BYOK encryption, autoscaling, CBR rules and VPE creation
1+
# Complete example with BYOK encryption, CBR rules and VPE creation
22

33
An end-to-end example that does the following:
44

55
- Create a new resource group if one is not passed in.
66
- Create Key Protect instance with root key.
7-
- Create a new ICD PostgreSQL database instance with auto-scaling and BYOK encryption enabled.
7+
- Create a new ICD PostgreSQL database instance with BYOK encryption.
88
- Create service credentials for the database instance.
99
- Create a Virtual Private Cloud (VPC).
1010
- Create Context Based Restriction (CBR) to only allow Postgresql to be accessible from the VPC.

examples/complete/main.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ module "postgresql_db" {
7777
existing_kms_instance_guid = module.key_protect_all_inclusive.key_protect_guid
7878
resource_tags = var.resource_tags
7979
service_credential_names = var.service_credential_names
80-
auto_scaling = var.auto_scaling
8180
cbr_rules = [
8281
{
8382
description = "${var.prefix}-postgres access only from vpc"

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
"postgressql_editor" : "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) Configure rules to allow your database to automatically increase its resources. Single block of autoscaling is allowed at once."
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 PostgreSQL.
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 PostgreSQL database instances in the given resource group, and the Hyper Protect Crypto Services instance that is passed in.
99
- An IBM Cloud Databases PostgreSQL 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 PostgreSQL database instance.
1011
- Service Credentials for the PostgreSQL database instance.
1112
- A sample virtual private cloud (VPC).
1213
- A context-based restriction (CBR) rule to only allow PostgreSQL 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 "postgresql_db" {
6161
existing_kms_instance_guid = var.existing_kms_instance_guid
6262
resource_tags = var.resource_tags
6363
service_credential_names = var.service_credential_names
64+
auto_scaling = var.auto_scaling
6465
cbr_rules = [
6566
{
6667
description = "${var.prefix}-postgres 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
"postgressql_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://ibm.biz/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
@@ -82,12 +82,6 @@ resource "ibm_database" "postgresql_db" {
8282
dynamic "auto_scaling" {
8383
for_each = local.auto_scaling_enabled
8484
content {
85-
cpu {
86-
rate_increase_percent = var.auto_scaling.cpu.rate_increase_percent
87-
rate_limit_count_per_member = var.auto_scaling.cpu.rate_limit_count_per_member
88-
rate_period_seconds = var.auto_scaling.cpu.rate_period_seconds
89-
rate_units = var.auto_scaling.cpu.rate_units
90-
}
9185
disk {
9286
capacity_enabled = var.auto_scaling.disk.capacity_enabled
9387
free_space_less_than_percent = var.auto_scaling.disk.free_space_less_than_percent

module-metadata.json

Lines changed: 12 additions & 12 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://ibm.biz/autoscaling-considerations in the IBM Cloud Docs.",
88
"pos": {
99
"filename": "variables.tf",
@@ -19,7 +19,7 @@
1919
],
2020
"pos": {
2121
"filename": "variables.tf",
22-
"line": 229
22+
"line": 223
2323
}
2424
},
2525
"backup_encryption_key_crn": {
@@ -28,7 +28,7 @@
2828
"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.",
2929
"pos": {
3030
"filename": "variables.tf",
31-
"line": 183
31+
"line": 177
3232
}
3333
},
3434
"cbr_rules": {
@@ -45,7 +45,7 @@
4545
],
4646
"pos": {
4747
"filename": "variables.tf",
48-
"line": 209
48+
"line": 203
4949
}
5050
},
5151
"configuration": {
@@ -69,7 +69,7 @@
6969
],
7070
"pos": {
7171
"filename": "variables.tf",
72-
"line": 199
72+
"line": 193
7373
},
7474
"immutable": true,
7575
"computed": true
@@ -84,7 +84,7 @@
8484
],
8585
"pos": {
8686
"filename": "variables.tf",
87-
"line": 163
87+
"line": 157
8888
}
8989
},
9090
"kms_key_crn": {
@@ -96,7 +96,7 @@
9696
],
9797
"pos": {
9898
"filename": "variables.tf",
99-
"line": 169
99+
"line": 163
100100
},
101101
"immutable": true
102102
},
@@ -176,7 +176,7 @@
176176
],
177177
"pos": {
178178
"filename": "variables.tf",
179-
"line": 246
179+
"line": 240
180180
}
181181
},
182182
"pitr_time": {
@@ -188,7 +188,7 @@
188188
],
189189
"pos": {
190190
"filename": "variables.tf",
191-
"line": 252
191+
"line": 246
192192
}
193193
},
194194
"plan_validation": {
@@ -307,7 +307,7 @@
307307
"default": false,
308308
"pos": {
309309
"filename": "variables.tf",
310-
"line": 193
310+
"line": 187
311311
}
312312
}
313313
},
@@ -449,7 +449,7 @@
449449
},
450450
"pos": {
451451
"filename": "main.tf",
452-
"line": 169
452+
"line": 163
453453
}
454454
}
455455
},
@@ -528,7 +528,7 @@
528528
},
529529
"pos": {
530530
"filename": "main.tf",
531-
"line": 131
531+
"line": 125
532532
}
533533
}
534534
}

0 commit comments

Comments
 (0)