Skip to content

Commit 4ebf7c8

Browse files
authored
feat: added new variable member_host_flavor which allows you to explicially specify the host falvor. See [here](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/database#host_flavor) for list of valid values (NOTE: This is currently a Beta feature) (#382)
1 parent f8d2b45 commit 4ebf7c8

File tree

16 files changed

+102
-30
lines changed

16 files changed

+102
-30
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ To attach access management tags to resources in this module, you need the follo
5858
| Name | Version |
5959
|------|---------|
6060
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0, <1.7.0 |
61-
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.61.0, <2.0.0 |
61+
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.62.0, <2.0.0 |
6262
| <a name="requirement_time"></a> [time](#requirement\_time) | >= 0.9.1 |
6363

6464
### Modules
@@ -94,6 +94,7 @@ To attach access management tags to resources in this module, you need the follo
9494
| <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 Services (HPCS) that you want to use for disk encryption. Only used if var.kms\_encryption\_enabled is set to true. | `string` | `null` | no |
9595
| <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-postgresql?topic=databases-for-postgresql-resources-scaling | `number` | `0` | no |
9696
| <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-postgresql?topic=databases-for-postgresql-resources-scaling | `number` | `5120` | no |
97+
| <a name="input_member_host_flavor"></a> [member\_host\_flavor](#input\_member\_host\_flavor) | Allocated host flavor per member. For more information, see https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/database#host_flavor | `string` | `null` | no |
9798
| <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-postgresql?topic=databases-for-postgresql-resources-scaling | `number` | `1024` | no |
9899
| <a name="input_members"></a> [members](#input\_members) | Allocated number of members. Members can be scaled up but not down. | `number` | `2` | no |
99100
| <a name="input_name"></a> [name](#input\_name) | The name to give the Postgresql instance. | `string` | n/a | yes |

examples/backup/version.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ terraform {
55
# module's version.tf (basic example), and 1 example that will always use the latest provider version (complete example).
66
ibm = {
77
source = "IBM-Cloud/ibm"
8-
version = ">=1.61.0, <2.0.0"
8+
version = ">=1.62.0, <2.0.0"
99
}
1010
}
1111
}

examples/basic/main.tf

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ module "resource_group" {
1515
##############################################################################
1616

1717
module "postgresql_db" {
18-
source = "../.."
19-
resource_group_id = module.resource_group.resource_group_id
20-
name = "${var.prefix}-postgres"
21-
pg_version = var.pg_version
22-
region = var.region
23-
resource_tags = var.resource_tags
24-
access_tags = var.access_tags
18+
source = "../.."
19+
resource_group_id = module.resource_group.resource_group_id
20+
name = "${var.prefix}-postgres"
21+
pg_version = var.pg_version
22+
region = var.region
23+
resource_tags = var.resource_tags
24+
access_tags = var.access_tags
25+
member_host_flavor = var.member_host_flavor
2526
}
2627

2728
# On destroy, we are seeing that even though the replica has been returned as

examples/basic/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,9 @@ variable "read_only_replicas_count" {
5050
error_message = "There is a limit of five read-only replicas per leader"
5151
}
5252
}
53+
54+
variable "member_host_flavor" {
55+
type = string
56+
description = "Allocated host flavor per member. For more information, see https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/database#host_flavor"
57+
default = null
58+
}

examples/basic/version.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ terraform {
55
# module's version.tf (basic example), and 1 example that will always use the latest provider version (complete example).
66
ibm = {
77
source = "IBM-Cloud/ibm"
8-
version = "1.61.0"
8+
version = "1.62.0"
99
}
1010

1111
time = {

examples/complete/version.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ terraform {
55
# module's version.tf (basic example), and 1 example that will always use the latest provider version (complete example).
66
ibm = {
77
source = "IBM-Cloud/ibm"
8-
version = ">=1.61.0, <2.0.0"
8+
version = ">=1.62.0, <2.0.0"
99
}
1010
time = {
1111
source = "hashicorp/time"

examples/fscloud/version.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ terraform {
55
# module's version.tf (basic example), and 1 example that will always use the latest provider version (complete example).
66
ibm = {
77
source = "IBM-Cloud/ibm"
8-
version = ">=1.61.0, <2.0.0"
8+
version = ">=1.62.0, <2.0.0"
99
}
1010
}
1111
}

examples/pitr/version.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ terraform {
55
# module's version.tf (basic example), and 1 example that will always use the latest provider version (complete example).
66
ibm = {
77
source = "IBM-Cloud/ibm"
8-
version = ">=1.61.0, <2.0.0"
8+
version = ">=1.62.0, <2.0.0"
99
}
1010
}
1111
}

main.tf

Lines changed: 43 additions & 14 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" : (
@@ -79,21 +82,47 @@ resource "ibm_database" "postgresql_db" {
7982
}
8083
}
8184

82-
group {
83-
group_id = "member" # Only member type is allowed for postgresql
84-
memory {
85-
allocation_mb = var.member_memory_mb
86-
}
87-
disk {
88-
allocation_mb = var.member_disk_mb
89-
}
90-
cpu {
91-
allocation_count = var.member_cpu_count
85+
## This for_each block is NOT a loop to attach to multiple group blocks.
86+
## This is used to conditionally add one, OR, the other group block depending on var.local.host_flavor_set
87+
## This block is for if host_flavor IS set
88+
dynamic "group" {
89+
for_each = local.host_flavor_set ? [1] : []
90+
content {
91+
group_id = "member" # Only member type is allowed for postgresql
92+
host_flavor {
93+
id = var.member_host_flavor
94+
}
95+
disk {
96+
allocation_mb = var.member_disk_mb
97+
}
98+
dynamic "members" {
99+
for_each = var.remote_leader_crn == null ? [1] : []
100+
content {
101+
allocation_count = var.members
102+
}
103+
}
92104
}
93-
dynamic "members" {
94-
for_each = var.remote_leader_crn == null ? [1] : []
95-
content {
96-
allocation_count = var.members
105+
}
106+
107+
## This block is for if host_flavor IS NOT set
108+
dynamic "group" {
109+
for_each = local.host_flavor_set ? [] : [1]
110+
content {
111+
group_id = "member" # Only member type is allowed for postgresql
112+
memory {
113+
allocation_mb = var.member_memory_mb
114+
}
115+
disk {
116+
allocation_mb = var.member_disk_mb
117+
}
118+
cpu {
119+
allocation_count = var.member_cpu_count
120+
}
121+
dynamic "members" {
122+
for_each = var.remote_leader_crn == null ? [1] : []
123+
content {
124+
allocation_count = var.members
125+
}
97126
}
98127
}
99128
}

modules/fscloud/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ The IBM Cloud Framework for Financial Services mandates the application of an in
1414
| Name | Version |
1515
|------|---------|
1616
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0, <1.7.0 |
17-
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >=1.61.0, <2.0.0 |
17+
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >=1.62.0, <2.0.0 |
1818

1919
### Modules
2020

@@ -40,6 +40,7 @@ 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-postgresql?topic=databases-for-postgresql-resources-scaling | `number` | `3` | 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-postgresql?topic=databases-for-postgresql-resources-scaling | `number` | `5120` | no |
43+
| <a name="input_member_host_flavor"></a> [member\_host\_flavor](#input\_member\_host\_flavor) | Allocated host flavor per member. For more information, see https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/database#host_flavor | `string` | `null` | no |
4344
| <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-postgresql?topic=databases-for-postgresql-resources-scaling | `number` | `1024` | 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 |
4546
| <a name="input_name"></a> [name](#input\_name) | The name to give the Postgresql instance. | `string` | n/a | yes |

0 commit comments

Comments
 (0)