Skip to content

Commit 3f2673d

Browse files
authored
Review sqlmi (#57)
* review code * upgrade to 3.41.0
1 parent fd95f37 commit 3f2673d

File tree

6 files changed

+69
-148
lines changed

6 files changed

+69
-148
lines changed

.github/workflows/sql-managed-instance.yml

Lines changed: 0 additions & 77 deletions
This file was deleted.

terraform/sql-managed-instance/main.tf

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,4 @@
1-
# Associate subnet and the security group
2-
resource "azurerm_subnet_network_security_group_association" "adl_sqlmi" {
3-
subnet_id = var.subnet_id
4-
network_security_group_id = var.network_security_group_id
5-
count = var.module_enabled ? 1 : 0
6-
}
7-
8-
# Associate subnet and the route table
9-
resource "azurerm_subnet_route_table_association" "adl_sqlmi" {
10-
subnet_id = var.subnet_id
11-
route_table_id = var.route_table_id
12-
count = var.module_enabled ? 1 : 0
13-
}
14-
15-
# Associate subnet and the security group
16-
resource "azurerm_subnet_network_security_group_association" "adl_sqlmi_pe" {
17-
subnet_id = var.subnet_private_enpoint_id
18-
network_security_group_id = var.network_security_group_id
19-
count = var.is_sec_module && var.module_enabled ? 1 : 0
20-
}
21-
22-
# Associate subnet and the route table
23-
resource "azurerm_subnet_route_table_association" "adl_sqlmi_pe" {
24-
subnet_id = var.subnet_private_enpoint_id
25-
route_table_id = var.route_table_id
26-
count = var.is_sec_module && var.module_enabled ? 1 : 0
27-
}
28-
1+
# https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/mssql_managed_instance
292

303
resource "azurerm_mssql_managed_instance" "adl_sqlmi" {
314
name = "sqlmi-${var.basename}"
@@ -57,11 +30,41 @@ resource "azurerm_mssql_managed_instance" "adl_sqlmi" {
5730
tags = var.tags
5831

5932
depends_on = [
60-
azurerm_subnet_network_security_group_association.adl_sqlmi,
61-
azurerm_subnet_route_table_association.adl_sqlmi
33+
azurerm_subnet_network_security_group_association.adl_sqlmi_snet_nsg,
34+
azurerm_subnet_route_table_association.adl_sqlmi_snet_rt
6235
]
6336
}
6437

38+
# Network configuration
39+
40+
# Associate subnet and the security group
41+
resource "azurerm_subnet_network_security_group_association" "adl_sqlmi_snet_nsg" {
42+
subnet_id = var.subnet_id
43+
network_security_group_id = var.network_security_group_id
44+
count = var.module_enabled ? 1 : 0
45+
}
46+
47+
# Associate subnet and the route table
48+
resource "azurerm_subnet_route_table_association" "adl_sqlmi_snet_rt" {
49+
subnet_id = var.subnet_id
50+
route_table_id = var.route_table_id
51+
count = var.module_enabled ? 1 : 0
52+
}
53+
54+
# Associate subnet and the security group
55+
resource "azurerm_subnet_network_security_group_association" "adl_sqlmi_snet_nsg_pe" {
56+
subnet_id = var.subnet_private_enpoint_id
57+
network_security_group_id = var.network_security_group_id
58+
count = var.is_sec_module && var.module_enabled ? 1 : 0
59+
}
60+
61+
# Associate subnet and the route table
62+
resource "azurerm_subnet_route_table_association" "adl_sqlmi_snet_rt_pe" {
63+
subnet_id = var.subnet_private_enpoint_id
64+
route_table_id = var.route_table_id
65+
count = var.is_sec_module && var.module_enabled ? 1 : 0
66+
}
67+
6568
# Private Endpoint configuration
6669

6770
resource "azurerm_private_endpoint" "sqlmi_pe_server" {
@@ -84,5 +87,4 @@ resource "azurerm_private_endpoint" "sqlmi_pe_server" {
8487
count = var.is_sec_module && var.module_enabled ? 1 : 0
8588

8689
tags = var.tags
87-
}
88-
90+
}

terraform/sql-managed-instance/outputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ output "id" {
33
length(azurerm_mssql_managed_instance.adl_sqlmi) > 0 ?
44
azurerm_mssql_managed_instance.adl_sqlmi[0].id : ""
55
)
6-
}
6+
}

terraform/sql-managed-instance/test/providers.tf

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@ terraform {
33
resource_group_name = "rg-adl-terraform-state"
44
storage_account_name = "stadltfstate"
55
container_name = "default"
6-
key = "sqlami.terraform.tfstate"
7-
8-
6+
key = "sqlmi.terraform.tfstate"
97
}
108

119
required_providers {
1210
azurerm = {
1311
source = "hashicorp/azurerm"
14-
version = "= 3.30.0"
12+
version = "= 3.41.0"
1513
}
1614
}
1715

@@ -23,4 +21,4 @@ provider "azurerm" {
2321
prevent_deletion_if_contains_resources = false
2422
}
2523
}
26-
}
24+
}

terraform/sql-managed-instance/test/sql_managed_instance.tf

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,34 @@
1+
module "sql_managed_instance" {
2+
source = "../"
3+
4+
basename = "sqlmi-${random_string.postfix.result}"
5+
rg_name = module.local_rg.name
6+
location = var.location
7+
subnet_id = module.local_snet_default.id
8+
subnet_private_enpoint_id = module.local_snet_private_enpoint.id
9+
route_table_id = module.route_table.id
10+
network_security_group_id = module.network_security_group.id
11+
administrator_login = "sqladminuser"
12+
administrator_login_password = "ThisIsNotVerySecure!"
13+
module_enabled = true
14+
is_sec_module = var.is_sec_module
15+
tags = {}
16+
license_type = "BasePrice"
17+
sku_name = "GP_Gen5"
18+
storage_size_in_gb = 32
19+
vcores = 4
20+
maintenance_configuration_name = "SQL_Default"
21+
dns_zone_partner_id = ""
22+
collation = "SQL_Latin1_General_CP1_CI_AS"
23+
minimum_tls_version = "1.2"
24+
proxy_override = "Default"
25+
public_data_endpoint_enabled = false
26+
storage_account_type = "GRS"
27+
timezone_id = "UTC"
28+
}
129

230
# Modules dependencies
31+
332
module "local_rg" {
433
source = "../../resource-group"
534
basename = random_string.postfix.result
@@ -50,35 +79,4 @@ module "route_table" {
5079
rg_name = module.local_rg.name
5180
location = var.location
5281
tags = {}
53-
}
54-
55-
// sql_managed_instance module
56-
module "sql_managed_instance" {
57-
source = "git::https://github.com/Azure/azure-data-labs-modules.git//terraform/sql-managed-instance?ref=feature/sqlami"
58-
basename = "sqlmi-${random_string.postfix.result}"
59-
rg_name = module.local_rg.name
60-
location = var.location
61-
subnet_id = module.local_snet_default.id
62-
subnet_private_enpoint_id = module.local_snet_private_enpoint.id
63-
route_table_id = module.route_table.id
64-
network_security_group_id = module.network_security_group.id
65-
administrator_login = "sqladminuser"
66-
administrator_login_password = "ThisIsNotVerySecure!"
67-
module_enabled = true
68-
is_sec_module = var.is_sec_module
69-
tags = {}
70-
license_type = "BasePrice"
71-
sku_name = "GP_Gen5"
72-
storage_size_in_gb = 32
73-
vcores = 4
74-
maintenance_configuration_name = "SQL_Default"
75-
dns_zone_partner_id = ""
76-
collation = "SQL_Latin1_General_CP1_CI_AS"
77-
minimum_tls_version = "1.2"
78-
proxy_override = "Default"
79-
public_data_endpoint_enabled = false
80-
storage_account_type = "GRS"
81-
timezone_id = "UTC"
82-
83-
}
84-
82+
}

terraform/sql-managed-instance/test/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ variable "rg_name_dns" {
1717
variable "is_sec_module" {
1818
type = bool
1919
description = "Is secure module?"
20-
default = true
20+
default = false
2121
}

0 commit comments

Comments
 (0)