Skip to content

Commit 83d0870

Browse files
committed
updating example for SQL DB with geo-replication and auto failover groups
1 parent d89c2d2 commit 83d0870

File tree

7 files changed

+240
-248
lines changed

7 files changed

+240
-248
lines changed

examples/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ Terraform module for Azure to create a MS SQL server with initial database, Azur
44

55
## Module Usage for
66

7-
[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/)
7+
- [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/)
1111

1212
## Terraform Usage
1313

Lines changed: 94 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,94 @@
1-
# Azure SQL database creation using geo-replication with auto-failover groups
2-
3-
Terraform module to create a SQL server with initial database, Azure AD login, Firewall rules for SQL, optional azure monitoring, vulnerability assessment and Geo-replication with auto-failover groups. 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-
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 = "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-
# AD administrator for an Azure SQL server
46-
# Allows you to set a user or group as the AD administrator for an Azure SQL server
47-
ad_admin_login_name = "[email protected]"
48-
49-
# (Optional) To enable Azure Monitoring for Azure SQL database including audit logs
50-
# log analytic workspace name required
51-
enable_log_monitoring = true
52-
log_analytics_workspace_name = "loganalytics-we-sharedtest2"
53-
54-
# Sql failover group creation. required secondary locaiton input.
55-
enable_failover_group = true
56-
secondary_sql_server_location = "northeurope"
57-
58-
# Firewall Rules to allow azure and external clients and specific Ip address/ranges.
59-
enable_firewall_rules = true
60-
firewall_rules = [
61-
{
62-
name = "access-to-azure"
63-
start_ip_address = "0.0.0.0"
64-
end_ip_address = "0.0.0.0"
65-
},
66-
{
67-
name = "desktop-ip"
68-
start_ip_address = "49.204.225.134"
69-
end_ip_address = "49.204.225.134"
70-
}
71-
]
72-
73-
# Create and initialize a database with custom SQL script
74-
# need sqlcmd utility to run this command
75-
# your desktop public IP must be added firewall rules to run this command
76-
initialize_sql_script_execution = true
77-
sqldb_init_script_file = "../artifacts/db-init-sample.sql"
78-
79-
# Tags for Azure Resources
80-
tags = {
81-
Terraform = "true"
82-
Environment = "dev"
83-
Owner = "test-user"
84-
}
85-
}
86-
```
87-
88-
## Terraform Usage
89-
90-
To run this example you need to execute following Terraform commands
91-
92-
```bash
93-
terraform init
94-
terraform plan
95-
terraform apply
96-
```
97-
98-
Run `terraform destroy` when you don't need these resources.
1+
# Azure SQL database creation using geo-replication with auto-failover groups
2+
3+
Terraform module to create a SQL server with initial database, Azure AD login, Firewall rules for SQL, optional azure monitoring, vulnerability assessment and Geo-replication with auto-failover groups. 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 = "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+
# AD administrator for an Azure SQL server
46+
# Allows you to set a user or group as the AD administrator for an Azure SQL server
47+
ad_admin_login_name = "[email protected]"
48+
49+
# (Optional) To enable Azure Monitoring for Azure SQL database including audit logs
50+
# log analytic workspace name required
51+
enable_log_monitoring = true
52+
log_analytics_workspace_name = "loganalytics-we-sharedtest2"
53+
54+
# Sql failover group creation. required secondary locaiton input.
55+
enable_failover_group = true
56+
secondary_sql_server_location = "northeurope"
57+
58+
# Firewall Rules to allow azure and external clients and specific Ip address/ranges.
59+
enable_firewall_rules = true
60+
firewall_rules = [
61+
{
62+
name = "access-to-azure"
63+
start_ip_address = "0.0.0.0"
64+
end_ip_address = "0.0.0.0"
65+
},
66+
{
67+
name = "desktop-ip"
68+
start_ip_address = "49.204.225.134"
69+
end_ip_address = "49.204.225.134"
70+
}
71+
]
72+
73+
# Adding additional TAG's to your Azure resources
74+
tags = {
75+
ProjectName = "demo-project"
76+
Env = "dev"
77+
78+
BusinessUnit = "CORP"
79+
ServiceClass = "Gold"
80+
}
81+
}
82+
```
83+
84+
## Terraform Usage
85+
86+
To run this example you need to execute following Terraform commands
87+
88+
```bash
89+
terraform init
90+
terraform plan
91+
terraform apply
92+
```
93+
94+
Run `terraform destroy` when you don't need these resources.
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,74 @@
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-
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 = "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-
# AD administrator for an Azure SQL server
39-
# Allows you to set a user or group as the AD administrator for an Azure SQL server
40-
ad_admin_login_name = "[email protected]"
41-
42-
# (Optional) To enable Azure Monitoring for Azure SQL database including audit logs
43-
# log analytic workspace name required
44-
enable_log_monitoring = true
45-
log_analytics_workspace_name = "loganalytics-we-sharedtest2"
46-
47-
# Sql failover group creation. required secondary locaiton input.
48-
enable_failover_group = true
49-
secondary_sql_server_location = "northeurope"
50-
51-
# Firewall Rules to allow azure and external clients and specific Ip address/ranges.
52-
enable_firewall_rules = true
53-
firewall_rules = [
54-
{
55-
name = "access-to-azure"
56-
start_ip_address = "0.0.0.0"
57-
end_ip_address = "0.0.0.0"
58-
},
59-
{
60-
name = "desktop-ip"
61-
start_ip_address = "49.204.225.134"
62-
end_ip_address = "49.204.225.134"
63-
}
64-
]
65-
66-
# Create and initialize a database with custom SQL script
67-
# need sqlcmd utility to run this command
68-
# your desktop public IP must be added firewall rules to run this command
69-
initialize_sql_script_execution = true
70-
sqldb_init_script_file = "../artifacts/db-init-sample.sql"
71-
72-
# Tags for Azure Resources
73-
tags = {
74-
Terraform = "true"
75-
Environment = "dev"
76-
Owner = "test-user"
77-
}
78-
}
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 = "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+
# AD administrator for an Azure SQL server
39+
# Allows you to set a user or group as the AD administrator for an Azure SQL server
40+
ad_admin_login_name = "[email protected]"
41+
42+
# (Optional) To enable Azure Monitoring for Azure SQL database including audit logs
43+
# log analytic workspace name required
44+
enable_log_monitoring = true
45+
log_analytics_workspace_name = "loganalytics-we-sharedtest2"
46+
47+
# Sql failover group creation. required secondary locaiton input.
48+
enable_failover_group = true
49+
secondary_sql_server_location = "northeurope"
50+
51+
# Firewall Rules to allow azure and external clients and specific Ip address/ranges.
52+
enable_firewall_rules = true
53+
firewall_rules = [
54+
{
55+
name = "access-to-azure"
56+
start_ip_address = "0.0.0.0"
57+
end_ip_address = "0.0.0.0"
58+
},
59+
{
60+
name = "desktop-ip"
61+
start_ip_address = "49.204.225.134"
62+
end_ip_address = "49.204.225.134"
63+
}
64+
]
65+
66+
# Adding additional TAG's to your Azure resources
67+
tags = {
68+
ProjectName = "demo-project"
69+
Env = "dev"
70+
71+
BusinessUnit = "CORP"
72+
ServiceClass = "Gold"
73+
}
74+
}

0 commit comments

Comments
 (0)