Skip to content

Commit a079367

Browse files
authored
feat: added the ability to set the host flavor using input variable member_host_flavor<br>- the default value of member_memory_mb has been updated to 4096<br><br>### [Cloud Database Hosting Models](https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-hosting-models)<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. (#184)
1 parent b413e90 commit a079367

File tree

12 files changed

+124
-45
lines changed

12 files changed

+124
-45
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ You need the following permissions to run this module.
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 |
9797
| <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. For more information, see https://cloud.ibm.com/docs/databases-for-elasticsearch?topic=databases-for-elasticsearch-resources-scaling | `number` | `0` | no |
9898
| <a name="input_member_disk_mb"></a> [member\_disk\_mb](#input\_member\_disk\_mb) | Allocated disk per-member. For more information, see https://cloud.ibm.com/docs/databases-for-elasticsearch?topic=databases-for-elasticsearch-resources-scaling | `number` | `5120` | no |
99-
| <a name="input_member_memory_mb"></a> [member\_memory\_mb](#input\_member\_memory\_mb) | Allocated memory per-member. For more information, see https://cloud.ibm.com/docs/databases-for-elasticsearch?topic=databases-for-elasticsearch-resources-scaling | `number` | `1024` | no |
99+
| <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 |
100+
| <a name="input_member_memory_mb"></a> [member\_memory\_mb](#input\_member\_memory\_mb) | Allocated memory per-member. For more information, see https://cloud.ibm.com/docs/databases-for-elasticsearch?topic=databases-for-elasticsearch-resources-scaling | `number` | `4096` | no |
100101
| <a name="input_members"></a> [members](#input\_members) | Allocated number of members. For more information, see https://cloud.ibm.com/docs/databases-for-elasticsearch?topic=databases-for-elasticsearch-resources-scaling | `number` | `3` | no |
101102
| <a name="input_name"></a> [name](#input\_name) | The name to give the Elasticsearch instance. | `string` | n/a | yes |
102103
| <a name="input_plan"></a> [plan](#input\_plan) | The name of the service plan that you choose for your Elasticsearch instance | `string` | `"enterprise"` | no |

examples/complete/main.tf

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ module "key_protect_all_inclusive" {
2929
resource_tags = var.resource_tags
3030
keys = [
3131
{
32-
key_ring_name = "icd"
32+
key_ring_name = "icd"
33+
force_delete_key_ring = true
3334
keys = [
3435
{
35-
key_name = "${var.prefix}-elasticsearch"
36+
key_name = "${var.prefix}-elasticsearch"
37+
force_delete = true
3638
}
3739
]
3840
}
@@ -59,6 +61,8 @@ module "icd_elasticsearch" {
5961
kms_key_crn = module.key_protect_all_inclusive.keys["icd.${var.prefix}-elasticsearch"].crn
6062
tags = var.resource_tags
6163
auto_scaling = var.auto_scaling
64+
member_host_flavor = "multitenant"
65+
member_memory_mb = 4096
6266
}
6367

6468
# wait 15 secs to allow IAM credential access to kick in before configuring instance

examples/fscloud/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ module "elasticsearch" {
6565
elasticsearch_version = var.elasticsearch_version
6666
service_credential_names = var.service_credential_names
6767
auto_scaling = var.auto_scaling
68+
member_host_flavor = "b3c.4x16.encrypted"
6869
cbr_rules = [
6970
{
7071
description = "${var.prefix}-elasticsearch access only from vpc"

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" "elasticsearch" {
6770
}
6871
}
6972

70-
group {
71-
group_id = "member"
72-
73-
memory {
74-
allocation_mb = var.member_memory_mb
75-
}
76-
77-
disk {
78-
allocation_mb = var.member_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 postgresql
80+
host_flavor {
81+
id = var.member_host_flavor
82+
}
83+
disk {
84+
allocation_mb = var.member_disk_mb
85+
}
86+
members {
87+
allocation_count = var.members
88+
}
7989
}
90+
}
8091

81-
cpu {
82-
allocation_count = var.member_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 postgresql
97+
host_flavor {
98+
id = var.member_host_flavor
99+
}
100+
disk {
101+
allocation_mb = var.member_disk_mb
102+
}
103+
memory {
104+
allocation_mb = var.member_memory_mb
105+
}
106+
cpu {
107+
allocation_count = var.member_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 postgresql
120+
memory {
121+
allocation_mb = var.member_memory_mb
122+
}
123+
disk {
124+
allocation_mb = var.member_disk_mb
125+
}
126+
cpu {
127+
allocation_count = var.member_cpu_count
128+
}
129+
members {
130+
allocation_count = var.members
131+
}
87132
}
88133
}
89134

modules/fscloud/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ No resources.
4040
| <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 |
4141
| <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. For more information, see https://cloud.ibm.com/docs/databases-for-elasticsearch?topic=databases-for-elasticsearch-resources-scaling | `number` | `0` | no |
4242
| <a name="input_member_disk_mb"></a> [member\_disk\_mb](#input\_member\_disk\_mb) | Allocated disk per-member. For more information, see https://cloud.ibm.com/docs/databases-for-elasticsearch?topic=databases-for-elasticsearch-resources-scaling | `number` | `5120` | no |
43-
| <a name="input_member_memory_mb"></a> [member\_memory\_mb](#input\_member\_memory\_mb) | Allocated memory per-member. For more information, see https://cloud.ibm.com/docs/databases-for-elasticsearch?topic=databases-for-elasticsearch-resources-scaling | `number` | `1024` | no |
43+
| <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 |
44+
| <a name="input_member_memory_mb"></a> [member\_memory\_mb](#input\_member\_memory\_mb) | Allocated memory per member. [Learn more](https://cloud.ibm.com/docs/databases-for-elasticsearch?topic=databases-for-elasticsearch-resources-scaling). | `number` | `4096` | no |
4445
| <a name="input_members"></a> [members](#input\_members) | Allocated number of members. For more information, see https://cloud.ibm.com/docs/databases-for-elasticsearch?topic=databases-for-elasticsearch-resources-scaling | `number` | `3` | no |
4546
| <a name="input_name"></a> [name](#input\_name) | Name of the Elasticsearch instance | `string` | n/a | yes |
4647
| <a name="input_plan"></a> [plan](#input\_plan) | The name of the service plan that you choose for your Elasticsearch instance | `string` | `"enterprise"` | no |

modules/fscloud/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ module "elasticsearch" {
2121
users = var.users
2222
member_disk_mb = var.member_disk_mb
2323
member_cpu_count = var.member_cpu_count
24+
member_host_flavor = var.member_host_flavor
2425
auto_scaling = var.auto_scaling
2526
service_credential_names = var.service_credential_names
2627
}

modules/fscloud/variables.tf

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ variable "members" {
5252

5353
variable "member_memory_mb" {
5454
type = number
55-
description = "Allocated memory per-member. For more information, see https://cloud.ibm.com/docs/databases-for-elasticsearch?topic=databases-for-elasticsearch-resources-scaling"
56-
default = 1024
55+
description = "Allocated memory per member. [Learn more](https://cloud.ibm.com/docs/databases-for-elasticsearch?topic=databases-for-elasticsearch-resources-scaling)."
56+
default = 4096
5757
# Validation is done in the Terraform plan phase by the IBM provider, so no need to add extra validation here.
5858
}
5959

@@ -72,6 +72,12 @@ variable "member_disk_mb" {
7272
# Validation is done in the Terraform plan phase by the IBM provider, so no need to add extra validation here.
7373
}
7474

75+
variable "member_host_flavor" {
76+
type = string
77+
description = "Allocated host flavor per member. [Learn more](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/database#host_flavor)."
78+
default = null
79+
}
80+
7581
variable "service_credential_names" {
7682
description = "Map of name, role for service credentials that you want to create for the database"
7783
type = map(string)

solutions/secure/main.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,11 @@ module "elasticsearch" {
7474
kms_key_crn = local.kms_key_crn
7575
access_tags = var.access_tags
7676
tags = var.tags
77-
members = var.members
78-
member_memory_mb = var.member_memory_mb
7977
admin_pass = var.admin_pass
8078
users = var.users
79+
members = var.members
80+
member_host_flavor = var.member_host_flavor
81+
member_memory_mb = var.member_memory_mb
8182
member_disk_mb = var.member_disk_mb
8283
member_cpu_count = var.member_cpu_count
8384
auto_scaling = var.auto_scaling

solutions/secure/variables.tf

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ variable "members" {
5858

5959
variable "member_memory_mb" {
6060
type = number
61-
description = "The memory per member that is allocated. For more information, see https://cloud.ibm.com/docs/databases-for-elasticsearch?topic=databases-for-elasticsearch-resources-scaling"
62-
default = 1024
61+
description = "Allocated memory per member. [Learn more](https://cloud.ibm.com/docs/databases-for-elasticsearch?topic=databases-for-elasticsearch-resources-scaling)"
62+
default = 4096
6363
}
6464

6565
variable "member_cpu_count" {
@@ -74,6 +74,18 @@ variable "member_disk_mb" {
7474
default = 5120
7575
}
7676

77+
# Use new hosting model for all DA
78+
variable "member_host_flavor" {
79+
type = string
80+
description = "The host flavor per member. [Learn more](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/database#host_flavor)."
81+
default = "multitenant"
82+
# Prevent null or "", require multitenant or a machine type
83+
validation {
84+
condition = (length(var.member_host_flavor) > 0)
85+
error_message = "Member host flavor must be specified. [Learn more](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/database#host_flavor)."
86+
}
87+
}
88+
7789
variable "service_credential_names" {
7890
description = "The map of name, role for service credentials that you want to create for the database"
7991
type = map(string)

tests/other_test.go

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,6 @@ import (
1313
"github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/testhelper"
1414
)
1515

16-
func TestRunBasicExample(t *testing.T) {
17-
t.Parallel()
18-
19-
options := testhelper.TestOptionsDefaultWithVars(&testhelper.TestOptions{
20-
Testing: t,
21-
TerraformDir: "examples/basic",
22-
Prefix: "es-test",
23-
ResourceGroup: resourceGroup,
24-
BestRegionYAMLPath: regionSelectionPath,
25-
CloudInfoService: sharedInfoSvc,
26-
27-
TerraformVars: map[string]interface{}{
28-
"elasticsearch_version": "8.12", // Always lock this test into the latest supported elasticsearch version
29-
},
30-
})
31-
32-
output, err := options.RunTestConsistency()
33-
assert.Nil(t, err, "This should not have errored")
34-
assert.NotNil(t, output, "Expected some output")
35-
}
36-
3716
func TestRunCompleteExampleOtherVersion(t *testing.T) {
3817
t.Parallel()
3918

0 commit comments

Comments
 (0)