Skip to content

Commit 926b587

Browse files
committed
updated example for Simple SQL single database with private endpoint
1 parent 5821453 commit 926b587

File tree

4 files changed

+243
-249
lines changed

4 files changed

+243
-249
lines changed
Lines changed: 96 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,96 @@
1-
# Simple Azure SQL single database using private Endpoint
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 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-
# enabling the Private Endpoints for Sql servers
48-
enable_private_endpoint = true
49-
50-
# AD administrator for an Azure SQL server
51-
# Allows you to set a user or group as the AD administrator for an Azure SQL server
52-
ad_admin_login_name = "[email protected]"
53-
54-
# (Optional) To enable Azure Monitoring for Azure SQL database including audit logs
55-
# log analytic workspace name required
56-
enable_log_monitoring = true
57-
log_analytics_workspace_name = "loganalytics-we-sharedtest2"
58-
59-
# Firewall Rules to allow azure and external clients and specific Ip address/ranges.
60-
enable_firewall_rules = true
61-
firewall_rules = [
62-
{
63-
name = "access-to-azure"
64-
start_ip_address = "0.0.0.0"
65-
end_ip_address = "0.0.0.0"
66-
},
67-
{
68-
name = "desktop-ip"
69-
start_ip_address = "49.204.225.134"
70-
end_ip_address = "49.204.225.134"
71-
}
72-
]
73-
74-
# Create and initialize a database with custom SQL script
75-
# need sqlcmd utility to run this command
76-
# your desktop public IP must be added to firewall rules to run this command
77-
initialize_sql_script_execution = true
78-
sqldb_init_script_file = "../artifacts/db-init-sample.sql"
79-
80-
# Tags for Azure Resources
81-
tags = {
82-
Terraform = "true"
83-
Environment = "dev"
84-
Owner = "test-user"
85-
}
86-
}
87-
```
88-
89-
## Terraform Usage
90-
91-
To run this example you need to execute following Terraform commands
92-
93-
```bash
94-
terraform init
95-
terraform plan
96-
terraform apply
97-
```
98-
99-
Run `terraform destroy` when you don't need these resources.
1+
# Simple Azure SQL single database using private Endpoint
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 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.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+
# Creating Private Endpoint requires, VNet name and address prefix to create a subnet
46+
# By default this will create a `privatelink.vaultcore.azure.net` DNS zone.
47+
# To use existing private DNS zone specify `existing_private_dns_zone` with valid zone name
48+
enable_private_endpoint = true
49+
virtual_network_name = "vnet-shared-hub-westeurope-001"
50+
private_subnet_address_prefix = ["10.1.5.0/29"]
51+
# existing_private_dns_zone = "demo.example.com"
52+
53+
# AD administrator for an Azure SQL server
54+
# Allows you to set a user or group as the AD administrator for an Azure SQL server
55+
ad_admin_login_name = "[email protected]"
56+
57+
# (Optional) To enable Azure Monitoring for Azure SQL database including audit logs
58+
# log analytic workspace name required
59+
enable_log_monitoring = true
60+
log_analytics_workspace_name = "loganalytics-we-sharedtest2"
61+
62+
# Firewall Rules to allow azure and external clients and specific Ip address/ranges.
63+
enable_firewall_rules = true
64+
firewall_rules = [
65+
{
66+
name = "access-to-azure"
67+
start_ip_address = "0.0.0.0"
68+
end_ip_address = "0.0.0.0"
69+
},
70+
{
71+
name = "desktop-ip"
72+
start_ip_address = "123.201.36.94"
73+
end_ip_address = "123.201.36.94"
74+
}
75+
]
76+
77+
# Tags for Azure Resources
78+
tags = {
79+
Terraform = "true"
80+
Environment = "dev"
81+
Owner = "test-user"
82+
}
83+
}
84+
```
85+
86+
## Terraform Usage
87+
88+
To run this example you need to execute following Terraform commands
89+
90+
```bash
91+
terraform init
92+
terraform plan
93+
terraform apply
94+
```
95+
96+
Run `terraform destroy` when you don't need these resources.
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,76 @@
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-
# enabling the Private Endpoints for Sql servers
41-
enable_private_endpoint = true
42-
43-
# AD administrator for an Azure SQL server
44-
# Allows you to set a user or group as the AD administrator for an Azure SQL server
45-
ad_admin_login_name = "[email protected]"
46-
47-
# (Optional) To enable Azure Monitoring for Azure SQL database including audit logs
48-
# log analytic workspace name required
49-
enable_log_monitoring = true
50-
log_analytics_workspace_name = "loganalytics-we-sharedtest2"
51-
52-
# Firewall Rules to allow azure and external clients and specific Ip address/ranges.
53-
enable_firewall_rules = true
54-
firewall_rules = [
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 to 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
74-
tags = {
75-
Terraform = "true"
76-
Environment = "dev"
77-
Owner = "test-user"
78-
}
79-
}
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+
# Creating Private Endpoint requires, VNet name and address prefix to create a subnet
39+
# By default this will create a `privatelink.vaultcore.azure.net` DNS zone.
40+
# To use existing private DNS zone specify `existing_private_dns_zone` with valid zone name
41+
enable_private_endpoint = true
42+
virtual_network_name = "vnet-shared-hub-westeurope-001"
43+
private_subnet_address_prefix = ["10.1.5.0/29"]
44+
# existing_private_dns_zone = "demo.example.com"
45+
46+
# AD administrator for an Azure SQL server
47+
# Allows you to set a user or group as the AD administrator for an Azure SQL server
48+
ad_admin_login_name = "[email protected]"
49+
50+
# (Optional) To enable Azure Monitoring for Azure SQL database including audit logs
51+
# log analytic workspace name required
52+
enable_log_monitoring = true
53+
log_analytics_workspace_name = "loganalytics-we-sharedtest2"
54+
55+
# Firewall Rules to allow azure and external clients and specific Ip address/ranges.
56+
enable_firewall_rules = true
57+
firewall_rules = [
58+
{
59+
name = "access-to-azure"
60+
start_ip_address = "0.0.0.0"
61+
end_ip_address = "0.0.0.0"
62+
},
63+
{
64+
name = "desktop-ip"
65+
start_ip_address = "123.201.36.94"
66+
end_ip_address = "123.201.36.94"
67+
}
68+
]
69+
70+
# Tags for Azure Resources
71+
tags = {
72+
Terraform = "true"
73+
Environment = "dev"
74+
Owner = "test-user"
75+
}
76+
}

0 commit comments

Comments
 (0)