diff --git a/.secrets.baseline b/.secrets.baseline index 59dc9a41..c6279d80 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -3,7 +3,7 @@ "files": "go.sum|^.secrets.baseline$", "lines": null }, - "generated_at": "2024-01-20T16:07:13Z", + "generated_at": "2025-07-23T16:20:34Z", "plugins_used": [ { "name": "AWSKeyDetector" @@ -86,6 +86,24 @@ "type": "Secret Keyword", "verified_result": null } + ], + "solutions/fully-configurable/DA-types.md": [ + { + "hashed_secret": "44cdfc3615970ada14420caaaa5c5745fca06002", + "is_secret": false, + "is_verified": false, + "line_number": 125, + "type": "Secret Keyword", + "verified_result": null + }, + { + "hashed_secret": "bd0d0d73a240c29656fb8ae0dfa5f863077788dc", + "is_secret": false, + "is_verified": false, + "line_number": 130, + "type": "Secret Keyword", + "verified_result": null + } ] }, "version": "0.13.1+ibm.62.dss", diff --git a/README.md b/README.md index 75cbbb83..e64725db 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,7 @@ To attach access management tags to resources in this module, you need the follo | [cbr\_rules](#input\_cbr\_rules) | (Optional, list) List of CBR rules to create |
list(object({
description = string
account_id = string
rule_contexts = list(object({
attributes = optional(list(object({
name = string
value = string
}))) }))
enforcement_mode = string
tags = optional(list(object({
name = string
value = string
})))
}))
| `[]` | no | | [configuration](#input\_configuration) | Database configuration parameters, see https://cloud.ibm.com/docs/databases-for-mysql?topic=databases-for-mysql-changing-configuration&interface=api for more details. |
object({
default_authentication_plugin = optional(string) # sha256_password,caching_sha2_password,mysql_native_password
innodb_buffer_pool_size_percentage = optional(number) # 10 ≤ value ≤ 100
innodb_flush_log_at_trx_commit = optional(number) # 0 ≤ value ≤ 2
innodb_log_buffer_size = optional(number) # 1048576 ≤ value ≤ 4294967295
innodb_log_file_size = optional(number) # 4194304 ≤ value ≤ 274877906900
innodb_lru_scan_depth = optional(number) # 128 ≤ value ≤ 2048
innodb_read_io_threads = optional(number) # 1 ≤ value ≤ 64
innodb_write_io_threads = optional(number) # 1 ≤ value ≤ 64
max_allowed_packet = optional(number) # 1024 ≤ value ≤ 1073741824
max_connections = optional(number) # 100 ≤ value ≤ 200000
max_prepared_stmt_count = optional(number) # 0 ≤ value ≤ 4194304
mysql_max_binlog_age_sec = optional(number) # 300 ≤ value ≤ 1073741823 Default: 1800
net_read_timeout = optional(number) # 1 ≤ value ≤ 7200
net_write_timeout = optional(number) # 1 ≤ value ≤ 7200
sql_mode = optional(string) # The comma-separated list of SQL modes applied on this server globally
wait_timeout = optional(number) # 1 ≤ value ≤ 31536000
})
| `null` | no | | [cpu\_count](#input\_cpu\_count) | Allocated dedicated CPU per member. For shared CPU, set to 0. [Learn more](https://cloud.ibm.com/docs/databases-for-mysql?topic=databases-for-mysql-resources-scaling) | `number` | `0` | no | +| [deletion\_protection](#input\_deletion\_protection) | Enable deletion protection within terraform. This is not a property of the resource and does not prevent deletion outside of terraform. The database can not be deleted by terraform when this value is set to 'true'. In order to delete with terraform the value must be set to 'false' and a terraform apply performed before the destroy is performed. The default is 'true'. | `bool` | `true` | no | | [disk\_mb](#input\_disk\_mb) | Allocated disk per member. [Learn more](https://cloud.ibm.com/docs/databases-for-mysql?topic=databases-for-mysql-resources-scaling) | `number` | `10240` | no | | [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 | | [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 | @@ -137,10 +138,12 @@ To attach access management tags to resources in this module, you need the follo | [service\_endpoints](#input\_service\_endpoints) | Specify whether you want to enable the public, private, or both service endpoints. Supported values are 'public', 'private', or 'public-and-private'. | `string` | `"private"` | no | | [skip\_iam\_authorization\_policy](#input\_skip\_iam\_authorization\_policy) | Set to true to skip the creation of IAM authorization policies that permits all Databases for MySQL instances in the given resource group 'Reader' access to the Key Protect or Hyper Protect Crypto Services key that was provided in the `kms_key_crn` and `backup_encryption_key_crn` inputs. This policy is required in order to enable KMS encryption, so only skip creation if there is one already present in your account. No policy is created if `use_ibm_owned_encryption_key` is true. | `bool` | `false` | no | | [tags](#input\_tags) | Optional list of tags to be added to the MySQL instance. | `list(string)` | `[]` | no | +| [timeouts\_update](#input\_timeouts\_update) | A database update may require a longer timeout for the update to complete. The default is 120 minutes. Set this variable to change the `update` value in the `timeouts` block. [Learn more](https://developer.hashicorp.com/terraform/language/resources/syntax#operation-timeouts). | `string` | `"120m"` | no | | [use\_default\_backup\_encryption\_key](#input\_use\_default\_backup\_encryption\_key) | When `use_ibm_owned_encryption_key` is set to false, backups will be encrypted with either the key specified in `kms_key_crn`, or in `backup_encryption_key_crn` if a value is passed. If you do not want to use your own key for backups encryption, you can set this to `true` to use the IBM Cloud Databases default encryption for backups. Alternatively set `use_ibm_owned_encryption_key` to true to use the default encryption for both backups and deployment data. | `bool` | `false` | no | | [use\_ibm\_owned\_encryption\_key](#input\_use\_ibm\_owned\_encryption\_key) | IBM Cloud Databases will secure your deployment's data at rest automatically with an encryption key that IBM hold. Alternatively, you may select your own Key Management System instance and encryption key (Key Protect or Hyper Protect Crypto Services) by setting this to false. If setting to false, a value must be passed for the `kms_key_crn` input. | `bool` | `true` | no | | [use\_same\_kms\_key\_for\_backups](#input\_use\_same\_kms\_key\_for\_backups) | Set this to false if you wan't to use a different key that you own to encrypt backups. When set to false, a value is required for the `backup_encryption_key_crn` input. Alternatiely set `use_default_backup_encryption_key` to true to use the IBM Cloud Databases default encryption. Applies only if `use_ibm_owned_encryption_key` is false. 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). | `bool` | `true` | no | | [users](#input\_users) | 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 MySQL instance. These blocks creates native MySQL database users, more info on that can be found here https://cloud.ibm.com/docs/databases-for-mysql?topic=databases-for-mysql-user-management |
list(object({
name = string
password = string # pragma: allowlist secret
type = optional(string)
role = optional(string)
}))
| `[]` | no | +| [version\_upgrade\_skip\_backup](#input\_version\_upgrade\_skip\_backup) | Whether to skip taking a backup before upgrading the database version. Attention: Skipping a backup is not recommended. Skipping a backup before a version upgrade is dangerous and may result in data loss if the upgrade fails at any stage — there will be no immediate backup to restore from. | `bool` | `false` | no | ### Outputs diff --git a/examples/backup/main.tf b/examples/backup/main.tf index 18c459d6..b67839ac 100644 --- a/examples/backup/main.tf +++ b/examples/backup/main.tf @@ -19,12 +19,13 @@ module "restored_mysql_db" { # remove the above line and uncomment the below 2 lines to consume the module from the registry # source = "terraform-ibm-modules/icd-mysql/ibm" # version = "X.Y.Z" # Replace "X.Y.Z" with a release version to lock into a specific release - resource_group_id = module.resource_group.resource_group_id - name = "${var.prefix}-mysql-restored" - mysql_version = var.mysql_version - region = var.region - tags = var.resource_tags - access_tags = var.access_tags - member_host_flavor = "multitenant" - backup_crn = data.ibm_database_backups.backup_database.backups[0].backup_id + resource_group_id = module.resource_group.resource_group_id + name = "${var.prefix}-mysql-restored" + mysql_version = var.mysql_version + region = var.region + tags = var.resource_tags + access_tags = var.access_tags + member_host_flavor = "multitenant" + deletion_protection = false + backup_crn = data.ibm_database_backups.backup_database.backups[0].backup_id } diff --git a/examples/basic/README.md b/examples/basic/README.md index 2498e795..ef939e7e 100644 --- a/examples/basic/README.md +++ b/examples/basic/README.md @@ -1,7 +1,7 @@ # Basic with read-only replica example -An end-to-end example that uses the module's default variable values. This example uses the IBM Cloud terraform provider to: +An end-to-end example that creates the following infrastructure: -- Create a new resource group if one is not passed in. -- Create a new ICD MySQL database instance. -- Create a read-only replica of the leader MySQL database instance. For more info on Read-only Replicas, see [Configuring Read-only Replicas](https://cloud.ibm.com/docs/databases-for-mysql?topic=databases-for-mysql-read-replicas) +- A resource group, if one is not passed in. +- An ICD MySQL database instance. +- A read-only replica of the leader MySQL database instance. For more info on Read-only Replicas, see [Configuring Read-only Replicas](https://cloud.ibm.com/docs/databases-for-mysql?topic=databases-for-mysql-read-replicas) diff --git a/examples/basic/main.tf b/examples/basic/main.tf index 7c9aa447..ea5870a6 100644 --- a/examples/basic/main.tf +++ b/examples/basic/main.tf @@ -19,14 +19,15 @@ module "database" { # remove the above line and uncomment the below 2 lines to consume the module from the registry # source = "terraform-ibm-modules/icd-mysql/ibm" # version = "X.Y.Z" # Replace "X.Y.Z" with a release version to lock into a specific release - resource_group_id = module.resource_group.resource_group_id - name = "${var.prefix}-mysql" - mysql_version = var.mysql_version - region = var.region - access_tags = var.access_tags - service_endpoints = var.service_endpoints - tags = var.resource_tags - member_host_flavor = var.member_host_flavor + resource_group_id = module.resource_group.resource_group_id + name = "${var.prefix}-mysql" + region = var.region + mysql_version = var.mysql_version + access_tags = var.access_tags + tags = var.resource_tags + service_endpoints = var.service_endpoints + member_host_flavor = var.member_host_flavor + deletion_protection = false service_credential_names = { "mysql_admin" : "Administrator", "mysql_operator" : "Operator", @@ -59,14 +60,15 @@ module "read_only_replica_mysql_db" { # remove the above line and uncomment the below 2 lines to consume the module from the registry # source = "terraform-ibm-modules/icd-mysql/ibm" # version = "X.Y.Z" # Replace "X.Y.Z" with a release version to lock into a specific release - resource_group_id = module.resource_group.resource_group_id - name = "${var.prefix}-read-only-replica-${count.index}" - region = var.region - tags = var.resource_tags - access_tags = var.access_tags - mysql_version = var.mysql_version - remote_leader_crn = module.database.crn - memory_mb = 12288 # Must be an increment of 384 megabytes. The minimum size of a read-only replica is 12 GB RAM - disk_mb = 10240 # Must be an increment of 512 megabytes. The minimum size of a read-only replica is 10 GB of disk - depends_on = [time_sleep.wait_time] + resource_group_id = module.resource_group.resource_group_id + name = "${var.prefix}-read-only-replica-${count.index}" + region = var.region + tags = var.resource_tags + access_tags = var.access_tags + mysql_version = var.mysql_version + deletion_protection = false + remote_leader_crn = module.database.crn + memory_mb = 12288 # Must be an increment of 384 megabytes. The minimum size of a read-only replica is 12 GB RAM + disk_mb = 10240 # Must be an increment of 512 megabytes. The minimum size of a read-only replica is 10 GB of disk + depends_on = [time_sleep.wait_time] } diff --git a/examples/basic/outputs.tf b/examples/basic/outputs.tf index 696da9a5..33114ab6 100644 --- a/examples/basic/outputs.tf +++ b/examples/basic/outputs.tf @@ -2,7 +2,7 @@ # Outputs ############################################################################## output "id" { - description = "MySQL instance id" + description = "Database instance id" value = module.database.id } diff --git a/examples/basic/variables.tf b/examples/basic/variables.tf index d2ed58da..d2e11f4b 100644 --- a/examples/basic/variables.tf +++ b/examples/basic/variables.tf @@ -6,7 +6,7 @@ variable "ibmcloud_api_key" { variable "region" { type = string - description = "Region to provision all resources created by this example." + description = "Region to provision all resources created by this example" default = "us-south" } @@ -16,27 +16,27 @@ variable "prefix" { default = "mysql" } -variable "mysql_version" { - description = "Version of the mysql instance. If no value passed, the current ICD preferred version is used." - type = string - default = null -} - variable "resource_group" { type = string description = "An existing resource group name to use for this example, if unset a new resource group will be created" default = null } -variable "resource_tags" { +variable "access_tags" { type = list(string) - description = "Optional list of tags to be added to created resources" + description = "A list of access tags to apply to the MySQL instance created by the module, see https://cloud.ibm.com/docs/account?topic=account-access-tags-tutorial for more details" default = [] } -variable "access_tags" { +variable "mysql_version" { + type = string + description = "Version of the mysql instance. If no value passed, the current ICD preferred version is used." + default = null +} + +variable "resource_tags" { type = list(string) - description = "A list of access tags to apply to the MySQL instance created by the module, see https://cloud.ibm.com/docs/account?topic=account-access-tags-tutorial for more details" + description = "Optional list of tags to be added to created resources" default = [] } @@ -52,6 +52,7 @@ variable "read_only_replicas_count" { error_message = "There is a limit of five read-only replicas per leader" } } + variable "service_endpoints" { type = string description = "The type of endpoint of the database instance. Possible values: `public`, `private`, `public-and-private`." @@ -62,6 +63,7 @@ variable "service_endpoints" { error_message = "Valid values for service_endpoints are 'public', 'public-and-private', and 'private'" } } + variable "member_host_flavor" { type = string description = "The host flavor per member. [Learn more](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/database#host_flavor)." diff --git a/examples/complete/main.tf b/examples/complete/main.tf index c662776d..34058750 100644 --- a/examples/complete/main.tf +++ b/examples/complete/main.tf @@ -106,12 +106,15 @@ module "mysql_db" { # remove the above line and uncomment the below 2 lines to consume the module from the registry # source = "terraform-ibm-modules/icd-mysql/ibm" # version = "X.Y.Z" # Replace "X.Y.Z" with a release version to lock into a specific release - resource_group_id = module.resource_group.resource_group_id - name = "${var.prefix}-mysql" - region = var.region - mysql_version = var.mysql_version - admin_pass = var.admin_pass - users = var.users + resource_group_id = module.resource_group.resource_group_id + name = "${var.prefix}-mysql" + region = var.region + mysql_version = var.mysql_version + admin_pass = var.admin_pass + users = var.users + access_tags = var.access_tags + tags = var.resource_tags + deletion_protection = false # Example of how to use different KMS keys for data and backups use_ibm_owned_encryption_key = false use_same_kms_key_for_backups = false @@ -123,8 +126,7 @@ module "mysql_db" { "mysql_viewer" : "Viewer", "mysql_editor" : "Editor", } - tags = var.resource_tags - access_tags = var.access_tags + member_host_flavor = "multitenant" cbr_rules = [ { diff --git a/examples/complete/outputs.tf b/examples/complete/outputs.tf index a354445f..50452730 100644 --- a/examples/complete/outputs.tf +++ b/examples/complete/outputs.tf @@ -1,19 +1,25 @@ ############################################################################## # Outputs ############################################################################## + output "id" { description = "MySQL instance id" value = module.mysql_db.id } +output "version" { + description = "MySQL instance version" + value = module.mysql_db.version +} + output "guid" { description = "MySQL instance guid" value = module.mysql_db.guid } -output "version" { - description = "MySQL instance version" - value = module.mysql_db.version +output "crn" { + description = "MySQL instance crn" + value = module.mysql_db.crn } output "service_credentials_json" { @@ -28,11 +34,6 @@ output "service_credentials_object" { sensitive = true } -output "cbr_rule_ids" { - description = "CBR rule ids created to restrict MySQL" - value = module.mysql_db.cbr_rule_ids -} - output "hostname" { description = "MySQL instance hostname" value = module.mysql_db.hostname @@ -42,3 +43,8 @@ output "port" { description = "MySQL instance port" value = module.mysql_db.port } + +output "cbr_rule_ids" { + description = "CBR rule ids created to restrict MySQL" + value = module.mysql_db.cbr_rule_ids +} diff --git a/examples/fscloud/main.tf b/examples/fscloud/main.tf index 9b0a6aab..ed7d5e01 100644 --- a/examples/fscloud/main.tf +++ b/examples/fscloud/main.tf @@ -61,6 +61,9 @@ module "mysql" { resource_group_id = module.resource_group.resource_group_id name = "${var.prefix}-mysql" region = var.region + tags = var.resource_tags + access_tags = var.access_tags + deletion_protection = false mysql_version = var.mysql_version kms_key_crn = var.kms_key_crn backup_encryption_key_crn = var.backup_encryption_key_crn @@ -81,8 +84,6 @@ module "mysql" { } } member_host_flavor = "b3c.4x16.encrypted" - tags = var.resource_tags - access_tags = var.access_tags cbr_rules = [ { description = "${var.prefix}-mysql access only from vpc" diff --git a/examples/fscloud/version.tf b/examples/fscloud/version.tf index 03d8bdf3..2b3b3466 100644 --- a/examples/fscloud/version.tf +++ b/examples/fscloud/version.tf @@ -4,7 +4,7 @@ terraform { # Use latest version of provider in non-basic examples to verify latest version works with module ibm = { source = "IBM-Cloud/ibm" - version = ">= 1.79.2" + version = ">=1.79.2" } } } diff --git a/examples/pitr/main.tf b/examples/pitr/main.tf index 79c6803d..9f39cd0e 100644 --- a/examples/pitr/main.tf +++ b/examples/pitr/main.tf @@ -16,13 +16,14 @@ module "mysql_db_pitr" { # remove the above line and uncomment the below 2 lines to consume the module from the registry # source = "terraform-ibm-modules/icd-mysql/ibm" # version = "X.Y.Z" # Replace "X.Y.Z" with a release version to lock into a specific release - resource_group_id = module.resource_group.resource_group_id - name = "${var.prefix}-mysql-pitr" - region = var.region - tags = var.resource_tags - access_tags = var.access_tags - mysql_version = var.mysql_version - pitr_id = var.pitr_id - pitr_time = var.pitr_time == "" ? " " : var.pitr_time - member_host_flavor = "multitenant" + resource_group_id = module.resource_group.resource_group_id + name = "${var.prefix}-mysql-pitr" + region = var.region + tags = var.resource_tags + access_tags = var.access_tags + deletion_protection = false + mysql_version = var.mysql_version + pitr_id = var.pitr_id + pitr_time = var.pitr_time == "" ? " " : var.pitr_time + member_host_flavor = "multitenant" } diff --git a/ibm_catalog.json b/ibm_catalog.json index 6b6eabc8..4847a60e 100644 --- a/ibm_catalog.json +++ b/ibm_catalog.json @@ -281,6 +281,15 @@ } ] }, + { + "key": "deletion_protection" + }, + { + "key": "timeouts_update" + }, + { + "key": "version_upgrade_skip_backup" + }, { "key": "service_credential_names" }, @@ -586,6 +595,12 @@ { "key": "configuration" }, + { + "key": "deletion_protection" + }, + { + "key": "timeouts_update" + }, { "key": "service_credential_names" }, diff --git a/main.tf b/main.tf index 88292acf..145af609 100644 --- a/main.tf +++ b/main.tf @@ -162,20 +162,22 @@ resource "time_sleep" "wait_for_backup_kms_authorization_policy" { ######################################################################################################################## resource "ibm_database" "mysql_db" { - depends_on = [time_sleep.wait_for_authorization_policy] - name = var.name - plan = "standard" # Only standard plan is available for mysql - location = var.region - service = "databases-for-mysql" - version = var.mysql_version - resource_group_id = var.resource_group_id - service_endpoints = var.service_endpoints - tags = var.tags - adminpassword = var.admin_pass - key_protect_key = var.kms_key_crn - backup_encryption_key_crn = local.backup_encryption_key_crn - backup_id = var.backup_crn - remote_leader_id = var.remote_leader_crn + depends_on = [time_sleep.wait_for_authorization_policy] + name = var.name + plan = "standard" # Only standard plan is available for mysql + location = var.region + service = "databases-for-mysql" + version = var.mysql_version + resource_group_id = var.resource_group_id + service_endpoints = var.service_endpoints + deletion_protection = var.deletion_protection + version_upgrade_skip_backup = var.version_upgrade_skip_backup + tags = var.tags + adminpassword = var.admin_pass + key_protect_key = var.kms_key_crn + backup_encryption_key_crn = local.backup_encryption_key_crn + backup_id = var.backup_crn + remote_leader_id = var.remote_leader_crn # remove elements with null values: see https://github.com/terraform-ibm-modules/terraform-ibm-icd-postgresql/issues/273 configuration = var.configuration != null ? jsonencode({ for k, v in var.configuration : k => v if v != null }) : null @@ -298,7 +300,6 @@ resource "ibm_database" "mysql_db" { lifecycle { ignore_changes = [ # Ignore changes to these because a change will destroy and recreate the instance - version, key_protect_key, backup_encryption_key_crn, ] @@ -306,7 +307,7 @@ resource "ibm_database" "mysql_db" { timeouts { create = "120m" # Extending provisioning time to 120 minutes - update = "120m" + update = var.timeouts_update delete = "15m" } } @@ -348,7 +349,7 @@ module "cbr_rule" { } ] }] - # There is only 1 operation type for Redis so it is not exposed as a configuration + # There is only 1 operation type for MySQL so it is not exposed as a configuration operations = [{ api_types = [ { diff --git a/modules/fscloud/README.md b/modules/fscloud/README.md index a3c08687..99dc6d7c 100644 --- a/modules/fscloud/README.md +++ b/modules/fscloud/README.md @@ -35,9 +35,10 @@ No resources. | [auto\_scaling](#input\_auto\_scaling) | Optional rules to allow the database to increase resources in response to usage. Only a single autoscaling block is allowed. Make sure you understand the effects of autoscaling, especially for production environments. See https://cloud.ibm.com/docs/databases-for-mysql?topic=databases-for-mysql-autoscaling-mysql&interface=ui in the IBM Cloud Docs. |
object({
disk = object({
capacity_enabled = optional(bool, false)
free_space_less_than_percent = optional(number, 10)
io_above_percent = optional(number, 90)
io_enabled = optional(bool, false)
io_over_period = optional(string, "15m")
rate_increase_percent = optional(number, 10)
rate_limit_mb_per_member = optional(number, 3670016)
rate_period_seconds = optional(number, 900)
rate_units = optional(string, "mb")
})
memory = object({
io_above_percent = optional(number, 90)
io_enabled = optional(bool, false)
io_over_period = optional(string, "15m")
rate_increase_percent = optional(number, 10)
rate_limit_mb_per_member = optional(number, 114688)
rate_period_seconds = optional(number, 900)
rate_units = optional(string, "mb")
})
})
| `null` | no | | [backup\_crn](#input\_backup\_crn) | 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. | `string` | `null` | no | | [backup\_encryption\_key\_crn](#input\_backup\_encryption\_key\_crn) | The CRN of a Key Protect or Hyper Protect Crypto Services encryption key that you want to use for encrypting the disk that holds deployment backups. Applies only if `use_ibm_owned_encryption_key` is false and `use_same_kms_key_for_backups` is false. If no value is passed, and `use_same_kms_key_for_backups` is true, the value of `kms_key_crn` is used. Alternatively set `use_default_backup_encryption_key` to true to use the IBM Cloud Databases default encryption. 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 | -| [cbr\_rules](#input\_cbr\_rules) | (Optional, list) List of CBR rules to create, if operations is not set it will default to api-type:data-plane |
list(object({
description = string
account_id = string
rule_contexts = list(object({
attributes = optional(list(object({
name = string
value = string
}))) }))
enforcement_mode = string
tags = optional(list(object({
name = string
value = string
})))
operations = optional(list(object({
api_types = list(object({
api_type_id = string
}))
})))
}))
| `[]` | no | +| [cbr\_rules](#input\_cbr\_rules) | (Optional, list) List of context-based restrictions rules to create. |
list(object({
description = string
account_id = string
rule_contexts = list(object({
attributes = optional(list(object({
name = string
value = string
}))) }))
enforcement_mode = string
tags = optional(list(object({
name = string
value = string
})))
operations = optional(list(object({
api_types = list(object({
api_type_id = string
}))
})))
}))
| `[]` | no | | [configuration](#input\_configuration) | Database configuration parameters, see https://cloud.ibm.com/docs/databases-for-mysql?topic=databases-for-mysql-changing-configuration&interface=api for more details. |
object({
default_authentication_plugin = optional(string) # sha256_password,caching_sha2_password,mysql_native_password
innodb_buffer_pool_size_percentage = optional(number) # 10 ≤ value ≤ 100
innodb_flush_log_at_trx_commit = optional(number) # 0 ≤ value ≤ 2
innodb_log_buffer_size = optional(number) # 1048576 ≤ value ≤ 4294967295
innodb_log_file_size = optional(number) # 4194304 ≤ value ≤ 274877906900
innodb_lru_scan_depth = optional(number) # 128 ≤ value ≤ 2048
innodb_read_io_threads = optional(number) # 1 ≤ value ≤ 64
innodb_write_io_threads = optional(number) # 1 ≤ value ≤ 64
max_allowed_packet = optional(number) # 1024 ≤ value ≤ 1073741824
max_connections = optional(number) # 100 ≤ value ≤ 200000
max_prepared_stmt_count = optional(number) # 0 ≤ value ≤ 4194304
mysql_max_binlog_age_sec = optional(number) # 300 ≤ value ≤ 1073741823 Default: 1800
net_read_timeout = optional(number) # 1 ≤ value ≤ 7200
net_write_timeout = optional(number) # 1 ≤ value ≤ 7200
sql_mode = optional(string) # The comma-separated list of SQL modes applied on this server globally.
wait_timeout = optional(number) # 1 ≤ value ≤ 31536000
})
| `null` | no | | [cpu\_count](#input\_cpu\_count) | Allocated dedicated CPU per member. For shared CPU, set to 0. For more information, see https://cloud.ibm.com/docs/databases-for-mysql?topic=databases-for-mysql-resources-scaling | `number` | `3` | no | +| [deletion\_protection](#input\_deletion\_protection) | Enable deletion protection within terraform. This is not a property of the resource and does not prevent deletion outside of terraform. The database can not be deleted by terraform when this value is set to 'true'. In order to delete with terraform the value must be set to 'false' and a terraform apply performed before the destroy is performed. The default is 'true'. | `bool` | `true` | no | | [disk\_mb](#input\_disk\_mb) | Allocated disk per member. For more information, see https://cloud.ibm.com/docs/databases-for-mysql?topic=databases-for-mysql-resources-scaling | `number` | `10240` | no | | [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 | | [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 | @@ -51,10 +52,12 @@ No resources. | [service\_credential\_names](#input\_service\_credential\_names) | Map of name, role for service credentials that you want to create for the database | `map(string)` | `{}` | no | | [skip\_iam\_authorization\_policy](#input\_skip\_iam\_authorization\_policy) | Set to true to skip the creation of IAM authorization policies that permits all Databases for MySQL instances in the given resource group 'Reader' access to the Key Protect or Hyper Protect Crypto Services key that was provided in the `kms_key_crn` and `backup_encryption_key_crn` inputs. This policy is required in order to enable KMS encryption, so only skip creation if there is one already present in your account. No policy is created if `use_ibm_owned_encryption_key` is true. | `bool` | `false` | no | | [tags](#input\_tags) | Optional list of tags to be added to the MySQL instance. | `list(string)` | `[]` | no | +| [timeouts\_update](#input\_timeouts\_update) | A database update may require a longer timeout for the update to complete. The default is 120 minutes. Set this variable to change the `update` value in the `timeouts` block. [Learn more](https://developer.hashicorp.com/terraform/language/resources/syntax#operation-timeouts). | `string` | `"120m"` | no | | [use\_default\_backup\_encryption\_key](#input\_use\_default\_backup\_encryption\_key) | When `use_ibm_owned_encryption_key` is set to false, backups will be encrypted with either the key specified in `kms_key_crn`, or in `backup_encryption_key_crn` if a value is passed. If you do not want to use your own key for backups encryption, you can set this to `true` to use the IBM Cloud Databases default encryption for backups. Alternatively set `use_ibm_owned_encryption_key` to true to use the default encryption for both backups and deployment data. | `bool` | `false` | no | | [use\_ibm\_owned\_encryption\_key](#input\_use\_ibm\_owned\_encryption\_key) | Set to true to use the default IBM Cloud® Databases randomly generated keys for disk and backups encryption. To control the encryption keys, use the `kms_key_crn` and `backup_encryption_key_crn` inputs. | `string` | `false` | no | | [use\_same\_kms\_key\_for\_backups](#input\_use\_same\_kms\_key\_for\_backups) | Set this to false if you wan't to use a different key that you own to encrypt backups. When set to false, a value is required for the `backup_encryption_key_crn` input. Alternatiely set `use_default_backup_encryption_key` to true to use the IBM Cloud Databases default encryption. Applies only if `use_ibm_owned_encryption_key` is false. 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). | `bool` | `true` | no | | [users](#input\_users) | 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 MySQL instance. This blocks creates native MySQL database users, more info on that can be found here https://cloud.ibm.com/docs/databases-for-mysql?topic=databases-for-mysql-user-management |
list(object({
name = string
password = string # pragma: allowlist secret
type = optional(string)
role = optional(string)
}))
| `[]` | no | +| [version\_upgrade\_skip\_backup](#input\_version\_upgrade\_skip\_backup) | Whether to skip taking a backup before upgrading the database version. Attention: Skipping a backup is not recommended. Skipping a backup before a version upgrade is dangerous and may result in data loss if the upgrade fails at any stage — there will be no immediate backup to restore from. | `bool` | `false` | no | ### Outputs diff --git a/modules/fscloud/main.tf b/modules/fscloud/main.tf index df599d74..b942b362 100644 --- a/modules/fscloud/main.tf +++ b/modules/fscloud/main.tf @@ -1,29 +1,32 @@ module "mysql_db" { source = "../.." resource_group_id = var.resource_group_id - mysql_version = var.mysql_version + name = var.name region = var.region skip_iam_authorization_policy = var.skip_iam_authorization_policy - name = var.name service_endpoints = "private" - cbr_rules = var.cbr_rules + deletion_protection = var.deletion_protection + version_upgrade_skip_backup = var.version_upgrade_skip_backup + timeouts_update = var.timeouts_update configuration = var.configuration - cpu_count = var.cpu_count - memory_mb = var.memory_mb - member_host_flavor = var.member_host_flavor - members = var.members - admin_pass = var.admin_pass - users = var.users - disk_mb = var.disk_mb + mysql_version = var.mysql_version use_ibm_owned_encryption_key = var.use_ibm_owned_encryption_key use_same_kms_key_for_backups = var.use_same_kms_key_for_backups use_default_backup_encryption_key = var.use_default_backup_encryption_key kms_key_crn = var.kms_key_crn backup_crn = var.backup_crn backup_encryption_key_crn = var.backup_encryption_key_crn - auto_scaling = var.auto_scaling + cbr_rules = var.cbr_rules access_tags = var.access_tags tags = var.tags + members = var.members + memory_mb = var.memory_mb + admin_pass = var.admin_pass + users = var.users + disk_mb = var.disk_mb + cpu_count = var.cpu_count + member_host_flavor = var.member_host_flavor + auto_scaling = var.auto_scaling service_credential_names = var.service_credential_names remote_leader_crn = var.remote_leader_crn } diff --git a/modules/fscloud/outputs.tf b/modules/fscloud/outputs.tf index b0e1595f..ca38b2d6 100644 --- a/modules/fscloud/outputs.tf +++ b/modules/fscloud/outputs.tf @@ -7,16 +7,16 @@ output "id" { value = module.mysql_db.id } -output "version" { - description = "MySQL instance version" - value = module.mysql_db.version -} - output "guid" { description = "MySQL instance guid" value = module.mysql_db.guid } +output "version" { + description = "MySQL instance version" + value = module.mysql_db.version +} + output "crn" { description = "MySQL instance crn" value = module.mysql_db.crn diff --git a/modules/fscloud/variables.tf b/modules/fscloud/variables.tf index 570acc11..8e414602 100644 --- a/modules/fscloud/variables.tf +++ b/modules/fscloud/variables.tf @@ -89,18 +89,36 @@ variable "service_credential_names" { default = {} } -variable "access_tags" { +variable "tags" { type = list(string) - description = "A list of access tags to apply to the MySQL instance created by the module, see https://cloud.ibm.com/docs/account?topic=account-access-tags-tutorial for more details" + description = "Optional list of tags to be added to the MySQL instance." default = [] } -variable "tags" { +variable "access_tags" { type = list(string) - description = "Optional list of tags to be added to the MySQL instance." + description = "A list of access tags to apply to the MySQL instance created by the module, see https://cloud.ibm.com/docs/account?topic=account-access-tags-tutorial for more details" default = [] } +variable "version_upgrade_skip_backup" { + type = bool + description = "Whether to skip taking a backup before upgrading the database version. Attention: Skipping a backup is not recommended. Skipping a backup before a version upgrade is dangerous and may result in data loss if the upgrade fails at any stage — there will be no immediate backup to restore from." + default = false +} + +variable "deletion_protection" { + type = bool + description = "Enable deletion protection within terraform. This is not a property of the resource and does not prevent deletion outside of terraform. The database can not be deleted by terraform when this value is set to 'true'. In order to delete with terraform the value must be set to 'false' and a terraform apply performed before the destroy is performed. The default is 'true'." + default = true +} + +variable "timeouts_update" { + type = string + description = "A database update may require a longer timeout for the update to complete. The default is 120 minutes. Set this variable to change the `update` value in the `timeouts` block. [Learn more](https://developer.hashicorp.com/terraform/language/resources/syntax#operation-timeouts)." + default = "120m" +} + variable "configuration" { type = object({ default_authentication_plugin = optional(string) # sha256_password,caching_sha2_password,mysql_native_password @@ -235,7 +253,7 @@ variable "cbr_rules" { })) }))) })) - description = "(Optional, list) List of CBR rules to create, if operations is not set it will default to api-type:data-plane" + description = "(Optional, list) List of context-based restrictions rules to create." default = [] # Validation happens in the rule module } diff --git a/outputs.tf b/outputs.tf index 35a0318e..73535b03 100644 --- a/outputs.tf +++ b/outputs.tf @@ -7,16 +7,16 @@ output "id" { value = ibm_database.mysql_db.id } -output "guid" { - description = "MySQL instance guid" - value = ibm_database.mysql_db.guid -} - output "version" { description = "MySQL instance version" value = ibm_database.mysql_db.version } +output "guid" { + description = "MySQL instance guid" + value = ibm_database.mysql_db.guid +} + output "crn" { description = "MySQL instance crn" value = ibm_database.mysql_db.resource_crn diff --git a/solutions/fully-configurable/DA-types.md b/solutions/fully-configurable/DA-types.md index 987c79e4..9e9c9e76 100644 --- a/solutions/fully-configurable/DA-types.md +++ b/solutions/fully-configurable/DA-types.md @@ -111,24 +111,23 @@ If you can't use the IAM-enabled `service_credential_names` input variable for a ### Options for users - - `name` (required): The username for the user account. - - `password` (required): The password for the user account in the range of 10-32 characters. - - `type` (required): The user type. The "type" field is required to generate the connection string for the outputs. - - `role`: The user role. The role determines the user's access level and permissions. +- `name` (required): The username for the user account. +- `password` (required): The password for the user account in the range of 10-32 characters. +- `type` (required): The user type. The "type" field is required to generate the connection string for the outputs. +- `role`: The user role. The role determines the user's access level and permissions. ### Example users - ```hcl [ { "name": "es_admin", - "password": "securepassword123", # pragma: allowlist secret + "password": "securepassword123", "type": "database", }, { "name": "es_reader", - "password": "readpassword123", # pragma: allowlist secret + "password": "readpassword123", "type": "ops_manager" } ] diff --git a/solutions/fully-configurable/catalogValidationValues.json.template b/solutions/fully-configurable/catalogValidationValues.json.template index be8f591c..8e32551a 100644 --- a/solutions/fully-configurable/catalogValidationValues.json.template +++ b/solutions/fully-configurable/catalogValidationValues.json.template @@ -5,5 +5,6 @@ "name": $PREFIX, "existing_resource_group_name": "geretain-test-mysql", "existing_kms_instance_crn": $HPCS_US_SOUTH_CRN, + "deletion_protection": false, "kms_encryption_enabled": true } diff --git a/solutions/fully-configurable/main.tf b/solutions/fully-configurable/main.tf index 58ddd0a7..12c8ec68 100644 --- a/solutions/fully-configurable/main.tf +++ b/solutions/fully-configurable/main.tf @@ -302,6 +302,9 @@ module "mysql" { service_credential_names = var.service_credential_names backup_crn = var.backup_crn service_endpoints = var.service_endpoints + deletion_protection = var.deletion_protection + version_upgrade_skip_backup = var.version_upgrade_skip_backup + timeouts_update = var.timeouts_update remote_leader_crn = var.remote_leader_crn } @@ -323,7 +326,7 @@ locals { } # Parse the Secrets Manager CRN -module "sm_instance_crn_parser" { +module "secrets_manager_instance_crn_parser" { count = var.existing_secrets_manager_instance_crn != null ? 1 : 0 source = "terraform-ibm-modules/common-utilities/ibm//modules/crn-parser" version = "1.2.0" @@ -386,8 +389,8 @@ locals { # Concatinate into 1 secrets object secrets = concat(local.service_credential_secrets, local.admin_pass_secret) # Parse Secrets Manager details from the CRN - existing_secrets_manager_instance_guid = var.existing_secrets_manager_instance_crn != null ? module.sm_instance_crn_parser[0].service_instance : null - existing_secrets_manager_instance_region = var.existing_secrets_manager_instance_crn != null ? module.sm_instance_crn_parser[0].region : null + existing_secrets_manager_instance_guid = var.existing_secrets_manager_instance_crn != null ? module.secrets_manager_instance_crn_parser[0].service_instance : null + existing_secrets_manager_instance_region = var.existing_secrets_manager_instance_crn != null ? module.secrets_manager_instance_crn_parser[0].region : null } module "secrets_manager_service_credentials" { diff --git a/solutions/fully-configurable/variables.tf b/solutions/fully-configurable/variables.tf index b0ae45b5..9494f3e7 100644 --- a/solutions/fully-configurable/variables.tf +++ b/solutions/fully-configurable/variables.tf @@ -119,6 +119,12 @@ variable "member_host_flavor" { type = string description = "The host flavor per member. [Learn more](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/database#host_flavor)." default = "multitenant" + nullable = false + # 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 "configuration" { @@ -198,6 +204,24 @@ variable "access_tags" { default = [] } +variable "version_upgrade_skip_backup" { + type = bool + description = "Whether to skip taking a backup before upgrading the database version. Attention: Skipping a backup is not recommended. Skipping a backup before a version upgrade is dangerous and may result in data loss if the upgrade fails at any stage — there will be no immediate backup to restore from." + default = false +} + +variable "deletion_protection" { + type = bool + description = "Enable deletion protection within terraform. This is not a property of the resource and does not prevent deletion outside of terraform. The database can not be deleted by terraform when this value is set to 'true'. In order to delete with terraform the value must be set to 'false' and a terraform apply performed before the destroy is performed. The default is 'true'." + default = true +} + +variable "timeouts_update" { + type = string + description = "A database update may require a longer timeout for the update to complete. The default is 120 minutes. Set this variable to change the `update` value in the `timeouts` block. [Learn more](https://developer.hashicorp.com/terraform/language/resources/syntax#operation-timeouts)." + default = "120m" +} + ############################################################## # Encryption ############################################################## @@ -239,6 +263,7 @@ variable "kms_endpoint_type" { type = string description = "The type of endpoint to use for communicating with the Key Protect or Hyper Protect Crypto Services instance. Possible values: `public`, `private`. Applies only if `existing_kms_key_crn` is not specified." default = "private" + validation { condition = can(regex("public|private", var.kms_endpoint_type)) error_message = "The kms_endpoint_type value must be 'public' or 'private'." @@ -352,6 +377,7 @@ variable "existing_secrets_manager_endpoint_type" { type = string description = "The endpoint type to use if `existing_secrets_manager_instance_crn` is specified. Possible values: public, private." default = "private" + validation { condition = contains(["public", "private"], var.existing_secrets_manager_endpoint_type) error_message = "Only \"public\" and \"private\" are allowed values for 'existing_secrets_endpoint_type'." @@ -363,7 +389,7 @@ variable "service_credential_secrets" { secret_group_name = string secret_group_description = optional(string) existing_secret_group = optional(bool) - service_credentials = list(object({ # pragma: allowlist secret + service_credentials = list(object({ secret_name = string service_credentials_source_service_role_crn = string secret_labels = optional(list(string)) diff --git a/solutions/security-enforced/catalogValidationValues.json.template b/solutions/security-enforced/catalogValidationValues.json.template index cbc61a42..37048f4c 100644 --- a/solutions/security-enforced/catalogValidationValues.json.template +++ b/solutions/security-enforced/catalogValidationValues.json.template @@ -4,5 +4,6 @@ "resource_tags": $TAGS, "name": $PREFIX, "existing_resource_group_name": "geretain-test-mysql", - "existing_kms_instance_crn": $HPCS_US_SOUTH_CRN + "existing_kms_instance_crn": $HPCS_US_SOUTH_CRN, + "deletion_protection": false } diff --git a/solutions/security-enforced/main.tf b/solutions/security-enforced/main.tf index bc2ddb85..4f6a47eb 100644 --- a/solutions/security-enforced/main.tf +++ b/solutions/security-enforced/main.tf @@ -39,5 +39,8 @@ module "mysql" { use_existing_admin_pass_secrets_manager_secret_group = var.use_existing_admin_pass_secrets_manager_secret_group admin_pass_secrets_manager_secret_name = var.admin_pass_secrets_manager_secret_name service_endpoints = "private" + deletion_protection = var.deletion_protection + version_upgrade_skip_backup = false + timeouts_update = var.timeouts_update remote_leader_crn = var.remote_leader_crn } diff --git a/solutions/security-enforced/variables.tf b/solutions/security-enforced/variables.tf index 29b0fad7..1f61b0e5 100644 --- a/solutions/security-enforced/variables.tf +++ b/solutions/security-enforced/variables.tf @@ -103,6 +103,12 @@ variable "member_host_flavor" { type = string description = "The host flavor per member. [Learn more](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/database#host_flavor)." default = "multitenant" + nullable = false + # 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 "configuration" { @@ -182,6 +188,18 @@ variable "access_tags" { default = [] } +variable "deletion_protection" { + type = bool + description = "Enable deletion protection within terraform. This is not a property of the resource and does not prevent deletion outside of terraform. The database can not be deleted by terraform when this value is set to 'true'. In order to delete with terraform the value must be set to 'false' and a terraform apply performed before the destroy is performed. The default is 'true'." + default = true +} + +variable "timeouts_update" { + type = string + description = "A database update may require a longer timeout for the update to complete. The default is 120 minutes. Set this variable to change the `update` value in the `timeouts` block. [Learn more](https://developer.hashicorp.com/terraform/language/resources/syntax#operation-timeouts)." + default = "120m" +} + ############################################################## # Encryption ############################################################## @@ -197,7 +215,6 @@ variable "existing_kms_key_crn" { description = "The CRN of a Key Protect or Hyper Protect Crypto Services encryption key to encrypt your data. By default this key is used for both deployment data and backups, but this behaviour can be altered using the optional `existing_backup_kms_key_crn` input. If no value is passed a new key will be created in the instance specified in the `existing_kms_instance_crn` input. 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)." default = null - validation { condition = ( (var.existing_kms_key_crn != null && var.existing_kms_instance_crn == null) || @@ -298,7 +315,7 @@ variable "service_credential_secrets" { secret_group_name = string secret_group_description = optional(string) existing_secret_group = optional(bool) - service_credentials = list(object({ # pragma: allowlist secret + service_credentials = list(object({ secret_name = string service_credentials_source_service_role_crn = string secret_labels = optional(list(string)) diff --git a/solutions/security-enforced/version.tf b/solutions/security-enforced/version.tf index 70b38b5b..2d5c091d 100644 --- a/solutions/security-enforced/version.tf +++ b/solutions/security-enforced/version.tf @@ -1,6 +1,5 @@ terraform { required_version = ">= 1.9.0" # Lock DA into an exact provider version - renovate automation will keep it updated - required_providers { - } + required_providers {} } diff --git a/tests/other_test.go b/tests/other_test.go index 7ba0282a..22726514 100644 --- a/tests/other_test.go +++ b/tests/other_test.go @@ -42,8 +42,8 @@ func TestRunPointInTimeRecoveryDBExample(t *testing.T) { Testing: t, TerraformDir: "examples/pitr", Prefix: "mysql-pitr", - ResourceGroup: resourceGroup, Region: fmt.Sprint(permanentResources["mysqlPITRRegion"]), + ResourceGroup: resourceGroup, TerraformVars: map[string]interface{}{ "pitr_id": permanentResources["mysqlPITRCrn"], "pitr_time": " ", diff --git a/tests/pr_test.go b/tests/pr_test.go index 85ae32a7..2cdc7e98 100644 --- a/tests/pr_test.go +++ b/tests/pr_test.go @@ -38,7 +38,7 @@ const regionSelectionPath = "../common-dev-assets/common-go-assets/icd-region-pr // Define a struct with fields that match the structure of the YAML data const yamlLocation = "../common-dev-assets/common-go-assets/common-permanent-resources.yaml" -var permanentResources map[string]any +var permanentResources map[string]interface{} var sharedInfoSvc *cloudinfo.CloudInfoService var validICDRegions = []string{ @@ -79,7 +79,7 @@ func TestRunFullyConfigurableSolutionSchematics(t *testing.T) { WaitJobCompleteMinutes: 60, }) - serviceCredentialSecrets := []map[string]any{ + serviceCredentialSecrets := []map[string]interface{}{ { "secret_group_name": fmt.Sprintf("%s-secret-group", options.Prefix), "service_credentials": []map[string]string{ @@ -109,6 +109,7 @@ func TestRunFullyConfigurableSolutionSchematics(t *testing.T) { options.TerraformVars = []testschematic.TestSchematicTerraformVar{ {Name: "ibmcloud_api_key", Value: options.RequiredEnvironmentVars["TF_VAR_ibmcloud_api_key"], DataType: "string", Secure: true}, {Name: "access_tags", Value: permanentResources["accessTags"], DataType: "list(string)"}, + {Name: "deletion_protection", Value: false, DataType: "bool"}, {Name: "existing_resource_group_name", Value: resourceGroup, DataType: "string"}, {Name: "mysql_version", Value: latestVersion, DataType: "string"}, // Always lock this test into the latest supported MySQL version {Name: "service_credential_names", Value: string(serviceCredentialNamesJSON), DataType: "map(string)"}, @@ -177,6 +178,7 @@ func TestRunSecurityEnforcedSolutionSchematics(t *testing.T) { options.TerraformVars = []testschematic.TestSchematicTerraformVar{ {Name: "ibmcloud_api_key", Value: options.RequiredEnvironmentVars["TF_VAR_ibmcloud_api_key"], DataType: "string", Secure: true}, {Name: "access_tags", Value: permanentResources["accessTags"], DataType: "list(string)"}, + {Name: "deletion_protection", Value: false, DataType: "bool"}, {Name: "existing_kms_instance_crn", Value: permanentResources["hpcs_south_crn"], DataType: "string"}, {Name: "existing_backup_kms_key_crn", Value: permanentResources["hpcs_south_root_key_crn"], DataType: "string"}, {Name: "existing_resource_group_name", Value: uniqueResourceGroup, DataType: "string"}, @@ -246,6 +248,7 @@ func TestRunSecurityEnforcedUpgradeSolution(t *testing.T) { {Name: "ibmcloud_api_key", Value: options.RequiredEnvironmentVars["TF_VAR_ibmcloud_api_key"], DataType: "string", Secure: true}, {Name: "prefix", Value: options.Prefix, DataType: "string"}, {Name: "access_tags", Value: permanentResources["accessTags"], DataType: "list(string)"}, + {Name: "deletion_protection", Value: false, DataType: "bool"}, {Name: "existing_kms_instance_crn", Value: permanentResources["hpcs_south_crn"], DataType: "string"}, {Name: "existing_resource_group_name", Value: resourceGroup, DataType: "string"}, {Name: "mysql_version", Value: "8.0", DataType: "string"}, // Always lock this test into the latest supported MySQL version diff --git a/variables.tf b/variables.tf index a7e59210..0118b382 100644 --- a/variables.tf +++ b/variables.tf @@ -137,6 +137,24 @@ variable "access_tags" { } } +variable "version_upgrade_skip_backup" { + type = bool + description = "Whether to skip taking a backup before upgrading the database version. Attention: Skipping a backup is not recommended. Skipping a backup before a version upgrade is dangerous and may result in data loss if the upgrade fails at any stage — there will be no immediate backup to restore from." + default = false +} + +variable "deletion_protection" { + type = bool + description = "Enable deletion protection within terraform. This is not a property of the resource and does not prevent deletion outside of terraform. The database can not be deleted by terraform when this value is set to 'true'. In order to delete with terraform the value must be set to 'false' and a terraform apply performed before the destroy is performed. The default is 'true'." + default = true +} + +variable "timeouts_update" { + type = string + description = "A database update may require a longer timeout for the update to complete. The default is 120 minutes. Set this variable to change the `update` value in the `timeouts` block. [Learn more](https://developer.hashicorp.com/terraform/language/resources/syntax#operation-timeouts)." + default = "120m" +} + variable "configuration" { type = object({ default_authentication_plugin = optional(string) # sha256_password,caching_sha2_password,mysql_native_password