Skip to content

Commit 8109b42

Browse files
committed
adding example to create SQL DB with geo-replication, auto-failover groups and Private Endpoints
1 parent 83d0870 commit 8109b42

File tree

6 files changed

+288
-292
lines changed

6 files changed

+288
-292
lines changed

examples/README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
Terraform module for Azure to create a MS SQL server with initial database, Azure AD login, Firewall rules, Failover Group, Private endpoint, and corresponding private DNS zone. It also supports creating a database with a custom SQL script initialization.
44

5-
## Module Usage for
5+
## Module Usage for:
66

77
- [Simple SQL Single DB Creation](Simple_SQL_Single_Database_creation/)
8-
- [Simple SQL Single DB with Private link Endpoint](Simple_SQL_Single_Database_Using_Private_Endpoint/)
9-
- [SQL DB with Geo-Replication and Auto Failover Groups](SQL_DB_Using_Geo-replication_with_Auto-Failover_Groups/)
10-
- [SQL DB with Geo-Replication, Private Endpoints, and Auto Failover Groups](SQL_DB_Using_Geo-replication_with_Auto-Failover_Groups_and_Private_Endpoints/)
8+
- [Simple SQL Single DB with Private link Endpoint](Simple_SQL_Single_Database_with_Private_Endpoint/)
9+
- [Simple SQL Single DB with Private link Endpoint using existing VNet and Subnets](Simple_SQL_Single_Database_with_Private_Endpoint_using_existing_VNet_and_Subnets/)
10+
- [SQL DB with Geo-Replication and Auto Failover Groups](SQL_DB_with_Geo-replication_and_Auto-Failover_Groups/)
11+
- [SQL DB with Geo-Replication, Private Endpoints, and Auto Failover Groups](SQL_DB_with_Geo-replication_Auto-Failover_Groups_and_Private_Endpoints/)
12+
- [SQL DB with Geo-Replication, Private Endpoints using existing VNet and Subnets, and Auto Failover Groups](SQL_DB_with_Geo-replication_Auto-Failover_Groups_and_Private_Endpoints_using_existing_VNet_and_Subnets/)
1113

1214
## Terraform Usage
1315

Original file line numberDiff line numberDiff line change
@@ -1,103 +1,100 @@
1-
# Azure SQL database creation using geo-replication with auto-failover groups and Private Endpoints
2-
3-
Terraform module to create a SQL server with initial database, Azure AD login, Firewall rules for SQL, optional azure monitoring, vulnerability assessment, Geo-replication with auto-failover groups and private endpoints. It also allows creating an SQL server database with a SQL script initialization.
4-
5-
## Module Usage
6-
7-
```hcl
8-
# Azurerm provider configuration
9-
provider "azurerm" {
10-
features {}
11-
}
12-
13-
module "mssql-server" {
14-
source = "kumarvna/mssql-db/azurerm"
15-
version = "1.2.0"
16-
17-
# By default, this module will create a resource group
18-
# proivde a name to use an existing resource group and set the argument
19-
# to `create_resource_group = false` if you want to existing resoruce group.
20-
# If you use existing resrouce group location will be the same as existing RG.
21-
create_resource_group = false
22-
resource_group_name = "rg-shared-westeurope-01"
23-
location = "westeurope"
24-
virtual_network_name = "vnet-shared-hub-westeurope-001"
25-
private_subnet_address_prefix = ["10.1.5.0/29"]
26-
27-
# SQL Server and Database details
28-
# The valid service objective name for the database include S0, S1, S2, S3, P1, P2, P4, P6, P11
29-
sqlserver_name = "sqldbserver01"
30-
database_name = "demomssqldb"
31-
sql_database_edition = "Standard"
32-
sqldb_service_objective_name = "S1"
33-
34-
# SQL server extended auditing policy defaults to `true`.
35-
# To turn off set enable_sql_server_extended_auditing_policy to `false`
36-
# DB extended auditing policy defaults to `false`.
37-
# to tun on set the variable `enable_database_extended_auditing_policy` to `true`
38-
# To enable Azure Defender for database set `enable_threat_detection_policy` to true
39-
enable_threat_detection_policy = true
40-
log_retention_days = 30
41-
42-
# schedule scan notifications to the subscription administrators
43-
# Manage Vulnerability Assessment set `enable_vulnerability_assessment` to `true`
44-
enable_vulnerability_assessment = false
45-
email_addresses_for_alerts = ["[email protected]", "[email protected]"]
46-
47-
# Sql failover group creation. required secondary locaiton input.
48-
enable_failover_group = true
49-
secondary_sql_server_location = "northeurope"
50-
51-
# enabling the Private Endpoints for Sql servers
52-
enable_private_endpoint = true
53-
54-
# AD administrator for an Azure SQL server
55-
# Allows you to set a user or group as the AD administrator for an Azure SQL server
56-
ad_admin_login_name = "[email protected]"
57-
58-
# (Optional) To enable Azure Monitoring for Azure SQL database including audit logs
59-
# log analytic workspace name required
60-
enable_log_monitoring = true
61-
log_analytics_workspace_name = "loganalytics-we-sharedtest2"
62-
63-
# Firewall Rules to allow azure and external clients and specific Ip address/ranges.
64-
enable_firewall_rules = true
65-
firewall_rules = [
66-
{
67-
name = "access-to-azure"
68-
start_ip_address = "0.0.0.0"
69-
end_ip_address = "0.0.0.0"
70-
},
71-
{
72-
name = "desktop-ip"
73-
start_ip_address = "49.204.225.134"
74-
end_ip_address = "49.204.225.134"
75-
}
76-
]
77-
78-
# Create and initialize a database with custom SQL script
79-
# need sqlcmd utility to run this command
80-
# your desktop public IP must be added to firewall rules to run this command
81-
initialize_sql_script_execution = true
82-
sqldb_init_script_file = "../artifacts/db-init-sample.sql"
83-
84-
# Tags for Azure Resources
85-
tags = {
86-
Terraform = "true"
87-
Environment = "dev"
88-
Owner = "test-user"
89-
}
90-
}
91-
```
92-
93-
## Terraform Usage
94-
95-
To run this example you need to execute following Terraform commands
96-
97-
```bash
98-
terraform init
99-
terraform plan
100-
terraform apply
101-
```
102-
103-
Run `terraform destroy` when you don't need these resources.
1+
# Azure SQL database creation with geo-replication, auto-failover groups and Private Endpoints
2+
3+
Terraform module to create a SQL server with initial database, Azure AD login, Firewall rules for SQL, optional azure monitoring, vulnerability assessment, Geo-replication with auto-failover groups and private endpoints. It also allows creating an SQL server database with a SQL script initialization.
4+
5+
## Module Usage
6+
7+
```terraform
8+
# Azurerm provider configuration
9+
provider "azurerm" {
10+
features {}
11+
}
12+
13+
module "mssql-server" {
14+
source = "kumarvna/mssql-db/azurerm"
15+
version = "1.3.0"
16+
17+
# By default, this module will create a resource group
18+
# proivde a name to use an existing resource group and set the argument
19+
# to `create_resource_group = false` if you want to existing resoruce group.
20+
# If you use existing resrouce group location will be the same as existing RG.
21+
create_resource_group = false
22+
resource_group_name = "rg-shared-westeurope-01"
23+
location = "westeurope"
24+
25+
# SQL Server and Database details
26+
# The valid service objective name for the database include S0, S1, S2, S3, P1, P2, P4, P6, P11
27+
sqlserver_name = "te-sqldbserver01"
28+
database_name = "demomssqldb"
29+
sql_database_edition = "Standard"
30+
sqldb_service_objective_name = "S1"
31+
32+
# SQL server extended auditing policy defaults to `true`.
33+
# To turn off set enable_sql_server_extended_auditing_policy to `false`
34+
# DB extended auditing policy defaults to `false`.
35+
# to tun on set the variable `enable_database_extended_auditing_policy` to `true`
36+
# To enable Azure Defender for database set `enable_threat_detection_policy` to true
37+
enable_threat_detection_policy = true
38+
log_retention_days = 30
39+
40+
# schedule scan notifications to the subscription administrators
41+
# Manage Vulnerability Assessment set `enable_vulnerability_assessment` to `true`
42+
enable_vulnerability_assessment = false
43+
email_addresses_for_alerts = ["[email protected]", "[email protected]"]
44+
45+
# Sql failover group creation. required secondary locaiton input.
46+
enable_failover_group = true
47+
secondary_sql_server_location = "northeurope"
48+
49+
# enabling the Private Endpoints for Sql servers
50+
enable_private_endpoint = true
51+
virtual_network_name = "vnet-shared-hub-westeurope-001"
52+
private_subnet_address_prefix = ["10.1.5.0/29"]
53+
# existing_private_dns_zone = "demo.example.com"
54+
55+
# AD administrator for an Azure SQL server
56+
# Allows you to set a user or group as the AD administrator for an Azure SQL server
57+
ad_admin_login_name = "[email protected]"
58+
59+
# (Optional) To enable Azure Monitoring for Azure SQL database including audit logs
60+
# log analytic workspace name required
61+
enable_log_monitoring = true
62+
log_analytics_workspace_name = "loganalytics-we-sharedtest2"
63+
64+
# Firewall Rules to allow azure and external clients and specific Ip address/ranges.
65+
enable_firewall_rules = true
66+
firewall_rules = [
67+
{
68+
name = "access-to-azure"
69+
start_ip_address = "0.0.0.0"
70+
end_ip_address = "0.0.0.0"
71+
},
72+
{
73+
name = "desktop-ip"
74+
start_ip_address = "123.201.36.94"
75+
end_ip_address = "123.201.36.94"
76+
}
77+
]
78+
79+
# Adding additional TAG's to your Azure resources
80+
tags = {
81+
ProjectName = "demo-project"
82+
Env = "dev"
83+
84+
BusinessUnit = "CORP"
85+
ServiceClass = "Gold"
86+
}
87+
}
88+
```
89+
90+
## Terraform Usage
91+
92+
To run this example you need to execute following Terraform commands
93+
94+
```bash
95+
terraform init
96+
terraform plan
97+
terraform apply
98+
```
99+
100+
Run `terraform destroy` when you don't need these resources.
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,80 @@
1-
# Azurerm provider configuration
2-
provider "azurerm" {
3-
features {}
4-
}
5-
6-
module "mssql-server" {
7-
source = "kumarvna/mssql-db/azurerm"
8-
version = "1.2.0"
9-
10-
# By default, this module will create a resource group
11-
# proivde a name to use an existing resource group and set the argument
12-
# to `create_resource_group = false` if you want to existing resoruce group.
13-
# If you use existing resrouce group location will be the same as existing RG.
14-
create_resource_group = false
15-
resource_group_name = "rg-shared-westeurope-01"
16-
location = "westeurope"
17-
virtual_network_name = "vnet-shared-hub-westeurope-001"
18-
private_subnet_address_prefix = ["10.1.5.0/29"]
19-
20-
# SQL Server and Database details
21-
# The valid service objective name for the database include S0, S1, S2, S3, P1, P2, P4, P6, P11
22-
sqlserver_name = "sqldbserver01"
23-
database_name = "demomssqldb"
24-
sql_database_edition = "Standard"
25-
sqldb_service_objective_name = "S1"
26-
27-
# SQL server extended auditing policy defaults to `true`.
28-
# To turn off set enable_sql_server_extended_auditing_policy to `false`
29-
# DB extended auditing policy defaults to `false`.
30-
# to tun on set the variable `enable_database_extended_auditing_policy` to `true`
31-
# To enable Azure Defender for database set `enable_threat_detection_policy` to true
32-
enable_threat_detection_policy = true
33-
log_retention_days = 30
34-
35-
# schedule scan notifications to the subscription administrators
36-
# Manage Vulnerability Assessment set `enable_vulnerability_assessment` to `true`
37-
enable_vulnerability_assessment = false
38-
email_addresses_for_alerts = ["[email protected]", "[email protected]"]
39-
40-
# Sql failover group creation. required secondary locaiton input.
41-
enable_failover_group = true
42-
secondary_sql_server_location = "northeurope"
43-
44-
# enabling the Private Endpoints for Sql servers
45-
enable_private_endpoint = true
46-
47-
# AD administrator for an Azure SQL server
48-
# Allows you to set a user or group as the AD administrator for an Azure SQL server
49-
ad_admin_login_name = "[email protected]"
50-
51-
# (Optional) To enable Azure Monitoring for Azure SQL database including audit logs
52-
# log analytic workspace name required
53-
enable_log_monitoring = true
54-
log_analytics_workspace_name = "loganalytics-we-sharedtest2"
55-
56-
# Firewall Rules to allow azure and external clients and specific Ip address/ranges.
57-
enable_firewall_rules = true
58-
firewall_rules = [
59-
{
60-
name = "access-to-azure"
61-
start_ip_address = "0.0.0.0"
62-
end_ip_address = "0.0.0.0"
63-
},
64-
{
65-
name = "desktop-ip"
66-
start_ip_address = "49.204.225.134"
67-
end_ip_address = "49.204.225.134"
68-
}
69-
]
70-
71-
# Create and initialize a database with custom SQL script
72-
# need sqlcmd utility to run this command
73-
# your desktop public IP must be added to firewall rules to run this command
74-
initialize_sql_script_execution = true
75-
sqldb_init_script_file = "../artifacts/db-init-sample.sql"
76-
77-
# Tags for Azure Resources
78-
tags = {
79-
Terraform = "true"
80-
Environment = "dev"
81-
Owner = "test-user"
82-
}
83-
}
1+
# Azurerm provider configuration
2+
provider "azurerm" {
3+
features {}
4+
}
5+
6+
module "mssql-server" {
7+
source = "kumarvna/mssql-db/azurerm"
8+
version = "1.3.0"
9+
10+
# By default, this module will create a resource group
11+
# proivde a name to use an existing resource group and set the argument
12+
# to `create_resource_group = false` if you want to existing resoruce group.
13+
# If you use existing resrouce group location will be the same as existing RG.
14+
create_resource_group = false
15+
resource_group_name = "rg-shared-westeurope-01"
16+
location = "westeurope"
17+
18+
# SQL Server and Database details
19+
# The valid service objective name for the database include S0, S1, S2, S3, P1, P2, P4, P6, P11
20+
sqlserver_name = "te-sqldbserver01"
21+
database_name = "demomssqldb"
22+
sql_database_edition = "Standard"
23+
sqldb_service_objective_name = "S1"
24+
25+
# SQL server extended auditing policy defaults to `true`.
26+
# To turn off set enable_sql_server_extended_auditing_policy to `false`
27+
# DB extended auditing policy defaults to `false`.
28+
# to tun on set the variable `enable_database_extended_auditing_policy` to `true`
29+
# To enable Azure Defender for database set `enable_threat_detection_policy` to true
30+
enable_threat_detection_policy = true
31+
log_retention_days = 30
32+
33+
# schedule scan notifications to the subscription administrators
34+
# Manage Vulnerability Assessment set `enable_vulnerability_assessment` to `true`
35+
enable_vulnerability_assessment = false
36+
email_addresses_for_alerts = ["[email protected]", "[email protected]"]
37+
38+
# Sql failover group creation. required secondary locaiton input.
39+
enable_failover_group = true
40+
secondary_sql_server_location = "northeurope"
41+
42+
# enabling the Private Endpoints for Sql servers
43+
enable_private_endpoint = true
44+
virtual_network_name = "vnet-shared-hub-westeurope-001"
45+
private_subnet_address_prefix = ["10.1.5.0/29"]
46+
# existing_private_dns_zone = "demo.example.com"
47+
48+
# AD administrator for an Azure SQL server
49+
# Allows you to set a user or group as the AD administrator for an Azure SQL server
50+
ad_admin_login_name = "[email protected]"
51+
52+
# (Optional) To enable Azure Monitoring for Azure SQL database including audit logs
53+
# log analytic workspace name required
54+
enable_log_monitoring = true
55+
log_analytics_workspace_name = "loganalytics-we-sharedtest2"
56+
57+
# Firewall Rules to allow azure and external clients and specific Ip address/ranges.
58+
enable_firewall_rules = true
59+
firewall_rules = [
60+
{
61+
name = "access-to-azure"
62+
start_ip_address = "0.0.0.0"
63+
end_ip_address = "0.0.0.0"
64+
},
65+
{
66+
name = "desktop-ip"
67+
start_ip_address = "123.201.36.94"
68+
end_ip_address = "123.201.36.94"
69+
}
70+
]
71+
72+
# Adding additional TAG's to your Azure resources
73+
tags = {
74+
ProjectName = "demo-project"
75+
Env = "dev"
76+
77+
BusinessUnit = "CORP"
78+
ServiceClass = "Gold"
79+
}
80+
}

0 commit comments

Comments
 (0)