Skip to content

Commit 11aa923

Browse files
authored
Merge pull request #1 from kumarvna/develop
adding terraform v0.15 support
2 parents 63e6703 + cfbbf4d commit 11aa923

File tree

20 files changed

+1333
-866
lines changed

20 files changed

+1333
-866
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ override.tf.json
2929
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
3030
# example: *tfplan*
3131
versions.tf
32+
examples/artifacts/db-init-sample.log

README.md

Lines changed: 173 additions & 166 deletions
Large diffs are not rendered by default.

examples/README.md

Lines changed: 276 additions & 221 deletions
Large diffs are not rendered by default.
Lines changed: 71 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,76 @@
1-
# Azure SQL Database Using Failover Groups with Private endpoints
1+
# Azure SQL database creation using geo-replication with auto-failover groups
22

3-
Terraform module for Azure to create a SQL server with initial database, Azure AD login, Firewall rules for SQL, Failover Group, Private endpoint, and corresponding private DNS zone for privatelink A records. It also allows creating an SQL server database with a SQL script initialization.
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.
44

55
## Module Usage
66

7-
### Azure SQL database creation using geo-replication with auto-failover groups
8-
9-
Following example to create a SQL database using geo-replication with auto-failover groups. This module also supports optional AD admin user for DB, Audit Policies, Firewall Rules, and creation of database schema using SQL script.
10-
11-
```
7+
```hcl
128
module "mssql-server" {
13-
source = "kumarvna/mssql-db/azurerm"
14-
version = "1.0.0"
15-
16-
# Resource Group, VNet and Subnet declarations
17-
create_resource_group = false
18-
resource_group_name = "rg-demo-westeurope-01"
19-
location = "westeurope"
20-
virtual_network_name = "vnet-demo-westeurope-001"
21-
private_subnet_address_prefix = "10.0.5.0/29"
22-
23-
# SQL Server and Database scaling options
24-
sqlserver_name = "sqldbserver-db01"
25-
database_name = "demomssqldb"
26-
sql_database_edition = "Standard"
27-
sqldb_service_objective_name = "S1"
28-
29-
# SQL Server and Database Audit policies
30-
enable_auditing_policy = true
31-
enable_threat_detection_policy = true
32-
log_retention_days = 30
33-
email_addresses_for_alerts = ["[email protected]"]
34-
35-
# AD administrator for an Azure SQL server
36-
enable_sql_ad_admin = true
37-
ad_admin_login_name = "[email protected]"
38-
39-
# Firewall Rules to allow azure and external clients
40-
enable_firewall_rules = true
9+
source = "kumarvna/mssql-db/azurerm"
10+
version = "1.1.0"
11+
12+
# By default, this module will not create a resource group
13+
# proivde a name to use an existing resource group, specify the existing resource group name,
14+
# and set the argument to `create_resource_group = false`. Location will be same as existing RG.
15+
resource_group_name = "rg-shared-westeurope-01"
16+
location = "westeurope"
17+
virtual_network_name = "vnet-shared-hub-westeurope-001"
18+
19+
# SQL Server and Database details
20+
# The valid service objective name for the database include S0, S1, S2, S3, P1, P2, P4, P6, P11
21+
sqlserver_name = "sqldbserver01"
22+
database_name = "demomssqldb"
23+
sql_database_edition = "Standard"
24+
sqldb_service_objective_name = "S1"
25+
26+
# SQL server extended auditing policy defaults to `true`.
27+
# To turn off set enable_sql_server_extended_auditing_policy to `false`
28+
# DB extended auditing policy defaults to `false`.
29+
# to tun on set the variable `enable_database_extended_auditing_policy` to `true`
30+
# To enable Azure Defender for database set `enable_threat_detection_policy` to true
31+
enable_threat_detection_policy = true
32+
log_retention_days = 30
33+
34+
# schedule scan notifications to the subscription administrators
35+
# Manage Vulnerability Assessment set `enable_vulnerability_assessment` to `true`
36+
enable_vulnerability_assessment = false
37+
email_addresses_for_alerts = ["[email protected]", "[email protected]"]
38+
39+
# AD administrator for an Azure SQL server
40+
# Allows you to set a user or group as the AD administrator for an Azure SQL server
41+
ad_admin_login_name = "[email protected]"
42+
43+
# (Optional) To enable Azure Monitoring for Azure SQL database including audit logs
44+
# log analytic workspace name required
45+
enable_log_monitoring = true
46+
log_analytics_workspace_name = "loganalytics-we-sharedtest2"
47+
48+
# Sql failover group creation. required secondary locaiton input.
49+
enable_failover_group = true
50+
secondary_sql_server_location = "northeurope"
51+
52+
# Firewall Rules to allow azure and external clients and specific Ip address/ranges.
53+
enable_firewall_rules = true
4154
firewall_rules = [
42-
{name = "access-to-azure"
43-
start_ip_address = "0.0.0.0"
44-
end_ip_address = "0.0.0.0"},
45-
{name = "desktop-ip"
46-
start_ip_address = "123.201.75.71"
47-
end_ip_address = "123.201.75.71"}]
48-
49-
# Sql failover group
50-
enable_failover_group = true
51-
secondary_sql_server_location = "northeurope"
52-
53-
# Create and initialize a database with SQL script
54-
initialize_sql_script_execution = false
55-
sqldb_init_script_file = "./artifacts/db-init-sample.sql"
56-
57-
# Tags for Azure Resources
55+
{
56+
name = "access-to-azure"
57+
start_ip_address = "0.0.0.0"
58+
end_ip_address = "0.0.0.0"
59+
},
60+
{
61+
name = "desktop-ip"
62+
start_ip_address = "49.204.225.134"
63+
end_ip_address = "49.204.225.134"
64+
}
65+
]
66+
67+
# Create and initialize a database with custom SQL script
68+
# need sqlcmd utility to run this command
69+
# your desktop public IP must be added firewall rules to run this command
70+
initialize_sql_script_execution = true
71+
sqldb_init_script_file = "../artifacts/db-init-sample.sql"
72+
73+
# Tags for Azure Resources
5874
tags = {
5975
Terraform = "true"
6076
Environment = "dev"
@@ -67,10 +83,10 @@ module "mssql-server" {
6783

6884
To run this example you need to execute following Terraform commands
6985

70-
```
71-
$ terraform init
72-
$ terraform plan
73-
$ terraform apply
86+
```bash
87+
terraform init
88+
terraform plan
89+
terraform apply
7490
```
7591

7692
Run `terraform destroy` when you don't need these resources.
Lines changed: 65 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,72 @@
11
module "mssql-server" {
2-
source = "kumarvna/mssql-db/azurerm"
3-
version = "1.0.0"
4-
5-
# Resource Group, VNet and Subnet declarations
6-
create_resource_group = false
7-
resource_group_name = "rg-demo-westeurope-01"
8-
location = "westeurope"
9-
virtual_network_name = "vnet-demo-westeurope-001"
10-
private_subnet_address_prefix = "10.0.5.0/29"
11-
12-
# SQL Server and Database scaling options
13-
sqlserver_name = "sqldbserver-db01"
14-
database_name = "demomssqldb"
15-
sql_database_edition = "Standard"
16-
sqldb_service_objective_name = "S1"
17-
18-
# SQL Server and Database Audit policies
19-
enable_auditing_policy = true
20-
enable_threat_detection_policy = true
21-
log_retention_days = 30
22-
email_addresses_for_alerts = ["[email protected]"]
23-
24-
# AD administrator for an Azure SQL server
25-
enable_sql_ad_admin = true
26-
ad_admin_login_name = "[email protected]"
27-
28-
# Firewall Rules to allow azure and external clients
29-
enable_firewall_rules = true
2+
source = "kumarvna/mssql-db/azurerm"
3+
version = "1.1.0"
4+
5+
# By default, this module will not create a resource group
6+
# proivde a name to use an existing resource group, specify the existing resource group name,
7+
# and set the argument to `create_resource_group = false`. Location will be same as existing RG.
8+
resource_group_name = "rg-shared-westeurope-01"
9+
location = "westeurope"
10+
virtual_network_name = "vnet-shared-hub-westeurope-001"
11+
12+
# SQL Server and Database details
13+
# The valid service objective name for the database include S0, S1, S2, S3, P1, P2, P4, P6, P11
14+
sqlserver_name = "sqldbserver01"
15+
database_name = "demomssqldb"
16+
sql_database_edition = "Standard"
17+
sqldb_service_objective_name = "S1"
18+
19+
# SQL server extended auditing policy defaults to `true`.
20+
# To turn off set enable_sql_server_extended_auditing_policy to `false`
21+
# DB extended auditing policy defaults to `false`.
22+
# to tun on set the variable `enable_database_extended_auditing_policy` to `true`
23+
# To enable Azure Defender for database set `enable_threat_detection_policy` to true
24+
enable_threat_detection_policy = true
25+
log_retention_days = 30
26+
27+
# schedule scan notifications to the subscription administrators
28+
# Manage Vulnerability Assessment set `enable_vulnerability_assessment` to `true`
29+
enable_vulnerability_assessment = false
30+
email_addresses_for_alerts = ["[email protected]", "[email protected]"]
31+
32+
# AD administrator for an Azure SQL server
33+
# Allows you to set a user or group as the AD administrator for an Azure SQL server
34+
ad_admin_login_name = "[email protected]"
35+
36+
# (Optional) To enable Azure Monitoring for Azure SQL database including audit logs
37+
# log analytic workspace name required
38+
enable_log_monitoring = true
39+
log_analytics_workspace_name = "loganalytics-we-sharedtest2"
40+
41+
# Sql failover group creation. required secondary locaiton input.
42+
enable_failover_group = true
43+
secondary_sql_server_location = "northeurope"
44+
45+
# Firewall Rules to allow azure and external clients and specific Ip address/ranges.
46+
enable_firewall_rules = true
3047
firewall_rules = [
31-
{name = "access-to-azure"
32-
start_ip_address = "0.0.0.0"
33-
end_ip_address = "0.0.0.0"},
34-
{name = "desktop-ip"
35-
start_ip_address = "123.201.42.91"
36-
end_ip_address = "123.201.42.91"}]
37-
38-
# Sql failover group
39-
enable_failover_group = true
40-
secondary_sql_server_location = "northeurope"
41-
42-
# Create and initialize a database with SQL script
43-
initialize_sql_script_execution = false
44-
sqldb_init_script_file = "./artifacts/db-init-sample.sql"
45-
46-
# Tags for Azure Resources
48+
{
49+
name = "access-to-azure"
50+
start_ip_address = "0.0.0.0"
51+
end_ip_address = "0.0.0.0"
52+
},
53+
{
54+
name = "desktop-ip"
55+
start_ip_address = "49.204.225.134"
56+
end_ip_address = "49.204.225.134"
57+
}
58+
]
59+
60+
# Create and initialize a database with custom SQL script
61+
# need sqlcmd utility to run this command
62+
# your desktop public IP must be added firewall rules to run this command
63+
initialize_sql_script_execution = true
64+
sqldb_init_script_file = "../artifacts/db-init-sample.sql"
65+
66+
# Tags for Azure Resources
4767
tags = {
4868
Terraform = "true"
4969
Environment = "dev"
5070
Owner = "test-user"
5171
}
52-
}
72+
}

0 commit comments

Comments
 (0)