Skip to content

Commit d4f10c0

Browse files
authored
feat: added new input variable member_host_flavor and updated default value of memory_mb to 8192.<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. (#368)
1 parent 7c5407f commit d4f10c0

File tree

9 files changed

+84
-17
lines changed

9 files changed

+84
-17
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,9 @@ You need the following permissions to run this module.
9393
| <a name="input_instance_name"></a> [instance\_name](#input\_instance\_name) | The name to give the Redis instance. | `string` | n/a | yes |
9494
| <a name="input_kms_encryption_enabled"></a> [kms\_encryption\_enabled](#input\_kms\_encryption\_enabled) | Set this to true to control the encryption keys used to encrypt the data that you store in IBM Cloud® Databases. If set to false, the data is encrypted by using randomly generated keys. For more info on Key Protect integration, see https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-key-protect. For more info on HPCS integration, see https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-hpcs | `bool` | `false` | no |
9595
| <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 |
96+
| <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 |
9697
| <a name="input_members"></a> [members](#input\_members) | Allocated number of members. Members can be scaled up but not down. | `number` | `2` | no |
97-
| <a name="input_memory_mb"></a> [memory\_mb](#input\_memory\_mb) | Allocated memory per member. For more information, see https://cloud.ibm.com/docs/databases-for-redis?topic=databases-for-redis-resources-scaling | `number` | `1024` | no |
98+
| <a name="input_memory_mb"></a> [memory\_mb](#input\_memory\_mb) | Allocated memory per member. For more information, see https://cloud.ibm.com/docs/databases-for-redis?topic=databases-for-redis-resources-scaling | `number` | `4096` | no |
9899
| <a name="input_redis_version"></a> [redis\_version](#input\_redis\_version) | Version of the Redis instance to provision. If no value is passed, the current preferred version of IBM Cloud Databases is used. | `string` | `null` | no |
99100
| <a name="input_region"></a> [region](#input\_region) | The region where you want to deploy your instance. | `string` | `"us-south"` | no |
100101
| <a name="input_resource_group_id"></a> [resource\_group\_id](#input\_resource\_group\_id) | The resource group ID where the Redis instance will be created. | `string` | n/a | yes |

examples/advanced/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ module "icd_redis" {
9393
kms_key_crn = module.key_protect_all_inclusive.keys["icd.${var.prefix}-redis"].crn
9494
tags = var.resource_tags
9595
service_credential_names = var.service_credential_names
96+
member_host_flavor = "multitenant"
9697
cbr_rules = [
9798
{
9899
description = "sample rule"

examples/advanced/outputs.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ output "service_credentials_object" {
3030
}
3131

3232
output "hostname" {
33-
description = "Postgresql instance hostname"
33+
description = "Redis instance hostname"
3434
value = module.icd_redis.hostname
3535
}
3636

3737
output "port" {
38-
description = "Postgresql instance port"
38+
description = "Redis instance port"
3939
value = module.icd_redis.port
4040
}

examples/fscloud/main.tf

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

main.tf

Lines changed: 60 additions & 11 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" : (
@@ -85,19 +88,65 @@ resource "ibm_database" "redis_database" {
8588
}
8689
}
8790

88-
group {
89-
group_id = "member"
90-
memory {
91-
allocation_mb = var.memory_mb
92-
}
93-
disk {
94-
allocation_mb = var.disk_mb
91+
## This for_each block is NOT a loop to attach to multiple group blocks.
92+
## This is used to conditionally add one, OR, the other group block depending on var.local.host_flavor_set
93+
## This block is for if host_flavor IS set to specific pre-defined host sizes and not set to "multitenant"
94+
dynamic "group" {
95+
for_each = local.host_flavor_set && var.member_host_flavor != "multitenant" ? [1] : []
96+
content {
97+
group_id = "member" # Only member type is allowed for IBM Cloud Databases
98+
host_flavor {
99+
id = var.member_host_flavor
100+
}
101+
disk {
102+
allocation_mb = var.disk_mb
103+
}
104+
members {
105+
allocation_count = var.members
106+
}
95107
}
96-
cpu {
97-
allocation_count = var.cpu_count
108+
}
109+
110+
## This block is for if host_flavor IS set to "multitenant"
111+
dynamic "group" {
112+
for_each = local.host_flavor_set && var.member_host_flavor == "multitenant" ? [1] : []
113+
content {
114+
group_id = "member" # Only member type is allowed for IBM Cloud Databases
115+
host_flavor {
116+
id = var.member_host_flavor
117+
}
118+
disk {
119+
allocation_mb = var.disk_mb
120+
}
121+
memory {
122+
allocation_mb = var.memory_mb
123+
}
124+
cpu {
125+
allocation_count = var.cpu_count
126+
}
127+
members {
128+
allocation_count = var.members
129+
}
98130
}
99-
members {
100-
allocation_count = var.members
131+
}
132+
133+
## This block is for if host_flavor IS NOT set
134+
dynamic "group" {
135+
for_each = local.host_flavor_set ? [] : [1]
136+
content {
137+
group_id = "member" # Only member type is allowed for IBM Cloud Databases
138+
memory {
139+
allocation_mb = var.memory_mb
140+
}
141+
disk {
142+
allocation_mb = var.disk_mb
143+
}
144+
cpu {
145+
allocation_count = var.cpu_count
146+
}
147+
members {
148+
allocation_count = var.members
149+
}
101150
}
102151
}
103152

modules/fscloud/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ No resources.
4141
| <a name="input_existing_kms_instance_guid"></a> [existing\_kms\_instance\_guid](#input\_existing\_kms\_instance\_guid) | The GUID of the Hyper Protect Crypto Services instance. | `string` | n/a | yes |
4242
| <a name="input_instance_name"></a> [instance\_name](#input\_instance\_name) | The name to give the Redis instance. | `string` | n/a | yes |
4343
| <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 |
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 |
4445
| <a name="input_members"></a> [members](#input\_members) | Allocated number of members. Members can be scaled up but not down. | `number` | `2` | no |
45-
| <a name="input_memory_mb"></a> [memory\_mb](#input\_memory\_mb) | Allocated memory per member. For more information, see https://cloud.ibm.com/docs/databases-for-redis?topic=databases-for-redis-resources-scaling | `number` | `1024` | no |
46+
| <a name="input_memory_mb"></a> [memory\_mb](#input\_memory\_mb) | Allocated memory per member. For more information, see https://cloud.ibm.com/docs/databases-for-redis?topic=databases-for-redis-resources-scaling | `number` | `4096` | no |
4647
| <a name="input_redis_version"></a> [redis\_version](#input\_redis\_version) | The version of redis. If null, the current default ICD redis version is used. | `string` | `null` | no |
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 |
4849
| <a name="input_resource_group_id"></a> [resource\_group\_id](#input\_resource\_group\_id) | The resource group ID where the Redis instance will be created. | `string` | n/a | yes |

modules/fscloud/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module "redis" {
1010
configuration = var.configuration
1111
cpu_count = var.cpu_count
1212
memory_mb = var.memory_mb
13+
member_host_flavor = var.member_host_flavor
1314
members = var.members
1415
admin_pass = var.admin_pass
1516
users = var.users

modules/fscloud/variables.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ variable "cpu_count" {
4040
variable "memory_mb" {
4141
description = "Allocated memory per member. For more information, see https://cloud.ibm.com/docs/databases-for-redis?topic=databases-for-redis-resources-scaling"
4242
type = number
43-
default = 1024
43+
default = 4096
4444
}
4545

4646
variable "disk_mb" {
@@ -56,6 +56,12 @@ variable "members" {
5656
# Validation is done in terraform plan phase by IBM provider, so no need to add any extra validation here
5757
}
5858

59+
variable "member_host_flavor" {
60+
type = string
61+
description = "Allocated host flavor per member. [Learn more](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/database#host_flavor)."
62+
default = null
63+
}
64+
5965
variable "admin_pass" {
6066
type = string
6167
description = "The password for the database administrator. If the admin password is null then the admin user ID cannot be accessed. More users can be specified in a user block."

variables.tf

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ variable "cpu_count" {
4949
variable "memory_mb" {
5050
description = "Allocated memory per member. For more information, see https://cloud.ibm.com/docs/databases-for-redis?topic=databases-for-redis-resources-scaling"
5151
type = number
52-
default = 1024
52+
default = 4096
5353
# Validation is done in terraform plan phase by IBM provider, so no need to add any extra validation here
5454
}
5555

@@ -60,6 +60,13 @@ variable "disk_mb" {
6060
# Validation is done in terraform plan phase by IBM provider, so no need to add any extra validation here
6161
}
6262

63+
variable "member_host_flavor" {
64+
type = string
65+
description = "Allocated host flavor per member. [Learn more](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/database#host_flavor)."
66+
default = null
67+
# Validation is done in the Terraform plan phase by the IBM provider, so no need to add extra validation here.
68+
}
69+
6370
variable "members" {
6471
description = "Allocated number of members. Members can be scaled up but not down."
6572
type = number

0 commit comments

Comments
 (0)