Skip to content
This repository was archived by the owner on Jun 17, 2025. It is now read-only.

Commit 2298204

Browse files
shemauSteve Peggs
andauthored
chore: make variables files more consistent (#233)
Co-authored-by: Steve Peggs <[email protected]>
1 parent fc4d420 commit 2298204

File tree

2 files changed

+108
-92
lines changed

2 files changed

+108
-92
lines changed

modules/fscloud/variables.tf

Lines changed: 70 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ variable "name" {
1212
description = "The name given to the Enterprise DB instance."
1313
}
1414

15-
variable "existing_kms_instance_guid" {
16-
description = "The GUID of the Hyper Protect Crypto Services instance."
17-
type = string
18-
}
15+
1916

2017
variable "edb_version" {
2118
description = "Version of the Enterprise DB instance. If no value is passed, the current preferred version of IBM Cloud Databases is used."
@@ -29,10 +26,23 @@ variable "region" {
2926
default = "us-south"
3027
}
3128

32-
variable "member_memory_mb" {
29+
##############################################################################
30+
# ICD hosting model properties
31+
##############################################################################
32+
variable "members" {
3333
type = number
34-
description = "Allocated memory per member. For more information, see https://cloud.ibm.com/docs/databases-for-enterprisedb?topic=databases-for-enterprisedb-resources-scaling"
35-
default = 4096
34+
description = "Allocated number of members. Members can be scaled up but not down."
35+
default = 3
36+
validation {
37+
condition = var.members >= 3 && var.members <= 20
38+
error_message = "Members count must be between 3 and 20(inclusive)"
39+
}
40+
}
41+
42+
variable "member_cpu_count" {
43+
type = number
44+
description = "Allocated dedicated CPU per member. Minimum number of CPU allowed is 3 . For more information, see https://cloud.ibm.com/docs/databases-for-enterprisedb?topic=databases-for-enterprisedb-resources-scaling"
45+
default = 3
3646
}
3747

3848
variable "member_disk_mb" {
@@ -41,17 +51,35 @@ variable "member_disk_mb" {
4151
default = 20480
4252
}
4353

44-
variable "member_cpu_count" {
54+
variable "member_host_flavor" {
55+
type = string
56+
description = "Allocated host flavor per member. [Learn more](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/database#host_flavor)."
57+
default = null
58+
}
59+
60+
variable "member_memory_mb" {
4561
type = number
46-
description = "Allocated dedicated CPU per member. Minimum number of CPU allowed is 3 . For more information, see https://cloud.ibm.com/docs/databases-for-enterprisedb?topic=databases-for-enterprisedb-resources-scaling"
47-
default = 3
62+
description = "Allocated memory per member. For more information, see https://cloud.ibm.com/docs/databases-for-enterprisedb?topic=databases-for-enterprisedb-resources-scaling"
63+
default = 4096
4864
}
4965

50-
variable "member_host_flavor" {
66+
variable "admin_pass" {
5167
type = string
52-
description = "Allocated host flavor per member. [Learn more](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/database#host_flavor)."
68+
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."
5369
default = null
54-
# Validation is done in the Terraform plan phase by the IBM provider, so no need to add extra validation here.
70+
sensitive = true
71+
}
72+
73+
variable "users" {
74+
type = list(object({
75+
name = string
76+
password = string # pragma: allowlist secret
77+
type = string # "type" is required to generate the connection string for the outputs.
78+
role = optional(string)
79+
}))
80+
default = []
81+
sensitive = true
82+
description = "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 Enterprise Db instance. This blocks creates native enterprise database users, more info on that can be found here https://cloud.ibm.com/docs/databases-for-enterprisedb?topic=databases-for-enterprisedb-user-management&interface=api"
5583
}
5684

5785
variable "service_credential_names" {
@@ -65,16 +93,6 @@ variable "service_credential_names" {
6593
}
6694
}
6795

68-
variable "members" {
69-
type = number
70-
description = "Allocated number of members. Members can be scaled up but not down."
71-
default = 3
72-
validation {
73-
condition = var.members >= 3 && var.members <= 20
74-
error_message = "Members count must be between 3 and 20(inclusive)"
75-
}
76-
}
77-
7896
variable "resource_tags" {
7997
type = list(string)
8098
description = "Optional list of tags to be added to the Enterprise DB instance."
@@ -105,16 +123,9 @@ variable "configuration" {
105123
default = null
106124
}
107125

108-
variable "kms_key_crn" {
109-
type = string
110-
description = "The root key CRN of the Hyper Protect Crypto Service (HPCS) to use for disk encryption."
111-
}
112-
113-
variable "skip_iam_authorization_policy" {
114-
type = bool
115-
description = "Set to true to skip the creation of an IAM authorization policy that permits all Enterprise database 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."
116-
default = false
117-
}
126+
##############################################################
127+
# Auto Scaling
128+
##############################################################
118129

119130
variable "auto_scaling" {
120131
type = object({
@@ -143,29 +154,13 @@ variable "auto_scaling" {
143154
default = null
144155
}
145156

146-
variable "admin_pass" {
147-
type = string
148-
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."
149-
sensitive = true
150-
default = null
151-
}
152-
153-
variable "users" {
154-
type = list(object({
155-
name = string
156-
password = string # pragma: allowlist secret
157-
type = string # "type" is required to generate the connection string for the outputs.
158-
role = optional(string)
159-
}))
160-
default = []
161-
sensitive = true
162-
description = "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 Enterprise Db instance. This blocks creates native enterprise database users, more info on that can be found here https://cloud.ibm.com/docs/databases-for-enterprisedb?topic=databases-for-enterprisedb-user-management&interface=api"
163-
}
157+
##############################################################
158+
# Encryption
159+
##############################################################
164160

165-
variable "backup_crn" {
161+
variable "kms_key_crn" {
166162
type = string
167-
description = "The CRN of a backup resource to restore from. The backup is created by a database deployment with the same service ID. The backup is loaded after provisioning and the new deployment starts up that uses that data. A backup CRN is in the format crn:v1:<…>:backup:. If omitted, the database is provisioned empty."
168-
default = null
163+
description = "The root key CRN of the Hyper Protect Crypto Service (HPCS) to use for disk encryption."
169164
}
170165

171166
variable "backup_encryption_key_crn" {
@@ -175,6 +170,17 @@ variable "backup_encryption_key_crn" {
175170
# Validation happens in the root module
176171
}
177172

173+
variable "skip_iam_authorization_policy" {
174+
type = bool
175+
description = "Set to true to skip the creation of an IAM authorization policy that permits all Enterprise database 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."
176+
default = false
177+
}
178+
179+
variable "existing_kms_instance_guid" {
180+
description = "The GUID of the Hyper Protect Crypto Services instance."
181+
type = string
182+
}
183+
178184
##############################################################
179185
# Context-based restriction (CBR)
180186
##############################################################
@@ -194,3 +200,13 @@ variable "cbr_rules" {
194200
default = []
195201
# Validation happens in the rule module
196202
}
203+
204+
##############################################################
205+
# Backup
206+
##############################################################
207+
208+
variable "backup_crn" {
209+
type = string
210+
description = "The CRN of a backup resource to restore from. The backup is created by a database deployment with the same service ID. The backup is loaded after provisioning and the new deployment starts up that uses that data. A backup CRN is in the format crn:v1:<…>:backup:. If omitted, the database is provisioned empty."
211+
default = null
212+
}

variables.tf

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,27 @@ variable "region" {
3737
default = "us-south"
3838
}
3939

40-
variable "member_memory_mb" {
40+
##############################################################################
41+
# ICD hosting model properties
42+
##############################################################################
43+
variable "members" {
4144
type = number
42-
description = "Allocated memory per-member. See the following doc for supported values: https://cloud.ibm.com/docs/databases-for-enterprisedb?topic=databases-for-enterprisedb-resources-scaling"
43-
default = 4096
45+
description = "Allocated number of members. Members can be scaled up but not down."
46+
default = 3
4447
# Validation is done in the Terraform plan phase by the IBM provider, so no need to add extra validation here.
4548
}
4649

47-
variable "member_disk_mb" {
50+
variable "member_cpu_count" {
4851
type = number
49-
description = "Allocated disk per member. For more information, see https://cloud.ibm.com/docs/databases-for-enterprisedb?topic=databases-for-enterprisedb-resources-scaling"
50-
default = 20480
52+
description = "Allocated dedicated CPU per member. Minimum number of CPU allowed is 3. For more information, see https://cloud.ibm.com/docs/databases-for-enterprisedb?topic=databases-for-enterprisedb-resources-scaling"
53+
default = 3
5154
# Validation is done in the Terraform plan phase by the IBM provider, so no need to add extra validation here.
5255
}
5356

54-
variable "member_cpu_count" {
57+
variable "member_disk_mb" {
5558
type = number
56-
description = "Allocated dedicated CPU per member. Minimum number of CPU allowed is 3. For more information, see https://cloud.ibm.com/docs/databases-for-enterprisedb?topic=databases-for-enterprisedb-resources-scaling"
57-
default = 3
59+
description = "Allocated disk per member. For more information, see https://cloud.ibm.com/docs/databases-for-enterprisedb?topic=databases-for-enterprisedb-resources-scaling"
60+
default = 20480
5861
# Validation is done in the Terraform plan phase by the IBM provider, so no need to add extra validation here.
5962
}
6063

@@ -65,6 +68,32 @@ variable "member_host_flavor" {
6568
# Validation is done in the Terraform plan phase by the IBM provider, so no need to add extra validation here.
6669
}
6770

71+
variable "member_memory_mb" {
72+
type = number
73+
description = "Allocated memory per-member. See the following doc for supported values: https://cloud.ibm.com/docs/databases-for-enterprisedb?topic=databases-for-enterprisedb-resources-scaling"
74+
default = 4096
75+
# Validation is done in the Terraform plan phase by the IBM provider, so no need to add extra validation here.
76+
}
77+
78+
variable "admin_pass" {
79+
type = string
80+
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."
81+
default = null
82+
sensitive = true
83+
}
84+
85+
variable "users" {
86+
type = list(object({
87+
name = string
88+
password = string # pragma: allowlist secret
89+
type = string # "type" is required to generate the connection string for the outputs.
90+
role = optional(string)
91+
}))
92+
default = []
93+
sensitive = true
94+
description = "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 Enterprise Db instance. This blocks creates native enterprise database users, more info on that can be found here https://cloud.ibm.com/docs/databases-for-enterprisedb?topic=databases-for-enterprisedb-user-management&interface=api"
95+
}
96+
6897
variable "service_credential_names" {
6998
description = "Map of name, role for service credentials that you want to create for the database"
7099
type = map(string)
@@ -76,16 +105,6 @@ variable "service_credential_names" {
76105
}
77106
}
78107

79-
variable "members" {
80-
type = number
81-
description = "Allocated number of members. Members can be scaled up but not down."
82-
default = 3
83-
validation {
84-
condition = var.members >= 3 && var.members <= 20
85-
error_message = "Members count must be between 3 and 20(inclusive)"
86-
}
87-
}
88-
89108
variable "service_endpoints" {
90109
type = string
91110
description = "Specify whether you want to enable the public, private, or both service endpoints. Supported values are 'public', 'private', or 'public-and-private'."
@@ -133,25 +152,6 @@ variable "configuration" {
133152
default = null
134153
}
135154

136-
variable "admin_pass" {
137-
type = string
138-
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."
139-
sensitive = true
140-
default = null
141-
}
142-
143-
variable "users" {
144-
type = list(object({
145-
name = string
146-
password = string # pragma: allowlist secret
147-
type = string # "type" is required to generate the connection string for the outputs.
148-
role = optional(string)
149-
}))
150-
default = []
151-
sensitive = true
152-
description = "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 Enterprise Db instance. This blocks creates native enterprise database users, more info on that can be found here https://cloud.ibm.com/docs/databases-for-enterprisedb?topic=databases-for-enterprisedb-user-management&interface=api"
153-
}
154-
155155
##############################################################
156156
# Auto Scaling
157157
##############################################################

0 commit comments

Comments
 (0)