Thanks to visit codestin.com
Credit goes to github.com

Skip to content

intel/terraform-intel-azure-mysql-flexible-server

Intel Logo

Intel Optimized Cloud Modules for Terraform

© Copyright 2024, Intel Corporation

Azure MySQL Flexible Server Module

This module can be used to deploy an Intel optimized Azure MySQL Flexible Server instance. Instance selection and mysql optimization are included by default in the code.

The MySQL Optimizations were based off Intel Xeon Tuning guides

Performance Data

MySQL

MySQL

MySQL

Usage

See examples folder for complete examples.

By default, you will only have to pass three variables

resource_group_name    
db_server_name       
db_password         

variables.tf

variable "db_password" {
  description = "Password for the master database user."
  type        = string
  sensitive   = true
}

main.tf

module "optimized-mysql-server" {
  source          = "intel/azure-mysql-flexible-server/intel"
  resource_group_name = "<RESOURCE_GROUP_NAME>"   
  db_server_name      = "<DB_SERVER_NAME>" 
  db_password         = var.db_password
}

Run Terraform

export TF_VAR_db_password ='<USE_A_STRONG_PASSWORD>'

terraform init  
terraform plan
terraform apply 

Note that this example creates resources. Run terraform destroy when you don't need these resources.

Requirements

Name Version
terraform >=1.3.0
azurerm ~>3.86

Providers

Name Version
azurerm ~>3.86

Modules

No modules.

Resources

Name Type
azurerm_mysql_flexible_database.mysql resource
azurerm_mysql_flexible_server.mysql resource
azurerm_mysql_flexible_server_configuration.mysql resource
azurerm_mysql_flexible_server_firewall_rule.firewall resource
azurerm_resource_group.rg data source

Inputs

Name Description Type Default Required
db_allocated_storage Maximum allocated storage for Azure database instance to grow (in gigabytes). number 2048 no
db_auto_grow_enabled Enable/Disable auto-growing of the storage. Storage auto-grow prevents your server from running out of storage and becoming read-only. bool true no
db_backup_retention_period The days to retain backups for. Must be between 1 and 35. number 7 no
db_charset Specifies the Charset for the MySQL Database. string "utf8" no
db_collation Specifies the Collation for the MySQL Database. string "utf8_general_ci" no
db_create_mode The creation mode which can be used to restore or replicate existing servers. string "Default" no
db_create_source_id For creation modes other than Default, the source server ID to use. string null no
db_delegated_subnet_id The ID of the virtual network subnet to create the MySQL Flexible Server. string null no
db_engine Database engine for Azure database instance. string "mysql" no
db_engine_version Database engine version for the Azure database instance. string "8.0.21" no
db_firewall_rules Map of IP ranges that (if specified) will create firewall rules for the MySQL server to access those addresses.
list(object({
name = string
start_ip_address = optional(string)
end_ip_address = optional(string)
}))
[] no
db_geo_backup_enabled Turn Geo-redundant server backups on/off. This allows you to choose between locally redundant or geo-redundant backup storage in the General Purpose and Memory Optimized tiers. When the backups are stored in geo-redundant backup storage, they are not only stored within the region in which your server is hosted, but are also replicated to a paired data center. This provides better protection and ability to restore your server in a different region in the event of a disaster bool false no
db_ha_mode The high availability mode for the MySQL Flexible Server. Possibles values are SameZone and ZoneRedundant. string "ZoneRedundant" no
db_ha_standby_zone Specifies the Availability Zone in which the standby Flexible Server should be located. Possible values are 1, 2 and 3. string 2 no
db_iops The amount of provisioned IOPS. number 10000 no
db_maintenance_day The day of week for maintenance window. string null no
db_maintenance_hour The start hour for maintenance window. string null no
db_maintenance_minute The start minute for maintenance window. string null no
db_name Name of the database that will be created on the flexible instance. If this is specified then a database will be created as a part of the instance provisioning process. string null no
db_parameters Intel Cloud optimizations for Xeon processors
object({
mysql = optional(object({
table_open_cache = optional(object({
value = optional(string, "8000")
}))
table_open_cache_instances = optional(object({
value = optional(string, "16")
}))
max_connections = optional(object({
value = optional(string, "10900")
}))
performance_schema = optional(object({
value = optional(string, "OFF")
}))
max_prepared_stmt_count = optional(object({
value = optional(string, "128000")
}))
character_set_server = optional(object({
value = optional(string, "latin1")
}))
collation_server = optional(object({
value = optional(string, "latin1_swedish_ci")
}))
transaction_isolation = optional(object({
value = optional(string, "REPEATABLE-READ")
}))
innodb_open_files = optional(object({
value = optional(string, "4000")
}))
innodb_file_per_table = optional(object({
value = optional(string, "ON")
}))
innodb_log_buffer_size = optional(object({
value = optional(string, "67108864")
}))
innodb_thread_concurrency = optional(object({
value = optional(string, "0")
}))
innodb_max_dirty_pages_pct = optional(object({
value = optional(string, "90")
}))
innodb_max_dirty_pages_pct_lwm = optional(object({
value = optional(string, "10")
}))
join_buffer_size = optional(object({
value = optional(string, 32 * 1024)
}))
sort_buffer_size = optional(object({
value = optional(string, 32 * 1024)
}))
innodb_stats_persistent = optional(object({
value = optional(string, "ON")
}))
innodb_spin_wait_delay = optional(object({
value = optional(string, "6")
}))
innodb_max_purge_lag_delay = optional(object({
value = optional(string, "300000")
}))
innodb_max_purge_lag = optional(object({
value = optional(string, "0")
}))
innodb_io_capacity = optional(object({
value = optional(string, "4000")
}))
innodb_io_capacity_max = optional(object({
value = optional(string, "20000")
}))
innodb_lru_scan_depth = optional(object({
value = optional(string, "9000")
}))
innodb_change_buffering = optional(object({
value = optional(string, "none")
}))
innodb_page_cleaners = optional(object({
value = optional(string, "4")
}))
innodb_adaptive_flushing = optional(object({
value = optional(string, "ON")
}))
innodb_flush_neighbors = optional(object({
value = optional(string, "0")
}))
innodb_read_io_threads = optional(object({
value = optional(string, "16")
}))
innodb_write_io_threads = optional(object({
value = optional(string, "16")
}))
innodb_purge_threads = optional(object({
value = optional(string, "4")
}))
innodb_adaptive_hash_index = optional(object({
value = optional(string, "OFF")
}))
# Non-Configurable parameters by Azure Flexible server
/* innodb_log_file_size = optional(object({
value = optional(string, 1024 * 1024 * 1024)
})) */
# Values not supported by Azure MySQL Flexible server
# Read Only
# back_log = optional(object({
# value = optional(string, "1500")
# }))
# Read Only
# default_password_lifetime = optional(object({
# value = optional(string, "0")
# }))
# Not required, Azure sets this to the maximum allowed the instance available memory (~70%)
# innodb_buffer_pool_size = optional(object({
# value = optional(string, 64424509440)
# }))
# Read Only
# innodb_buffer_pool_instances = optional(object({
# value = optional(string, "16")
# }))
# Read Only
# innodb_flush_log_at_trx_commit = optional(object({
# value = optional(string, "0")
# }))
# Read Only
# innodb_use_native_aio = optional(object({
# value = optional(string, "1")
# }))
# Read Only
# innodb_checksum_algorithm = optional(object({
# value = optional(string, "none")
# }))
# Read Only
# innodb_undo_log_truncate = optional(object({
# value = optional(string, "0")
# }))
}))
})
{
"mysql": {
"character_set_server": {},
"collation_server": {},
"innodb_adaptive_flushing": {},
"innodb_adaptive_hash_index": {},
"innodb_change_buffering": {},
"innodb_file_per_table": {},
"innodb_flush_neighbors": {},
"innodb_io_capacity": {},
"innodb_io_capacity_max": {},
"innodb_log_buffer_size": {},
"innodb_lru_scan_depth": {},
"innodb_max_dirty_pages_pct": {},
"innodb_max_dirty_pages_pct_lwm": {},
"innodb_max_purge_lag": {},
"innodb_max_purge_lag_delay": {},
"innodb_open_files": {},
"innodb_page_cleaners": {},
"innodb_purge_threads": {},
"innodb_read_io_threads": {},
"innodb_spin_wait_delay": {},
"innodb_stats_persistent": {},
"innodb_thread_concurrency": {},
"innodb_write_io_threads": {},
"join_buffer_size": {},
"max_connections": {},
"max_prepared_stmt_count": {},
"performance_schema": {},
"sort_buffer_size": {},
"table_open_cache": {},
"table_open_cache_instances": {},
"transaction_isolation": {}
}
}
no
db_password Password for the master database user. string n/a yes
db_private_dns_zone_id The ID of the private DNS zone to create the MySQL Flexible Server. string null no
db_replica_role The replica role that the database will use. string null no
db_restore_time When create_mode is PointInTimeRestore, specifies the point in time to restore from creation_source_server_id. It should be provided in RFC3339 format, e.g. 2013-11-08T22:00:40Z. string null no
db_server_name Name of the server that will be created. string n/a yes
db_server_sku Instance SKU, see comments above for guidance string "MO_Standard_E8ds_v5" no
db_timeouts Map of timeouts that can be adjusted when executing the module. This allows you to customize how long certain operations are allowed to take before being considered to have failed.
object({
create = optional(string, null)
delete = optional(string, null)
update = optional(string, null)
})
{
"db_timeouts": {}
}
no
db_username Username for the master database user. string "mysqladmin" no
db_zone Specifies the Availability Zone in which this MySQL Flexible Server should be located. Possible values are 1, 2 and 3. string 1 no
resource_group_name Resource Group where resource will be created. It should already exist string n/a yes
tags Tags to apply to the Database Server map(string) {} no

Outputs

Name Description
db_allocated_storage Storage allocated to the database instance.
db_auto_grow_enabled Flag that determines if storage auto grow is enabled.
db_backup_retention Number of configured backups to keep for the database instance.
db_charset The Charset configured on the database.
db_collation The Collation configured on the database.
db_create_mode The creation mode that was configured on the instance.
db_create_source_id For creation modes other than Default, the source server ID to use.
db_delegated_subnet_id The ID of the virtual network subnet to create the MySQL Flexible Server.
db_engine_version_actual Running engine version of the database (full version number).
db_firewall_rules Database Firewall Rules.
db_ha_mode The high availability mode for the MySQL Flexible Server.
db_ha_standby_zone Specifies the Availability Zone in which the standby Flexible Server should be located.
db_hostname Database instance fully qualified domain name.
db_id Database instance ID.
db_iops Database instance storage iops configuration.
db_location Database instance location.
db_maintenance_window_day Maintenance window for the database instance.
db_maintenance_window_hour Maintenance window for the database instance.
db_maintenance_window_minute Maintenance window for the database instance.
db_name Name of the database that has been provisioned on the database instance.
db_password Database instance master password.
db_private_dns_zone_id The ID of the private DNS zone that the instance will use.
db_replica_role The replica role that the database was configured with.
db_resource_group_name Resource Group where the database instance resides.
db_restore_time Specifies the point in time to restore from creation_source_server_id.
db_server_name Database instance hostname.
db_server_sku Instance SKU in use for the database instance that was created.
db_username Database instance master username.
db_zone Zone where the database instance was deployed.

About

Intel Cloud Optimization Module - Azure MySQL Flexible Server

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages