You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+97-53
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,11 @@
1
-
# Azure SQL Database - Using Failover Groups with Private Endpoints
1
+
# Azure SQL Database Terraform Module
2
2
3
3
Terraform module to create an MS SQL server with initial database, Azure AD login, Firewall rules, geo-replication using auto-failover groups, Private endpoints, and corresponding private DNS zone. It also supports creating a database with a custom SQL script initialization.
4
4
5
5
A single database is the quickest and simplest deployment option for Azure SQL Database. You manage a single database within a SQL Database server, which is inside an Azure resource group in a specified Azure region with this module.
6
6
7
7
You can also create a single database in the provisioned or serverless compute tier. A provisioned database is pre-allocated a fixed amount of computing resources, including CPU and memory, and uses one of two purchasing models. This module creates a provisioned database using the vCore-based purchasing model, but you can choose a DTU-based model as well.
8
8
9
-
> **[NOTE]**
10
-
> **This module now supports the meta arguments including `providers`, `depends_on`, `count`, and `for_each`.**
@@ -121,16 +111,10 @@ By default, this module generates a strong password for all virtual machines als
121
111
122
112
### Resource Group
123
113
124
-
By default, this module will not create a resource group and the name of an existing resource group to be given in an argument `resource_group_name`. If you want to create a new resource group, set the argument `create_resource_group = true`.
114
+
By default, this module will create a resource group. To use the existing resource group, set the arguments `create_resource_group = false` and provide a valid resource group name with`resource_group_name`.
125
115
126
116
*If you are using an existing resource group, then this module uses the same resource group location to create all resources in this module.*
127
117
128
-
### VNet and Subnets
129
-
130
-
This module is not going to create a `VNet` and corresponding services. However, this module expect you to provide VPC and Subnet address space for private end points.
131
-
132
-
Deploy Azure VNet terraform module to overcome with this dependency. The [`terraform-azurerm-vnet`](https://github.com/tietoevry-cloud-infra/terraform-azurerm-vnet) module currently available from [GitHub](https://github.com/tietoevry-cloud-infra/terraform-azurerm-vnet), also aligned with this module.
133
-
134
118
## Advance usage of module
135
119
136
120
### `extended_auditing_policy` - Auditing for SQL Database
@@ -179,7 +163,49 @@ Azure Private Endpoint is a network interface that connects you privately and se
179
163
180
164
With Private Link, Microsoft offering the ability to associate a logical server to a specific private IP address (also known as private endpoint) within the VNet. This module helps to implement Failover Groups using private endpoint for SQL Database instead of the public endpoint thus ensuring that customers can get security benefits that it offers.
181
165
182
-
Clients can connect to the Private endpoint from the same VNet, peered VNet in same region, or via VNet-to-VNet connection across regions. Additionally, clients can connect from on-premises using ExpressRoute, private peering, or VPN tunneling.
166
+
By default, this feature not enabled on this module. To create private link with private endpoints set the variable `enable_private_endpoint` to `true` and provide `virtual_network_name`, `private_subnet_address_prefix` with a valid values. You can also use the existing private DNS zone to create DNS records. To use this feature, set the `existing_private_dns_zone` with a valid existing private DNS zone name.
167
+
168
+
```terraform
169
+
module "mssql-server" {
170
+
source = "kumarvna/mssql-db/azurerm"
171
+
version = "1.3.0"
172
+
173
+
# .... omitted
174
+
175
+
# Creating Private Endpoint requires, VNet name and address prefix to create a subnet
176
+
# By default this will create a `privatelink.database.windows.net` DNS zone.
177
+
# To use existing private DNS zone specify `existing_private_dns_zone` with valid zone name
If you want to use eixsting VNet and Subnet to create a private endpoints, set a variable `enable_private_endpoint` to `true` and provide `existing_vnet_id`, `existing_subnet_id` with a valid resource ids. You can also use the existing private DNS zone to create DNS records. To use this feature, set the `existing_private_dns_zone` with a valid existing private DNS zone name.
189
+
190
+
```terraform
191
+
module "mssql-server" {
192
+
source = "kumarvna/mssql-db/azurerm"
193
+
version = "1.3.0"
194
+
195
+
# .... omitted
196
+
197
+
# Creating Private Endpoint requires, VNet name and address prefix to create a subnet
198
+
# By default this will create a `privatelink.database.windows.net` DNS zone.
199
+
# To use existing private DNS zone specify `existing_private_dns_zone` with valid zone name
@@ -189,6 +215,24 @@ This module uses the tool slqcmd as a local provisioner to connect and inject th
189
215
190
216
Installation of the Microsoft `sqlcmd` utility on [Ubuntu](https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup-tools?view=sql-server-ver15#ubuntu) or on [Windows](https://docs.microsoft.com/en-us/sql/tools/sqlcmd-utility?view=sql-server-ver15) found here.
191
217
218
+
```terraform
219
+
module "mssql-server" {
220
+
source = "kumarvna/mssql-db/azurerm"
221
+
version = "1.3.0"
222
+
223
+
# .... omitted
224
+
225
+
# Create and initialize a database with custom SQL script
226
+
# need sqlcmd utility to run this command
227
+
# your desktop public IP must be added to firewall rules to run this command
Applying tags to your Azure resources, resource groups, and subscriptions to logically organize them into a taxonomy. Each tag consists of a name and a value pair. For example, you can apply the name `Environment` and the value `Production` to all the resources in production.
@@ -225,27 +269,31 @@ Name | Description | Type | Default
225
269
`database_name`|The name of the SQL database|string|`""`
226
270
`admin_username`|The username of the local administrator used for the SQL Server|string|`"azureadmin"`
227
271
`admin_password`|The Password which should be used for the local-administrator on this SQL Server|string|`null`
272
+
`random_password_length`|The desired length of random password created by this module|number|`32`
273
+
`storage_account_name`|The name of the storage account|string|`null`
228
274
`sql_database_edition`|The edition of the database to be created. Valid values are: `Basic`, `Standard`, `Premium`, `DataWarehouse`, `Business`, `BusinessCritical`, `Free`, `GeneralPurpose`, `Hyperscale`, `Premium`, `PremiumRS`, `Standard`, `Stretch`, `System`, `System2`, or `Web`|string|`"Standard"`
229
275
`sqldb_service_objective_name`|The service objective name for the database. Valid values depend on edition and location and may include `S0`, `S1`, `S2`, `S3`, `P1`, `P2`, `P4`, `P6`, `P11`|string|`"S1"`
230
276
`enable_sql_server_extended_auditing_policy`|Manages Extended Audit policy for SQL servers|string|`"true"`
231
277
`enable_database_extended_auditing_policy`|Manages Extended Audit policy for SQL database|string|`"false"`
`enable_log_monitoring`|Enable audit events to Azure Monitor?|string|`false`
233
280
`log_retention_days`|Specifies the number of days to retain logs for in the storage account|`number`|`30`
234
281
`email_addresses_for_alerts`|Account administrators email for alerts|`list(any)`|`""`
235
282
`ad_admin_login_name`|The login name of the principal to set as the server administrator|string|`null`
236
283
`enable_firewall_rules`|Manages a Firewall Rule for a MySQL Server|string|`"false"`
237
284
`firewall_rules`| list of firewall rules to add SQL servers| `list(object({}))`| `[]`
238
285
`enable_failover_group`|Create a failover group of databases on a collection of Azure SQL servers|string| `"false"`
239
286
`secondary_sql_server_location`|The location of the secondary SQL server (applicable if Failover groups enabled)|string|`"northeurope"`
240
-
`enable_private_endpoint`|Azure Private Endpoint is a network interface that connects you privately and securely to a service powered by Azure Private Link|string|`"false"`
241
-
`virtual_network_name` | The name of the virtual network|string|`""`
242
-
`private_subnet_address_prefix`|A list of subnets address prefixes inside virtual network| list |`[]`
243
287
`initialize_sql_script_execution`|enable sqlcmd tool to connect and create database schema|string| `"false"`
244
288
`sqldb_init_script_file`|SQL file to execute via sqlcmd utility to create required database schema |string|`""`
245
-
`enable_log_monitoring`|Enable audit events to Azure Monitor?|string|`false`
246
-
`storage_account_name`|The name of the storage account name|string|`null`
247
-
`log_analytics_workspace_name`|The name of log analytics workspace name|string|`null`
248
-
`random_password_length`|The desired length of random password created by this module|number|`24`
289
+
`enable_private_endpoint`|Manages a Private Endpoint to Azure Container Registry|string|`false`
290
+
`virtual_network_name`|The name of the virtual network for the private endpoint creation. conflicts with `existing_vnet_id`and shouldn't use both.|string|`""`
291
+
`private_subnet_address_prefix`|Address prefix of the subnet for private endpoint creation. conflicts with `existing_subnet_id` and shouldn't use both|list(string)|`null`
292
+
`existing_vnet_id`|The resoruce id of existing Virtual network for private endpoint creation. Conflicts with `virtual_network_name`and shouldn't use both|string|`null`
293
+
`existing_subnet_id`|The resource id of existing subnet for private endpoint creation. Conflicts with `private_subnet_address_prefix` and shouldn't use both|string|`null`
294
+
`existing_private_dns_zone`|The name of exisging private DNS zone|string|`null`
295
+
`log_analytics_workspace_id`|The id of log analytic workspace to send logs and metrics.|string|`"null"`
296
+
`storage_account_id`|The id of storage account to send logs and metrics|string|`"null"`
249
297
`Tags`|A map of tags to add to all resources|map|`{}`
250
298
251
299
## Outputs
@@ -286,7 +334,3 @@ Originally created by [Kumaraswamy Vithanala](mailto:[email protected])
0 commit comments