Skip to content

Latest commit

 

History

History

mysql

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Azure MySQL Database Module (mysql)

Contents

Architecture

mysql-diagram

Overview

This configuration implements a network isolated Azure Database for MySQL using private endpoints.

Enabling this module also causes the vnet-app module to install MySQL Workbench on jumpwin1. MySQL Workbench is not uninstalled if this module is later disabled.

The estimated provisioning time for this module is 10 minutes.

Smoke Testing

This section describes how to test the module after deployment.

  • Test DNS queries for Azure Database for MySQL private endpoint
    • From jumpwin1, execute the following PowerShell command:

      Resolve-DnsName <mysql-server-name-here>.mysql.database.azure.com
    • Verify the IP4Address returned is within the subnet IP address prefix for the centralized private endpoint subnet vnet_shared.subnets["snet-privatelink-01"], e.g. 10.1.5.*.

  • From jumpwin1, test network isolated MySQL connectivity using MySQL Workbench.
    • Navigate to Start > MySQL Workbench
    • Navigate to Database Connections > New Connection and connect using the following values:
      • Caption: <mysql-server-name-here>.mysql.database.azure.com
      • Connection method: mysql
      • Hostname or IP address: <mysql-server-name-here>.mysql.database.azure.com
      • Port: 3306
      • User Name: bootstrapadmin
      • Default Schema: testdb
      • Click OK
    • Click on the newly created Database Connection
      • When prompted for password use the value of the adminpassword secret in the sandbox environment key vault.
      • Create a table, insert some data and run some sample queries to verify functionality.

Documentation

This section provides additional information on various aspects of this module.

Dependencies

This module depends upon resources provisioned in the following modules:

  • Root module
  • vnet-shared module
  • vnet-app module

Module Structure

The module is organized as follows:

├── images/
|   └── mysql-diagram.drawio.svg  # Architecture diagram
├── scripts/
|   └── Test-Mysql.ps1            # Unit test script
├── main.tf                       # Resource configurations
├── network.tf                    # Network resource configurations
├── outputs.tf                    # Output variables
├── terraform.tf                  # Terraform configuration block
└── variables.tf                  # Input variables

Input Variables

This section lists input variables used in this module. Defaults can be overridden by specifying a different value in the root module.

Variable Default Description
admin_password A strong password used for admin accounts. Defined in the vnet-shared module.
admin_username bootstrapadmin The user name used for admin accounts. Defined in the vnet-shared module.
location The name of the Azure Region where resources will be provisioned. Defined in the root module.
log_analytics_workspace_id The ID of the Log Analytics workspace where MySQL diagnostic logs and metrics will be sent. Defined in the vnet-shared module.
mysql_database_name testdb The name of the Azure MySQL Database to be provisioned.
mysql_sku_name B_Standard_B1ms The SKU name for the Azure MySQL Flexible Server.
private_dns_zone_id The ID of the private DNS zone for Azure Database for MySQL. Defined in the vnet-app module.
resource_group_name The name of the resource group defined in the root module.
subnet_id The subnet ID defined in the vnet-app module.
tags The tags from the root module.
unique_seed The unique seed used to generate unique names for resources. Defined in the root module.

Module Resources

This section lists the resources included in this module.

Address Name Notes
module.mysql[0].azurerm_mysql_flexible_database.this testdb The Azure MySQL Database.
module.mysql[0].azurerm_mysql_flexible_server.this mysql‑sand‑dev‑xxxxxxxx The Azure MySQL flexible server.
module.mysql[0].azurerm_mysql_flexible_server_configuration.slow_query_log slow_query_log Enables slow query logging so the MySqlSlowLogs diagnostic category produces data.
module.mysql[0].azurerm_mysql_flexible_server_configuration.audit_log_enabled audit_log_enabled Enables audit logging so the MySqlAuditLogs diagnostic category produces data.
module.mysql[0].azurerm_mysql_flexible_server_configuration.audit_log_events audit_log_events Selects the audit event classes (CONNECTION, DML, DDL, DCL) to be logged.
module.mysql[0].azurerm_monitor_diagnostic_setting.this Diagnostic Logs The diagnostic setting that sends MySQL slow/audit logs and metrics to the Log Analytics workspace.
module.mysql[0].azurerm_private_endpoint.this pe‑sand‑dev‑mysql‑server The private endpoint for the Azure MySQL flexible server.

Output Variables

This section includes a list of output variables returned by the module.

Name Comments
fqdns A map of fqdns for resources provisioned in the module.
resource_ids A map of resource IDs for key resources in the module.
resource_names A map of resource names for key resources in the module.