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
303resource "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
6770resource "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+ }
0 commit comments