Skip to content

fix: remove legacy hosting model #618

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ To attach access management tags to resources in this module, you need the follo
| <a name="input_kms_key_crn"></a> [kms\_key\_crn](#input\_kms\_key\_crn) | The CRN of a Key Protect or Hyper Protect Crypto Services encryption key to encrypt your data. Applies only if `use_ibm_owned_encryption_key` is false. By default this key is used for both deployment data and backups, but this behaviour can be altered using the `use_same_kms_key_for_backups` and `backup_encryption_key_crn` inputs. Bare in mind that backups encryption is only available in certain regions. See [Bring your own key for backups](https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-key-protect&interface=ui#key-byok) and [Using the HPCS Key for Backup encryption](https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-hpcs#use-hpcs-backups). | `string` | `null` | no |
| <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. [Learn more](https://cloud.ibm.com/docs/databases-for-postgresql?topic=databases-for-postgresql-resources-scaling). Ignored during restore and point in time recovery operations | `number` | `0` | no |
| <a name="input_member_disk_mb"></a> [member\_disk\_mb](#input\_member\_disk\_mb) | Allocated disk per member. [Learn more](https://cloud.ibm.com/docs/databases-for-postgresql?topic=databases-for-postgresql-resources-scaling). Ignored during restore and point in time recovery operations | `number` | `5120` | no |
| <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). Ignored during restore and point in time recovery operations | `string` | `null` | no |
| <a name="input_member_host_flavor"></a> [member\_host\_flavor](#input\_member\_host\_flavor) | The host flavor per member. [Learn more](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/database#host_flavor). | `string` | `"multitenant"` | no |
| <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-postgresql?topic=databases-for-postgresql-resources-scaling). Ignored during restore and point in time recovery operations | `number` | `4096` | no |
| <a name="input_members"></a> [members](#input\_members) | Allocated number of members. Members can be scaled up but not down. | `number` | `2` | no |
| <a name="input_name"></a> [name](#input\_name) | The name to give the Postgresql instance. | `string` | n/a | yes |
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module "database" {
tags = var.resource_tags
access_tags = var.access_tags
service_endpoints = var.service_endpoints
member_host_flavor = var.member_host_flavor
member_host_flavor = "multitenant"
service_credential_names = {
"postgresql_admin" : "Administrator",
"postgresql_operator" : "Operator",
Expand Down
6 changes: 0 additions & 6 deletions examples/basic/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@ variable "read_only_replicas_count" {
}
}

variable "member_host_flavor" {
type = string
description = "Allocated host flavor per member. For more information, see https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/database#host_flavor"
default = null
}

variable "service_endpoints" {
type = string
description = "The type of endpoint of the database instance. Possible values: `public`, `private`, `public-and-private`."
Expand Down
35 changes: 33 additions & 2 deletions ibm_catalog.json
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@
{
"displayname": "preferred",
"value": "__NULL__"
},
},
{
"displayname": "13",
"value": "13"
Expand Down Expand Up @@ -233,7 +233,38 @@
"key": "member_disk_mb"
},
{
"key": "member_host_flavor"
"key": "member_host_flavor",
"default_value": "multitenant",
"options": [
{
"displayname": "multitenant (Shared)",
"value": "multitenant"
},
{
"displayname": "XS 4x16",
"value": "b3c.4x16.encrypted"
},
{
"displayname": "S 8x32",
"value": "b3c.8x32.encrypted"
},
{
"displayname": "S+ 16x64",
"value": "m3c.8x64.encrypted"
},
{
"displayname": "M 16x64",
"value": "b3c.16x64.encrypted"
},
{
"displayname": "L 32x128",
"value": "b3c.32x128.encrypted"
},
{
"displayname": "XL 30x240",
"value": "m3c.30x240.encrypted"
}
]
},
{
"key": "configuration"
Expand Down
32 changes: 3 additions & 29 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ locals {
# Determine if auto scaling is enabled
auto_scaling_enabled = var.auto_scaling == null ? [] : [1]

# Determine if host_flavor is used
host_flavor_set = var.member_host_flavor != null ? true : false

# Determine if restore, from backup or point in time recovery
recovery_mode = var.backup_crn != null || var.pitr_id != null
}
Expand Down Expand Up @@ -212,10 +209,10 @@ resource "ibm_database" "postgresql_db" {
# or point in time recovery

## This for_each block is NOT a loop to attach to multiple group blocks.
## This is used to conditionally add one, OR, the other group block depending on var.local.host_flavor_set
## This is used to conditionally add one, OR, the other group block depending on var.member_host_flavor
## This block is for if host_flavor IS set to specific pre-defined host sizes and not set to "multitenant"
dynamic "group" {
for_each = local.host_flavor_set && var.member_host_flavor != "multitenant" && !local.recovery_mode ? [1] : []
for_each = var.member_host_flavor != "multitenant" && !local.recovery_mode ? [1] : []
content {
group_id = "member" # Only member type is allowed for IBM Cloud Databases
host_flavor {
Expand All @@ -235,7 +232,7 @@ resource "ibm_database" "postgresql_db" {

## This block is for if host_flavor IS set to "multitenant"
dynamic "group" {
for_each = local.host_flavor_set && var.member_host_flavor == "multitenant" && !local.recovery_mode ? [1] : []
for_each = var.member_host_flavor == "multitenant" && !local.recovery_mode ? [1] : []
content {
group_id = "member" # Only member type is allowed for IBM Cloud Databases
host_flavor {
Expand All @@ -259,29 +256,6 @@ resource "ibm_database" "postgresql_db" {
}
}

## This block is for if host_flavor IS NOT set
dynamic "group" {
for_each = local.host_flavor_set == false && !local.recovery_mode ? [1] : []
content {
group_id = "member" # Only member type is allowed for IBM Cloud Databases
memory {
allocation_mb = var.member_memory_mb
}
disk {
allocation_mb = var.member_disk_mb
}
cpu {
allocation_count = var.member_cpu_count
}
dynamic "members" {
for_each = var.remote_leader_crn == null ? [1] : []
content {
allocation_count = var.members
}
}
}
}

## This for_each block is NOT a loop to attach to multiple auto_scaling blocks.
## This block is only used to conditionally add auto_scaling block depending on var.auto_scaling
dynamic "auto_scaling" {
Expand Down
2 changes: 1 addition & 1 deletion modules/fscloud/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ No resources.
| <a name="input_kms_key_crn"></a> [kms\_key\_crn](#input\_kms\_key\_crn) | The CRN of a Key Protect or Hyper Protect Crypto Services encryption key to encrypt your data. Applies only if `use_ibm_owned_encryption_key` is false. By default this key is used for both deployment data and backups, but this behaviour can be altered using the `use_same_kms_key_for_backups` and `backup_encryption_key_crn` inputs. Bare in mind that backups encryption is only available in certain regions. See [Bring your own key for backups](https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-key-protect&interface=ui#key-byok) and [Using the HPCS Key for Backup encryption](https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-hpcs#use-hpcs-backups). | `string` | `null` | no |
| <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. [Learn more](https://cloud.ibm.com/docs/databases-for-postgresql?topic=databases-for-postgresql-resources-scaling) | `number` | `3` | no |
| <a name="input_member_disk_mb"></a> [member\_disk\_mb](#input\_member\_disk\_mb) | Allocated disk per member. [Learn more](https://cloud.ibm.com/docs/databases-for-postgresql?topic=databases-for-postgresql-resources-scaling) | `number` | `5120` | no |
| <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 |
| <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` | `"multitenant"` | no |
| <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-postgresql?topic=databases-for-postgresql-resources-scaling) | `number` | `4096` | no |
| <a name="input_members"></a> [members](#input\_members) | Allocated number of members. Members can be scaled up but not down. | `number` | `2` | no |
| <a name="input_name"></a> [name](#input\_name) | The name to give the Postgresql instance. | `string` | n/a | yes |
Expand Down
2 changes: 1 addition & 1 deletion modules/fscloud/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ variable "member_disk_mb" {
variable "member_host_flavor" {
type = string
description = "Allocated host flavor per member. [Learn more](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/database#host_flavor)"
default = null
default = "multitenant"
}

variable "member_memory_mb" {
Expand Down
9 changes: 3 additions & 6 deletions tests/other_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,16 @@ func TestRunCompleteExample(t *testing.T) {
assert.NotNil(t, output, "Expected some output")
}

func TestRunBasicExampleWithFlavorMultitenant(t *testing.T) {
func TestRunBasicExample(t *testing.T) {
t.Parallel()

options := testhelper.TestOptionsDefaultWithVars(&testhelper.TestOptions{
Testing: t,
TerraformDir: "examples/basic",
Prefix: "pg-flvr-multitenant",
Prefix: "pg-basic",
BestRegionYAMLPath: regionSelectionPath,
ResourceGroup: resourceGroup,
TerraformVars: map[string]interface{}{
"member_host_flavor": "multitenant",
},
CloudInfoService: sharedInfoSvc,
CloudInfoService: sharedInfoSvc,
})

output, err := options.RunTestConsistency()
Expand Down
10 changes: 7 additions & 3 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,13 @@ variable "member_disk_mb" {

variable "member_host_flavor" {
type = string
description = "Allocated host flavor per member. [Learn more](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/database#host_flavor). Ignored during restore and point in time recovery operations"
default = null
# Validation is done in the Terraform plan phase by the IBM provider, so no need to add extra validation here.
description = "The host flavor per member. [Learn more](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/database#host_flavor)."
default = "multitenant"
# Prevent null or "", require multitenant or a machine type
validation {
condition = (length(var.member_host_flavor) > 0)
error_message = "Member host flavor must be specified. [Learn more](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/database#host_flavor)."
}
}

variable "member_memory_mb" {
Expand Down