Skip to content

Commit 39b7daf

Browse files
shemauSteve Peggs
andauthored
chore: make variables files more consistent (#455)
Co-authored-by: Steve Peggs <peggs@uk.ibm.com>
1 parent 404a5af commit 39b7daf

File tree

3 files changed

+95
-128
lines changed

3 files changed

+95
-128
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@ To attach access management tags to resources in this module, you need the follo
101101
| <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 |
102102
| <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 |
103103
| <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 |
104-
| <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` | `4096` | no |
104+
| <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` | `4096` | no |
105105
| <a name="input_members"></a> [members](#input\_members) | Allocated number of members. Members can be scaled up but not down. | `number` | `2` | no |
106106
| <a name="input_name"></a> [name](#input\_name) | The name to give the Postgresql instance. | `string` | n/a | yes |
107-
| <a name="input_pg_version"></a> [pg\_version](#input\_pg\_version) | Version of the PostgreSQL instance to provision. If no value is passed, the current preferred version of IBM Cloud Databases is used. | `string` | `null` | no |
107+
| <a name="input_pg_version"></a> [pg\_version](#input\_pg\_version) | Version of the PostgreSQL instance. If no value is passed, the current preferred version of IBM Cloud Databases is used. | `string` | `null` | no |
108108
| <a name="input_pitr_id"></a> [pitr\_id](#input\_pitr\_id) | (Optional) The ID of the source deployment PostgreSQL instance that you want to recover back to. The PostgreSQL instance is expected to be in an up and in running state. | `string` | `null` | no |
109109
| <a name="input_pitr_time"></a> [pitr\_time](#input\_pitr\_time) | (Optional) The timestamp in UTC format (%Y-%m-%dT%H:%M:%SZ) for any time in the last 7 days that you want to restore to. To retrieve the timestamp, run the command (ibmcloud cdb postgresql earliest-pitr-timestamp <deployment name or CRN>). For more info on Point-in-time Recovery, see https://cloud.ibm.com/docs/databases-for-postgresql?topic=databases-for-postgresql-pitr | `string` | `null` | no |
110110
| <a name="input_region"></a> [region](#input\_region) | The region where you want to deploy your instance. | `string` | `"us-south"` | no |

modules/fscloud/variables.tf

Lines changed: 54 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ variable "name" {
1212
description = "The name to give the Postgresql instance."
1313
}
1414

15-
variable "existing_kms_instance_guid" {
16-
description = "The GUID of the Hyper Protect Crypto Services instance."
17-
type = string
18-
}
19-
2015
variable "pg_version" {
2116
description = "Version of the PostgreSQL instance. If no value is passed, the current preferred version of IBM Cloud Databases is used."
2217
type = string
@@ -29,16 +24,13 @@ variable "region" {
2924
default = "us-south"
3025
}
3126

32-
variable "member_memory_mb" {
33-
type = number
34-
description = "Allocated memory per member. For more information, see https://cloud.ibm.com/docs/databases-for-postgresql?topic=databases-for-postgresql-resources-scaling"
35-
default = 4096
36-
}
37-
38-
variable "member_disk_mb" {
27+
##############################################################################
28+
# ICD hosting model properties
29+
##############################################################################
30+
variable "members" {
3931
type = number
40-
description = "Allocated disk per member. For more information, see https://cloud.ibm.com/docs/databases-for-postgresql?topic=databases-for-postgresql-resources-scaling"
41-
default = 5120
32+
description = "Allocated number of members. Members can be scaled up but not down."
33+
default = 2
4234
}
4335

4436
variable "member_cpu_count" {
@@ -47,12 +39,24 @@ variable "member_cpu_count" {
4739
default = 3
4840
}
4941

42+
variable "member_disk_mb" {
43+
type = number
44+
description = "Allocated disk per member. For more information, see https://cloud.ibm.com/docs/databases-for-postgresql?topic=databases-for-postgresql-resources-scaling"
45+
default = 5120
46+
}
47+
5048
variable "member_host_flavor" {
5149
type = string
5250
description = "Allocated host flavor per member. For more information, see https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/database#host_flavor"
5351
default = null
5452
}
5553

54+
variable "member_memory_mb" {
55+
type = number
56+
description = "Allocated memory per member. For more information, see https://cloud.ibm.com/docs/databases-for-postgresql?topic=databases-for-postgresql-resources-scaling"
57+
default = 4096
58+
}
59+
5660
variable "admin_pass" {
5761
type = string
5862
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."
@@ -83,12 +87,6 @@ variable "service_credential_names" {
8387
}
8488
}
8589

86-
variable "members" {
87-
type = number
88-
description = "Allocated number of members. Members can be scaled up but not down."
89-
default = 2
90-
}
91-
9290
variable "resource_tags" {
9391
type = list(string)
9492
description = "Optional list of tags to be added to the PostgreSQL instance."
@@ -125,76 +123,11 @@ variable "configuration" {
125123
max_wal_senders = optional(number)
126124
})
127125
default = null
128-
129-
# uncomment below validation when max_locks_per_transaction provider bug is resolved
130-
# validation {
131-
# condition = var.configuration != null ? (var.configuration["max_locks_per_transaction"] != null ? var.configuration["max_locks_per_transaction"] >= 10 : true) : true
132-
# error_message = "Value for `configuration[\"max_locks_per_transaction\"]` must be 10 or more, if specified."
133-
# }
134-
135-
validation {
136-
condition = var.configuration != null ? (var.configuration["synchronous_commit"] != null ? contains(["local", "on", "off"], var.configuration["synchronous_commit"]) : true) : true
137-
error_message = "Value for `configuration[\"synchronous_commit\"]` must be one of `local`, `on`, or `off`, if specified."
138-
}
139-
140-
validation {
141-
condition = var.configuration != null ? (var.configuration["deadlock_timeout"] != null ? var.configuration["deadlock_timeout"] >= 100 : true) : true
142-
error_message = "Value for `configuration[\"deadlock_timeout\"]` must be 100 or more, if specified."
143-
}
144-
145-
validation {
146-
condition = var.configuration != null ? (var.configuration["log_connections"] != null ? contains(["on", "off"], var.configuration["log_connections"]) : true) : true
147-
error_message = "Value for `configuration[\"log_connections\"]` must be either `on` or `off`, if specified."
148-
}
149-
150-
validation {
151-
condition = var.configuration != null ? (var.configuration["log_disconnections"] != null ? contains(["on", "off"], var.configuration["log_disconnections"]) : true) : true
152-
error_message = "Value for `configuration[\"log_disconnections\"]` must be either `on` or `off`, if specified."
153-
}
154-
155-
validation {
156-
condition = var.configuration != null ? (var.configuration["log_min_duration_statement"] != null ? var.configuration["log_min_duration_statement"] >= 100 : true) : true
157-
error_message = "Value for `configuration[\"log_min_duration_statement\"]` must be 100 or more, if specified."
158-
}
159-
160-
validation {
161-
condition = var.configuration != null ? (var.configuration["archive_timeout"] != null ? var.configuration["archive_timeout"] >= 300 : true) : true
162-
error_message = "Value for `configuration[\"archive_timeout\"]` must be 300 or more, if specified."
163-
}
164-
165-
validation {
166-
condition = var.configuration != null ? (var.configuration["wal_level"] != null ? contains(["hot_standby", "logical"], var.configuration["wal_level"]) : true) : true
167-
error_message = "Value for `configuration[\"wal_level\"]` must be either `hot_standby` or `logical`, if specified."
168-
}
169-
170-
validation {
171-
condition = var.configuration != null ? (var.configuration["max_replication_slots"] != null ? var.configuration["max_replication_slots"] >= 10 : true) : true
172-
error_message = "Value for `configuration[\"max_replication_slots\"]` must be 10 or more, if specified."
173-
}
174-
175-
validation {
176-
condition = var.configuration != null ? (var.configuration["max_wal_senders"] != null ? var.configuration["max_wal_senders"] >= 12 : true) : true
177-
error_message = "Value for `configuration[\"max_wal_senders\"]` must be 12 or more, if specified."
178-
}
179126
}
180127

181-
variable "kms_key_crn" {
182-
type = string
183-
description = "The root key CRN of the Hyper Protect Crypto Service (HPCS) to use for disk encryption."
184-
}
185-
186-
variable "backup_encryption_key_crn" {
187-
type = string
188-
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"
189-
default = null
190-
# Validation happens in the root module
191-
}
192-
193-
variable "skip_iam_authorization_policy" {
194-
type = bool
195-
description = "Set to true to skip the creation of an IAM authorization policy that permits all PostgreSQL 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."
196-
default = false
197-
}
128+
##############################################################
129+
# Auto Scaling
130+
##############################################################
198131

199132
variable "auto_scaling" {
200133
type = object({
@@ -223,10 +156,31 @@ variable "auto_scaling" {
223156
default = null
224157
}
225158

226-
variable "backup_crn" {
159+
##############################################################
160+
# Encryption
161+
##############################################################
162+
163+
variable "kms_key_crn" {
227164
type = string
228-
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."
165+
description = "The root key CRN of the Hyper Protect Crypto Service (HPCS) to use for disk encryption."
166+
}
167+
168+
variable "backup_encryption_key_crn" {
169+
type = string
170+
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"
229171
default = null
172+
# Validation happens in the root module
173+
}
174+
175+
variable "skip_iam_authorization_policy" {
176+
type = bool
177+
description = "Set to true to skip the creation of an IAM authorization policy that permits all PostgreSQL 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."
178+
default = false
179+
}
180+
181+
variable "existing_kms_instance_guid" {
182+
description = "The GUID of the Hyper Protect Crypto Services instance."
183+
type = string
230184
}
231185

232186
##############################################################
@@ -248,3 +202,13 @@ variable "cbr_rules" {
248202
default = []
249203
# Validation happens in the rule module
250204
}
205+
206+
##############################################################
207+
# Backup
208+
##############################################################
209+
210+
variable "backup_crn" {
211+
type = string
212+
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."
213+
default = null
214+
}

variables.tf

Lines changed: 39 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ variable "remote_leader_crn" {
1919
}
2020

2121
variable "pg_version" {
22-
description = "Version of the PostgreSQL instance to provision. If no value is passed, the current preferred version of IBM Cloud Databases is used."
22+
description = "Version of the PostgreSQL instance. If no value is passed, the current preferred version of IBM Cloud Databases is used."
2323
type = string
2424
default = null
2525
validation {
@@ -40,24 +40,27 @@ variable "region" {
4040
default = "us-south"
4141
}
4242

43-
variable "member_memory_mb" {
43+
##############################################################################
44+
# ICD hosting model properties
45+
##############################################################################
46+
variable "members" {
4447
type = number
45-
description = "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"
46-
default = 4096
48+
description = "Allocated number of members. Members can be scaled up but not down."
49+
default = 2
4750
# Validation is done in the Terraform plan phase by the IBM provider, so no need to add extra validation here.
4851
}
4952

50-
variable "member_disk_mb" {
53+
variable "member_cpu_count" {
5154
type = number
52-
description = "Allocated disk per member. For more information, see https://cloud.ibm.com/docs/databases-for-postgresql?topic=databases-for-postgresql-resources-scaling"
53-
default = 5120
55+
description = "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"
56+
default = 0
5457
# Validation is done in the Terraform plan phase by the IBM provider, so no need to add extra validation here.
5558
}
5659

57-
variable "member_cpu_count" {
60+
variable "member_disk_mb" {
5861
type = number
59-
description = "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"
60-
default = 0
62+
description = "Allocated disk per member. For more information, see https://cloud.ibm.com/docs/databases-for-postgresql?topic=databases-for-postgresql-resources-scaling"
63+
default = 5120
6164
# Validation is done in the Terraform plan phase by the IBM provider, so no need to add extra validation here.
6265
}
6366

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

74+
variable "member_memory_mb" {
75+
type = number
76+
description = "Allocated memory per member. For more information, see https://cloud.ibm.com/docs/databases-for-postgresql?topic=databases-for-postgresql-resources-scaling"
77+
default = 4096
78+
# Validation is done in the Terraform plan phase by the IBM provider, so no need to add extra validation here.
79+
}
80+
81+
variable "admin_pass" {
82+
type = string
83+
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."
84+
default = null
85+
sensitive = true
86+
}
87+
88+
variable "users" {
89+
type = list(object({
90+
name = string
91+
password = string # pragma: allowlist secret
92+
type = string # "type" is required to generate the connection string for the outputs.
93+
role = optional(string)
94+
}))
95+
default = []
96+
sensitive = true
97+
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 Postgres instance. This blocks creates native postgres database users, more info on that can be found here https://cloud.ibm.com/docs/databases-for-postgresql?topic=databases-for-postgresql-user-management&interface=ui"
98+
}
99+
71100
variable "service_credential_names" {
72101
description = "Map of name, role for service credentials that you want to create for the database"
73102
type = map(string)
@@ -79,13 +108,6 @@ variable "service_credential_names" {
79108
}
80109
}
81110

82-
variable "members" {
83-
type = number
84-
description = "Allocated number of members. Members can be scaled up but not down."
85-
default = 2
86-
# Validation is done in the Terraform plan phase by the IBM provider, so no need to add extra validation here.
87-
}
88-
89111
variable "service_endpoints" {
90112
type = string
91113
description = "Specify whether you want to enable the public, private, or both service endpoints. Supported values are 'public', 'private', or 'public-and-private'."
@@ -192,25 +214,6 @@ variable "configuration" {
192214
}
193215
}
194216

195-
variable "admin_pass" {
196-
type = string
197-
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."
198-
default = null
199-
sensitive = true
200-
}
201-
202-
variable "users" {
203-
type = list(object({
204-
name = string
205-
password = string # pragma: allowlist secret
206-
type = string # "type" is required to generate the connection string for the outputs.
207-
role = optional(string)
208-
}))
209-
default = []
210-
sensitive = true
211-
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 Postgres instance. This blocks creates native postgres database users, more info on that can be found here https://cloud.ibm.com/docs/databases-for-postgresql?topic=databases-for-postgresql-user-management&interface=ui"
212-
}
213-
214217
##############################################################
215218
# Auto Scaling
216219
##############################################################

0 commit comments

Comments
 (0)