Skip to content

Commit 227cf24

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. (#199)
1 parent 1e5618b commit 227cf24

File tree

10 files changed

+127
-46
lines changed

10 files changed

+127
-46
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,9 @@ You need the following permissions to run this module.
9494
| <a name="input_instance_name"></a> [instance\_name](#input\_instance\_name) | The name to give the RabbitMQ instance | `string` | n/a | yes |
9595
| <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 |
9696
| <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 |
97+
| <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 |
9798
| <a name="input_members"></a> [members](#input\_members) | Allocated number of members. For more information, see: https://cloud.ibm.com/docs/messages-for-rabbitmq?topic=messages-for-rabbitmq-resources-scaling | `number` | `3` | 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/messages-for-rabbitmq?topic=messages-for-rabbitmq-resources-scaling | `number` | `1024` | no |
99+
| <a name="input_memory_mb"></a> [memory\_mb](#input\_memory\_mb) | Allocated memory per-member. For more information, see: https://cloud.ibm.com/docs/messages-for-rabbitmq?topic=messages-for-rabbitmq-resources-scaling | `number` | `8192` | no |
99100
| <a name="input_plan"></a> [plan](#input\_plan) | The name of the service plan that you choose for your RabbitMQ instance | `string` | `"standard"` | no |
100101
| <a name="input_rabbitmq_version"></a> [rabbitmq\_version](#input\_rabbitmq\_version) | The version of RabbitMQ to deploy. If no value passed, the current ICD preferred version is used. | `string` | `null` | no |
101102
| <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 RabbitMQ db instance pointing to the backup instance
1818
module "restored_rabbitmq_db" {
19-
source = "../.."
20-
resource_group_id = module.resource_group.resource_group_id
21-
instance_name = "${var.prefix}-rabbitmq-restored"
22-
region = var.region
23-
rabbitmq_version = var.rabbitmq_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+
instance_name = "${var.prefix}-rabbitmq-restored"
22+
region = var.region
23+
rabbitmq_version = var.rabbitmq_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
@@ -96,6 +96,7 @@ module "icd_rabbitmq" {
9696
tags = var.resource_tags
9797
access_tags = var.access_tags
9898
auto_scaling = var.auto_scaling
99+
member_host_flavor = "multitenant"
99100
cbr_rules = [
100101
{
101102
description = "${var.prefix}-rabbitmq access only from vpc"

examples/complete/outputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ output "id" {
88
}
99

1010
output "guid" {
11-
description = "Postgresql instance guid"
11+
description = "RabbitMQ instance guid"
1212
value = module.icd_rabbitmq.guid
1313
}
1414

examples/fscloud/main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ module "cbr_zone" {
5050
}
5151

5252
##############################################################################
53-
# Postgres Instance
53+
# RabbitMQ Instance
5454
##############################################################################
5555

5656
module "rabbitmq_database" {
@@ -66,6 +66,7 @@ module "rabbitmq_database" {
6666
tags = var.tags
6767
access_tags = var.access_tags
6868
auto_scaling = var.auto_scaling
69+
member_host_flavor = "b3c.4x16.encrypted"
6970
backup_encryption_key_crn = var.backup_encryption_key_crn
7071
backup_crn = var.backup_crn
7172
cbr_rules = [

main.tf

Lines changed: 58 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ locals {
1616
# Determine if auto scaling is enabled
1717
auto_scaling_enabled = var.auto_scaling == null ? [] : [1]
1818

19+
# Determine if host_flavor is used
20+
host_flavor_set = var.member_host_flavor != null ? true : false
21+
1922
# Determine what KMS service is being used for database encryption
2023
kms_service = var.kms_key_crn != null ? (
2124
can(regex(".*kms.*", var.kms_key_crn)) ? "kms" : (
@@ -67,23 +70,65 @@ resource "ibm_database" "rabbitmq_database" {
6770
}
6871
}
6972

70-
group {
71-
group_id = "member"
72-
73-
memory {
74-
allocation_mb = var.memory_mb
75-
}
76-
77-
disk {
78-
allocation_mb = var.disk_mb
73+
## This for_each block is NOT a loop to attach to multiple group blocks.
74+
## This is used to conditionally add one, OR, the other group block depending on var.local.host_flavor_set
75+
## This block is for if host_flavor IS set to specific pre-defined host sizes and not set to "multitenant"
76+
dynamic "group" {
77+
for_each = local.host_flavor_set && var.member_host_flavor != "multitenant" ? [1] : []
78+
content {
79+
group_id = "member" # Only member type is allowed for IBM Cloud Databases
80+
host_flavor {
81+
id = var.member_host_flavor
82+
}
83+
disk {
84+
allocation_mb = var.disk_mb
85+
}
86+
members {
87+
allocation_count = var.members
88+
}
7989
}
90+
}
8091

81-
cpu {
82-
allocation_count = var.cpu_count
92+
## This block is for if host_flavor IS set to "multitenant"
93+
dynamic "group" {
94+
for_each = local.host_flavor_set && var.member_host_flavor == "multitenant" ? [1] : []
95+
content {
96+
group_id = "member" # Only member type is allowed for IBM Cloud Databases
97+
host_flavor {
98+
id = var.member_host_flavor
99+
}
100+
disk {
101+
allocation_mb = var.disk_mb
102+
}
103+
memory {
104+
allocation_mb = var.memory_mb
105+
}
106+
cpu {
107+
allocation_count = var.cpu_count
108+
}
109+
members {
110+
allocation_count = var.members
111+
}
83112
}
113+
}
84114

85-
members {
86-
allocation_count = var.members
115+
## This block is for if host_flavor IS NOT set
116+
dynamic "group" {
117+
for_each = local.host_flavor_set ? [] : [1]
118+
content {
119+
group_id = "member" # Only member type is allowed for IBM Cloud Databases
120+
memory {
121+
allocation_mb = var.memory_mb
122+
}
123+
disk {
124+
allocation_mb = var.disk_mb
125+
}
126+
cpu {
127+
allocation_count = var.cpu_count
128+
}
129+
members {
130+
allocation_count = var.members
131+
}
87132
}
88133
}
89134

modules/fscloud/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,14 @@ No resources.
4242
| <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 |
4343
| <a name="input_instance_name"></a> [instance\_name](#input\_instance\_name) | The name of the RabbitMQ instance | `string` | n/a | yes |
4444
| <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 |
45+
| <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 |
4546
| <a name="input_members"></a> [members](#input\_members) | Allocated number of members. For more information, see: https://cloud.ibm.com/docs/messages-for-rabbitmq?topic=messages-for-rabbitmq-resources-scaling | `number` | `3` | no |
47+
| <a name="input_memory_mb"></a> [memory\_mb](#input\_memory\_mb) | Allocated memory per member. [Learn more](https://cloud.ibm.com/docs/messages-for-rabbitmq?topic=messages-for-rabbitmq-resources-scaling). | `number` | `8192` | no |
4648
| <a name="input_rabbitmq_version"></a> [rabbitmq\_version](#input\_rabbitmq\_version) | The version of RabbitMQ to deploy. If no value passed, the current ICD preferred version is used. | `string` | `null` | no |
4749
| <a name="input_region"></a> [region](#input\_region) | The region where you want to deploy your instance. | `string` | `"us-south"` | no |
4850
| <a name="input_resource_group_id"></a> [resource\_group\_id](#input\_resource\_group\_id) | The resource group ID where the RabbitMQ instance will be created. | `string` | n/a | yes |
4951
| <a name="input_service_credential_names"></a> [service\_credential\_names](#input\_service\_credential\_names) | Map of name, role for service credentials that you want to create for the database | `map(string)` | `{}` | no |
52+
| <a name="input_skip_iam_authorization_policy"></a> [skip\_iam\_authorization\_policy](#input\_skip\_iam\_authorization\_policy) | Set to true to skip the creation of an IAM authorization policy that permits all RabbitMQ instances in the resource group to read the encryption key from the Hyper Protect Crypto Services instance. The HPCS instance is passed in through the var.existing\_kms\_instance\_guid variable. | `bool` | `false` | no |
5053
| <a name="input_tags"></a> [tags](#input\_tags) | Optional list of tags to be added to the RabbitMQ instance. | `list(any)` | `[]` | no |
5154
| <a name="input_users"></a> [users](#input\_users) | A list of users that you want to create on the database. Multiple blocks are allowed. The user password must be in the range of 10-32 characters. Be warned that in most case using IAM service credentials (via the var.service\_credential\_names) is sufficient to control access to the RabbitMQ instance. This blocks creates native RabbitMQ database users, more info on that can be found here https://cloud.ibm.com/docs/messages-for-rabbitmq?topic=messages-for-rabbitmq-user-management | <pre>list(object({<br> name = string<br> password = string # pragma: allowlist secret<br> type = string # "type" is required to generate the connection string for the outputs.<br> role = optional(string)<br> }))</pre> | `[]` | no |
5255

modules/fscloud/main.tf

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
11
module "rabbitmq_database" {
2-
source = "../../"
3-
resource_group_id = var.resource_group_id
4-
instance_name = var.instance_name
5-
region = var.region
6-
rabbitmq_version = var.rabbitmq_version
7-
endpoints = var.endpoints
8-
tags = var.tags
9-
access_tags = var.access_tags
10-
kms_encryption_enabled = true
11-
existing_kms_instance_guid = var.existing_kms_instance_guid
12-
service_credential_names = var.service_credential_names
13-
backup_encryption_key_crn = var.backup_encryption_key_crn
14-
kms_key_crn = var.kms_key_crn
15-
admin_pass = var.admin_pass
16-
members = var.members
17-
users = var.users
18-
disk_mb = var.disk_mb
19-
cpu_count = var.cpu_count
20-
auto_scaling = var.auto_scaling
21-
cbr_rules = var.cbr_rules
22-
backup_crn = var.backup_crn
2+
source = "../../"
3+
resource_group_id = var.resource_group_id
4+
instance_name = var.instance_name
5+
region = var.region
6+
skip_iam_authorization_policy = var.skip_iam_authorization_policy
7+
rabbitmq_version = var.rabbitmq_version
8+
endpoints = var.endpoints
9+
tags = var.tags
10+
access_tags = var.access_tags
11+
kms_encryption_enabled = true
12+
existing_kms_instance_guid = var.existing_kms_instance_guid
13+
service_credential_names = var.service_credential_names
14+
backup_encryption_key_crn = var.backup_encryption_key_crn
15+
kms_key_crn = var.kms_key_crn
16+
admin_pass = var.admin_pass
17+
members = var.members
18+
users = var.users
19+
memory_mb = var.memory_mb
20+
disk_mb = var.disk_mb
21+
cpu_count = var.cpu_count
22+
member_host_flavor = var.member_host_flavor
23+
auto_scaling = var.auto_scaling
24+
cbr_rules = var.cbr_rules
25+
backup_crn = var.backup_crn
2326
}

modules/fscloud/variables.tf

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ variable "existing_kms_instance_guid" {
4747
type = string
4848
}
4949

50+
variable "skip_iam_authorization_policy" {
51+
type = bool
52+
description = "Set to true to skip the creation of an IAM authorization policy that permits all RabbitMQ instances in the resource group to read the encryption key from the Hyper Protect Crypto Services instance. The HPCS instance is passed in through the var.existing_kms_instance_guid variable."
53+
default = false
54+
}
55+
5056
variable "backup_encryption_key_crn" {
5157
type = string
5258
description = "The CRN of a Hyper Protect Crypto Service use for encrypting the disk that holds deployment backups. Only used if var.kms_encryption_enabled is set to true. There are limitation per region on the Hyper Protect Crypto Services and region for those services. See https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-hpcs#use-hpcs-backups"
@@ -86,6 +92,13 @@ variable "service_credential_names" {
8692
default = {}
8793
}
8894

95+
variable "memory_mb" {
96+
type = number
97+
description = "Allocated memory per member. [Learn more](https://cloud.ibm.com/docs/messages-for-rabbitmq?topic=messages-for-rabbitmq-resources-scaling)."
98+
default = 8192
99+
# Validation is done in the Terraform plan phase by the IBM provider, so no need to add extra validation here.
100+
}
101+
89102
variable "disk_mb" {
90103
description = "Allocated disk per member. For more information, see https://cloud.ibm.com/docs/messages-for-rabbitmq?topic=messages-for-rabbitmq-resources-scaling"
91104
type = number
@@ -98,6 +111,12 @@ variable "cpu_count" {
98111
default = 0
99112
}
100113

114+
variable "member_host_flavor" {
115+
type = string
116+
description = "Allocated host flavor per member. [Learn more](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/database#host_flavor)."
117+
default = null
118+
}
119+
101120
variable "auto_scaling" {
102121
type = object({
103122
disk = object({

variables.tf

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ variable "members" {
8383
variable "memory_mb" {
8484
description = "Allocated memory per-member. For more information, see: https://cloud.ibm.com/docs/messages-for-rabbitmq?topic=messages-for-rabbitmq-resources-scaling"
8585
type = number
86-
default = 1024
86+
default = 8192
8787
}
8888

8989
variable "cpu_count" {
@@ -98,6 +98,13 @@ variable "disk_mb" {
9898
default = 1024
9999
}
100100

101+
variable "member_host_flavor" {
102+
type = string
103+
description = "Allocated host flavor per member. [Learn more](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/database#host_flavor)."
104+
default = null
105+
# Validation is done in the Terraform plan phase by the IBM provider, so no need to add extra validation here.
106+
}
107+
101108
variable "auto_scaling" {
102109
type = object({
103110
disk = object({

0 commit comments

Comments
 (0)