Skip to content
This repository was archived by the owner on Jun 30, 2025. It is now read-only.

Commit 9404c0f

Browse files
authored
feat: added new input variable member_host_flavor and updated default value of memory_mb to 4096.<br><br>Reference: [Cloud Database Hosting Models](https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-hosting-models)<br><br>The [host model switching](https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-hosting-models&interface=api#hosting-models-switching) section has details of the migrations that the service is rolling out. All instances will have to be switched and the [time line](https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-hosting-models&interface=api#hosting-model-transition-timeline) for the migrations is outlined.<br><br>During the transition both existing and new models are supported.<br><br>Users of this module should consider the changes being implemented by the service. It is recommended that new deployments use the shared or isolated compute models to start, by specifying the member_host_flavor. It is recommended that existing deployments make updates to control the upgrade process by specifying shared or isolate compute configurations and the resource required to run the service, by adding the member_host_flavor. (#179)
1 parent 9db685a commit 9404c0f

File tree

9 files changed

+93
-24
lines changed

9 files changed

+93
-24
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ You need the following permissions to run this module.
101101
| <a name="input_kms_key_crn"></a> [kms\_key\_crn](#input\_kms\_key\_crn) | The root key CRN of a Key Management Services like Key Protect or Hyper Protect Crypto Service (HPCS) that you want to use for disk encryption. Only used if var.kms\_encryption\_enabled is set to true. | `string` | `null` | no |
102102
| <a name="input_member_cpu_count"></a> [member\_cpu\_count](#input\_member\_cpu\_count) | Allocated dedicated CPU per-member. For shared CPU, set to 0. See the following doc for supported values: https://cloud.ibm.com/docs/databases-for-etcd?topic=databases-for-etcd-resources-scaling | `number` | `0` | no |
103103
| <a name="input_member_disk_mb"></a> [member\_disk\_mb](#input\_member\_disk\_mb) | Allocated memory per-member. See the following doc for supported values: https://cloud.ibm.com/docs/databases-for-etcd?topic=databases-for-etcd-resources-scaling | `number` | `20480` | no |
104-
| <a name="input_member_memory_mb"></a> [member\_memory\_mb](#input\_member\_memory\_mb) | Allocated memory per-member. See the following doc for supported values: https://cloud.ibm.com/docs/databases-for-etcd?topic=databases-for-etcd-resources-scaling | `number` | `1024` | no |
104+
| <a name="input_member_host_flavor"></a> [member\_host\_flavor](#input\_member\_host\_flavor) | Allocated host flavor per member. [Learn more](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/database#host_flavor). | `string` | `null` | no |
105+
| <a name="input_member_memory_mb"></a> [member\_memory\_mb](#input\_member\_memory\_mb) | Allocated memory per-member. See the following doc for supported values: https://cloud.ibm.com/docs/databases-for-etcd?topic=databases-for-etcd-resources-scaling | `number` | `4096` | no |
105106
| <a name="input_members"></a> [members](#input\_members) | Allocated number of members. Members can be scaled up but not down. | `number` | `3` | no |
106107
| <a name="input_name"></a> [name](#input\_name) | The name to give the etcd instance. | `string` | n/a | yes |
107108
| <a name="input_region"></a> [region](#input\_region) | The region where you want to deploy your instance. | `string` | `"us-south"` | no |

examples/backup-restore/main.tf

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ data "ibm_database_backups" "backup_database" {
1616

1717
# New etcd db instance pointing to the backup instance
1818
module "restored_etcd_db" {
19-
source = "../.."
20-
resource_group_id = module.resource_group.resource_group_id
21-
name = "${var.prefix}-etcd-restored"
22-
region = var.region
23-
etcd_version = var.etcd_version
24-
access_tags = var.access_tags
25-
tags = var.resource_tags
26-
backup_crn = data.ibm_database_backups.backup_database.backups[0].backup_id
19+
source = "../.."
20+
resource_group_id = module.resource_group.resource_group_id
21+
name = "${var.prefix}-etcd-restored"
22+
region = var.region
23+
etcd_version = var.etcd_version
24+
access_tags = var.access_tags
25+
tags = var.resource_tags
26+
member_host_flavor = "multitenant"
27+
backup_crn = data.ibm_database_backups.backup_database.backups[0].backup_id
2728
}

examples/complete/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,5 @@ module "etcd_db" {
5353
tags = var.resource_tags
5454
access_tags = var.access_tags
5555
service_credential_names = var.service_credential_names
56+
member_host_flavor = "multitenant"
5657
}

examples/fscloud/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ module "etcd_db" {
6565
existing_kms_instance_guid = var.existing_kms_instance_guid
6666
service_credential_names = var.service_credential_names
6767
auto_scaling = var.auto_scaling
68+
member_host_flavor = "b3c.4x16.encrypted"
6869
backup_encryption_key_crn = var.backup_encryption_key_crn
6970
backup_crn = var.backup_crn
7071
cbr_rules = [

main.tf

Lines changed: 61 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ locals {
2222
# Determine if auto scaling is enabled
2323
auto_scaling_enabled = var.auto_scaling == null ? [] : [1]
2424

25+
# Determine if host_flavor is used
26+
host_flavor_set = var.member_host_flavor != null ? true : false
27+
2528
# Determine what KMS service is being used for database encryption
2629
kms_service = var.kms_key_crn != null ? (
2730
can(regex(".*kms.*", var.kms_key_crn)) ? "kms" : (
@@ -74,22 +77,68 @@ resource "ibm_database" "etcd_db" {
7477
}
7578
}
7679

77-
group {
78-
group_id = "member" #Only member type is allowed for etcd
79-
memory {
80-
allocation_mb = var.member_memory_mb
81-
}
82-
disk {
83-
allocation_mb = var.member_disk_mb
80+
## This for_each block is NOT a loop to attach to multiple group blocks.
81+
## This is used to conditionally add one, OR, the other group block depending on var.local.host_flavor_set
82+
## This block is for if host_flavor IS set to specific pre-defined host sizes and not set to "multitenant"
83+
dynamic "group" {
84+
for_each = local.host_flavor_set && var.member_host_flavor != "multitenant" ? [1] : []
85+
content {
86+
group_id = "member" # Only member type is allowed for IBM Cloud Databases
87+
host_flavor {
88+
id = var.member_host_flavor
89+
}
90+
disk {
91+
allocation_mb = var.member_disk_mb
92+
}
93+
members {
94+
allocation_count = var.members
95+
}
8496
}
85-
cpu {
86-
allocation_count = var.member_cpu_count
97+
}
98+
99+
## This block is for if host_flavor IS set to "multitenant"
100+
dynamic "group" {
101+
for_each = local.host_flavor_set && var.member_host_flavor == "multitenant" ? [1] : []
102+
content {
103+
group_id = "member" # Only member type is allowed for IBM Cloud Databases
104+
host_flavor {
105+
id = var.member_host_flavor
106+
}
107+
disk {
108+
allocation_mb = var.member_disk_mb
109+
}
110+
memory {
111+
allocation_mb = var.member_memory_mb
112+
}
113+
cpu {
114+
allocation_count = var.member_cpu_count
115+
}
116+
members {
117+
allocation_count = var.members
118+
}
87119
}
120+
}
88121

89-
members {
90-
allocation_count = var.members
122+
## This block is for if host_flavor IS NOT set
123+
dynamic "group" {
124+
for_each = local.host_flavor_set ? [] : [1]
125+
content {
126+
group_id = "member" # Only member type is allowed for IBM Cloud Databases
127+
memory {
128+
allocation_mb = var.member_memory_mb
129+
}
130+
disk {
131+
allocation_mb = var.member_disk_mb
132+
}
133+
cpu {
134+
allocation_count = var.member_cpu_count
135+
}
136+
members {
137+
allocation_count = var.members
138+
}
91139
}
92140
}
141+
93142
dynamic "auto_scaling" {
94143
for_each = local.auto_scaling_enabled
95144
content {
@@ -165,7 +214,7 @@ module "cbr_rule" {
165214
}
166215
]
167216
}]
168-
# There is only 1 operation type for Elasticsearch so it is not exposed as a configuration
217+
# There is only 1 operation type for etcd so it is not exposed as a configuration
169218
operations = [{
170219
api_types = [
171220
{

modules/fscloud/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ No resources.
4141
| <a name="input_kms_key_crn"></a> [kms\_key\_crn](#input\_kms\_key\_crn) | The root key CRN of the Hyper Protect Crypto Service (HPCS) to use for disk encryption. | `string` | n/a | yes |
4242
| <a name="input_member_cpu_count"></a> [member\_cpu\_count](#input\_member\_cpu\_count) | Allocated dedicated CPU per-member. For shared CPU, set to 0. See the following doc for supported values: https://cloud.ibm.com/docs/databases-for-etcd?topic=databases-for-etcd-resources-scaling | `number` | `0` | no |
4343
| <a name="input_member_disk_mb"></a> [member\_disk\_mb](#input\_member\_disk\_mb) | Allocated memory per-member. See the following doc for supported values: https://cloud.ibm.com/docs/databases-for-etcd?topic=databases-for-etcd-resources-scaling | `number` | `20480` | no |
44-
| <a name="input_member_memory_mb"></a> [member\_memory\_mb](#input\_member\_memory\_mb) | Allocated memory per-member. See the following doc for supported values: https://cloud.ibm.com/docs/databases-for-etcd?topic=databases-for-etcd-resources-scaling | `number` | `1024` | no |
44+
| <a name="input_member_host_flavor"></a> [member\_host\_flavor](#input\_member\_host\_flavor) | Allocated host flavor per member. [Learn more](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/database#host_flavor). | `string` | `null` | no |
45+
| <a name="input_member_memory_mb"></a> [member\_memory\_mb](#input\_member\_memory\_mb) | Allocated memory per-member. See the following doc for supported values: https://cloud.ibm.com/docs/databases-for-etcd?topic=databases-for-etcd-resources-scaling | `number` | `4096` | no |
4546
| <a name="input_members"></a> [members](#input\_members) | Allocated number of members. Members can be scaled up but not down. | `number` | `3` | no |
4647
| <a name="input_name"></a> [name](#input\_name) | Name of the etcd\_db instance | `string` | n/a | yes |
4748
| <a name="input_region"></a> [region](#input\_region) | The region where you want to deploy your instance. Must be the same region as the Hyper Protect Crypto Services instance. | `string` | `"us-south"` | no |

modules/fscloud/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ module "etcd_db" {
2020
users = var.users
2121
member_disk_mb = var.member_disk_mb
2222
member_cpu_count = var.member_cpu_count
23+
member_host_flavor = var.member_host_flavor
2324
auto_scaling = var.auto_scaling
2425
service_credential_names = var.service_credential_names
2526
}

modules/fscloud/variables.tf

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ variable "region" {
2727
variable "member_memory_mb" {
2828
type = number
2929
description = "Allocated memory per-member. See the following doc for supported values: https://cloud.ibm.com/docs/databases-for-etcd?topic=databases-for-etcd-resources-scaling"
30-
default = 1024
30+
default = 4096
3131
# Validation is done in terraform plan phase by IBM provider, so no need to add any extra validation here
3232
}
3333

@@ -45,6 +45,13 @@ variable "member_cpu_count" {
4545
# Validation is done in terraform plan phase by IBM provider, so no need to add any extra validation here
4646
}
4747

48+
variable "member_host_flavor" {
49+
type = string
50+
description = "Allocated host flavor per member. [Learn more](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/database#host_flavor)."
51+
default = null
52+
# Validation is done in the Terraform plan phase by the IBM provider, so no need to add extra validation here.
53+
}
54+
4855
# actual scaling of the resources could take some time to apply
4956
variable "members" {
5057
type = number

variables.tf

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ variable "region" {
3535
variable "member_memory_mb" {
3636
type = number
3737
description = "Allocated memory per-member. See the following doc for supported values: https://cloud.ibm.com/docs/databases-for-etcd?topic=databases-for-etcd-resources-scaling"
38-
default = 1024
38+
default = 4096
3939
# Validation is done in terraform plan phase by IBM provider, so no need to add any extra validation here
4040
}
4141

@@ -53,6 +53,13 @@ variable "member_cpu_count" {
5353
# Validation is done in terraform plan phase by IBM provider, so no need to add any extra validation here
5454
}
5555

56+
variable "member_host_flavor" {
57+
type = string
58+
description = "Allocated host flavor per member. [Learn more](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/database#host_flavor)."
59+
default = null
60+
# Validation is done in the Terraform plan phase by the IBM provider, so no need to add extra validation here.
61+
}
62+
5663
# actual scaling of the resources could take some time to apply
5764
variable "members" {
5865
type = number

0 commit comments

Comments
 (0)