From 8a1c8616d4cd05423e53c3260a016919ce0df33d Mon Sep 17 00:00:00 2001 From: thebikeshedder <141344797+thebikeshedder@users.noreply.github.com> Date: Mon, 13 Nov 2023 21:40:03 +0000 Subject: [PATCH] feat: Add support for Azure SQL Managed Instance (azurerm_mssql_managed_instance) (#102) --- README.md | 17 +++++++---------- docs/defined_specs | 1 + main.tf | 14 ++++++++++++++ outputs.tf | 5 +++++ resourceDefinition.json | 11 +++++++++++ 5 files changed, 38 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index c458bd2..e5b260a 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ postgresql_server = { | Name | Version | |------|---------| -| [random](#provider\_random) | 3.4.3 | +| [random](#provider\_random) | >= 3.3.2 | ## Modules @@ -127,7 +127,7 @@ No modules. | [api\_management](#output\_api\_management) | Api Management | | [app\_configuration](#output\_app\_configuration) | App Configuration | | [app\_service](#output\_app\_service) | App Service | -| [app\_service\_environment](#output\_app\_service\_environment) | App Service Environment | +| [app\_service\_environment](#output\_app\_service\_environment) | n/a | | [app\_service\_plan](#output\_app\_service\_plan) | App Service Plan | | [application\_gateway](#output\_application\_gateway) | Application Gateway | | [application\_insights](#output\_application\_insights) | Application Insights | @@ -250,14 +250,6 @@ No modules. | [linux\_virtual\_machine\_scale\_set](#output\_linux\_virtual\_machine\_scale\_set) | Linux Virtual Machine Scale Set | | [local\_network\_gateway](#output\_local\_network\_gateway) | Local Network Gateway | | [log\_analytics\_workspace](#output\_log\_analytics\_workspace) | Log Analytics Workspace | -| [monitor\_action\_group] -(#output\_monitor\_action\_group) | Alerts Action group | -| [monitor\_scheduled\_query\_rules\_alert] -(#output\_monitor\_scheduled\_query\_rules\_alert) | Alerts scheduled query rules | -| [monitor\_autoscale\_setting] -(#output\_monitor\_autoscale\_setting) | Autoscale Setting | -| [monitor\_diagnostic\_setting] -(#output\_monitor\_diagnostic\_setting) | Siagnostic setting | | [logic\_app\_workflow](#output\_logic\_app\_workflow) | Logic App Workflow | | [machine\_learning\_workspace](#output\_machine\_learning\_workspace) | Machine Learning Workspace | | [managed\_disk](#output\_managed\_disk) | Managed Disk | @@ -266,8 +258,13 @@ No modules. | [mariadb\_firewall\_rule](#output\_mariadb\_firewall\_rule) | Mariadb Firewall Rule | | [mariadb\_server](#output\_mariadb\_server) | Mariadb Server | | [mariadb\_virtual\_network\_rule](#output\_mariadb\_virtual\_network\_rule) | Mariadb Virtual Network Rule | +| [monitor\_action\_group](#output\_monitor\_action\_group) | Monitor Action Group | +| [monitor\_autoscale\_setting](#output\_monitor\_autoscale\_setting) | Monitor Autoscale Setting | +| [monitor\_diagnostic\_setting](#output\_monitor\_diagnostic\_setting) | Monitor Diagnostic Setting | +| [monitor\_scheduled\_query\_rules\_alert](#output\_monitor\_scheduled\_query\_rules\_alert) | Monitor Scheduled Query Rules Alert | | [mssql\_database](#output\_mssql\_database) | Mssql Database | | [mssql\_elasticpool](#output\_mssql\_elasticpool) | Mssql Elasticpool | +| [mssql\_managed\_instance](#output\_mssql\_managed\_instance) | Mssql Server Managed Instance | | [mssql\_server](#output\_mssql\_server) | Mssql Server | | [mysql\_database](#output\_mysql\_database) | Mysql Database | | [mysql\_firewall\_rule](#output\_mysql\_firewall\_rule) | Mysql Firewall Rule | diff --git a/docs/defined_specs b/docs/defined_specs index ae8f4a3..3cc8fff 100644 --- a/docs/defined_specs +++ b/docs/defined_specs @@ -53,6 +53,7 @@ az = { azure_data_warehouse = "sqldw" azure_synapse_analytics = "syn" sql_server_strech_database = "sqlstrdb" + mssql_managed_instance = "sqlmi" // Storage storage_account = "st" diff --git a/main.tf b/main.tf index d8446f5..c5f2bb1 100644 --- a/main.tf +++ b/main.tf @@ -1456,6 +1456,16 @@ locals { scope = "global" regex = "^[a-z0-9][a-z0-9-]+[a-z0-9]$" } + mssql_managed_instance = { + name = lower(substr(join("-", compact([local.prefix, "sqlmi", local.suffix])), 0, 63)) + name_unique = lower(substr(join("-", compact([local.prefix, "sqlmi", local.suffix_unique])), 0, 63)) + dashes = true + slug = "sqlmi" + min_length = 1 + max_length = 63 + scope = "global" + regex = "^[a-z0-9][a-z0-9-]+[a-z0-9]$" + } mysql_database = { name = substr(join("-", compact([local.prefix, "mysqldb", local.suffix])), 0, 63) name_unique = substr(join("-", compact([local.prefix, "mysqldb", local.suffix_unique])), 0, 63) @@ -3006,6 +3016,10 @@ locals { valid_name = length(regexall(local.az.mssql_server.regex, local.az.mssql_server.name)) > 0 && length(local.az.mssql_server.name) > local.az.mssql_server.min_length valid_name_unique = length(regexall(local.az.mssql_server.regex, local.az.mssql_server.name_unique)) > 0 } + mssql_managed_instance = { + valid_name = length(regexall(local.az.mssql_managed_instance.regex, local.az.mssql_managed_instance.name)) > 0 && length(local.az.mssql_managed_instance.name) > local.az.mssql_managed_instance.min_length + valid_name_unique = length(regexall(local.az.mssql_managed_instance.regex, local.az.mssql_managed_instance.name_unique)) > 0 + } mysql_database = { valid_name = length(regexall(local.az.mysql_database.regex, local.az.mysql_database.name)) > 0 && length(local.az.mysql_database.name) > local.az.mysql_database.min_length valid_name_unique = length(regexall(local.az.mysql_database.regex, local.az.mysql_database.name_unique)) > 0 diff --git a/outputs.tf b/outputs.tf index ddaba6c..2f907fd 100644 --- a/outputs.tf +++ b/outputs.tf @@ -716,6 +716,11 @@ output "mssql_server" { description = "Mssql Server" } +output "mssql_managed_instance" { + value = local.az.mssql_managed_instance + description = "Mssql Server Managed Instance" +} + output "mysql_database" { value = local.az.mysql_database description = "Mysql Database" diff --git a/resourceDefinition.json b/resourceDefinition.json index a72a556..89d1dd7 100644 --- a/resourceDefinition.json +++ b/resourceDefinition.json @@ -1363,6 +1363,17 @@ "slug": "sql", "dashes": true }, + { + "name": "mssql_managed_instance", + "length": { + "min": 1, + "max": 63 + }, + "regex": "^(?=.{1,63}$)[a-z0-9][a-z0-9-]+[a-z0-9]$", + "scope": "global", + "slug": "sqlmi", + "dashes": true + }, { "name": "mysql_database", "length": {