Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ To attach access management tags to resources in this module, you need the follo
| <a name="input_cbr_rules"></a> [cbr\_rules](#input\_cbr\_rules) | (Optional, list) List of CBR rules to create | <pre>list(object({<br/> description = string<br/> account_id = string<br/> rule_contexts = list(object({<br/> attributes = optional(list(object({<br/> name = string<br/> value = string<br/> }))) }))<br/> enforcement_mode = string<br/> tags = optional(list(object({<br/> name = string<br/> value = string<br/> })))<br/> }))</pre> | `[]` | no |
| <a name="input_configuration"></a> [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. | <pre>object({<br/> default_authentication_plugin = optional(string) # sha256_password,caching_sha2_password,mysql_native_password<br/> innodb_buffer_pool_size_percentage = optional(number) # 10 ≤ value ≤ 100<br/> innodb_flush_log_at_trx_commit = optional(number) # 0 ≤ value ≤ 2<br/> innodb_log_buffer_size = optional(number) # 1048576 ≤ value ≤ 4294967295<br/> innodb_log_file_size = optional(number) # 4194304 ≤ value ≤ 274877906900<br/> innodb_lru_scan_depth = optional(number) # 128 ≤ value ≤ 2048<br/> innodb_read_io_threads = optional(number) # 1 ≤ value ≤ 64<br/> innodb_write_io_threads = optional(number) # 1 ≤ value ≤ 64<br/> max_allowed_packet = optional(number) # 1024 ≤ value ≤ 1073741824<br/> max_connections = optional(number) # 100 ≤ value ≤ 200000<br/> max_prepared_stmt_count = optional(number) # 0 ≤ value ≤ 4194304<br/> mysql_max_binlog_age_sec = optional(number) # 300 ≤ value ≤ 1073741823 Default: 1800<br/> net_read_timeout = optional(number) # 1 ≤ value ≤ 7200<br/> net_write_timeout = optional(number) # 1 ≤ value ≤ 7200<br/> sql_mode = optional(string) # The comma-separated list of SQL modes applied on this server globally<br/> wait_timeout = optional(number) # 1 ≤ value ≤ 31536000<br/> })</pre> | `null` | no |
| <a name="input_cpu_count"></a> [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 |
| <a name="input_deletion_protection"></a> [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 |
| <a name="input_disk_mb"></a> [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 |
| <a name="input_kms_key_crn"></a> [kms\_key\_crn](#input\_kms\_key\_crn) | The CRN of a Key Protect or Hyper Protect Crypto Services encryption key to encrypt your data. Applies only if `use_ibm_owned_encryption_key` is false. By default this key is used for both deployment data and backups, but this behaviour can be altered using the `use_same_kms_key_for_backups` and `backup_encryption_key_crn` inputs. Bare in mind that backups encryption is only available in certain regions. See [Bring your own key for backups](https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-key-protect&interface=ui#key-byok) and [Using the HPCS Key for Backup encryption](https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-hpcs#use-hpcs-backups). | `string` | `null` | no |
| <a name="input_member_host_flavor"></a> [member\_host\_flavor](#input\_member\_host\_flavor) | Allocated host flavor per member. [Learn more](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/database#host_flavor). | `string` | `null` | no |
Expand All @@ -137,10 +138,12 @@ To attach access management tags to resources in this module, you need the follo
| <a name="input_service_endpoints"></a> [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 |
| <a name="input_skip_iam_authorization_policy"></a> [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 |
| <a name="input_tags"></a> [tags](#input\_tags) | Optional list of tags to be added to the MySQL instance. | `list(string)` | `[]` | no |
| <a name="input_timeouts_update"></a> [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 |
| <a name="input_use_default_backup_encryption_key"></a> [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 |
| <a name="input_use_ibm_owned_encryption_key"></a> [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 |
| <a name="input_use_same_kms_key_for_backups"></a> [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 |
| <a name="input_users"></a> [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 | <pre>list(object({<br/> name = string<br/> password = string # pragma: allowlist secret<br/> type = optional(string)<br/> role = optional(string)<br/> }))</pre> | `[]` | no |
| <a name="input_version_upgrade_skip_backup"></a> [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

Expand Down
17 changes: 9 additions & 8 deletions examples/backup/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
8 changes: 4 additions & 4 deletions examples/basic/README.md
Original file line number Diff line number Diff line change
@@ -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)
38 changes: 20 additions & 18 deletions examples/basic/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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]
}
2 changes: 1 addition & 1 deletion examples/basic/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Outputs
##############################################################################
output "id" {
description = "MySQL instance id"
description = "Database instance id"
value = module.database.id
}

Expand Down
24 changes: 13 additions & 11 deletions examples/basic/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand All @@ -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 = []
}

Expand All @@ -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`."
Expand All @@ -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)."
Expand Down
18 changes: 10 additions & 8 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 = [
{
Expand Down
22 changes: 14 additions & 8 deletions examples/complete/outputs.tf
Original file line number Diff line number Diff line change
@@ -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" {
Expand All @@ -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
Expand All @@ -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
}
Loading