Skip to content

Commit 294b9d3

Browse files
authored
Merge pull request #8 from data-platform-hq/feat/custom_name
feat: added custom names for resources
2 parents 25889b9 + 80950fe commit 294b9d3

File tree

4 files changed

+26
-6
lines changed

4 files changed

+26
-6
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ Terraform module for creation Azure Microsoft SQL Database Server
99
| Name | Version |
1010
| ------------------------------------------------------------------------- | --------- |
1111
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0.0 |
12-
| <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) | >= 3.23.0 |
12+
| <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) | >= 3.40.0 |
1313

1414
## Providers
1515

1616
| Name | Version |
1717
| ------------------------------------------------------------- | ------- |
18-
| <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) | 3.24.0 |
18+
| <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) | 3.40.0 |
1919

2020
## Modules
2121

@@ -45,6 +45,8 @@ No modules.
4545
| <a name="input_admin_password"></a> [admin\_password](#input\_admin\_password) | The password associated with the admin_username | `string` | n/a | yes |
4646
| <a name="input_azure_ad_admin_login"></a> [azure\_ad\_admin\_login](#input\_azure\_ad\_admin\_login) | The login username of the Azure AD Administrator of this SQL Server | `string` | n/a | yes |
4747
| <a name="input_azure_ad_admin_object_id"></a> [azure\_ad\_admin\_object\_id](#input\_azure\_ad\_admin\_object\_id) | The object id of the Azure AD Administrator of this SQL Server | `string` | n/a | yes |
48+
| <a name="input_custom_mssql_server_name"></a> [custom_mssql\_server\_name](#input\_custom\_mssql\_server\_name) | The name of the Microsoft SQL Server | `string` | `null` | no |
49+
| <a name="input_custom_tde_key_name"></a> [custom\_tde\_key\_name](#input\_custom\_tde\_key\_name) | Specifies the name of the Key Vault Key | `string` | `null` | no |
4850
| <a name="input_server_version"></a> [server_version](#input\_server\_version) | Server version | `string` | 12.0 | no |
4951
| <a name="input_connection_policy"></a> [connection\_policy](#input\_connection\_policy) | The connection policy the server will use: [Default \| Proxy \| Redirect] | `string` | Default | no |
5052
| <a name="input_minimum_tls_version"></a> [minimum\_tls\_version](#input\_minimum\_tls\_version) | The Minimum TLS Version for all SQL Database and SQL Data Warehouse databases associated with the server: [1.0 \| 1.1 \| 1.2] | `string` | 1.2 | no |

main.tf

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
locals {
2-
ip_rules = { for e in [for k, ip in var.ip_rules : try(regex("/", ip), 0) != 0 ? { (k) = { start_ip_address = cidrhost(ip, 0), end_ip_address = cidrhost(ip, -1) } } : { (k) = { start_ip_address = ip, end_ip_address = ip } }] : keys(e)[0] => e[keys(e)[0]] }
2+
ip_rules = { for e in [for k, ip in var.ip_rules : try(regex("/", ip), 0) != 0 ? { (k) = { start_ip_address = cidrhost(ip, 0), end_ip_address = cidrhost(ip, -1) } } : { (k) = { start_ip_address = ip, end_ip_address = ip } }] : keys(e)[0] => e[keys(e)[0]] }
3+
server_name = var.custom_mssql_server_name == null ? "mssql-${var.project}-${var.env}-${var.location}" : var.custom_mssql_server_name
4+
tde_key_name = var.custom_tde_key_name == null ? "tde-${var.project}-${var.env}-${var.location}" : var.custom_tde_key_name
35
}
46

57
resource "azurerm_mssql_server" "this" {
6-
name = "mssql-${var.project}-${var.env}-${var.location}"
8+
name = local.server_name
79
resource_group_name = var.resource_group
810
location = var.location
911
version = var.server_version
@@ -48,11 +50,15 @@ resource "azurerm_key_vault_access_policy" "tde_policy" {
4850
resource "azurerm_key_vault_key" "this" {
4951
for_each = { for k, v in var.key_vault_id : k => v }
5052

51-
name = "tde-${var.project}-${var.env}-${var.location}"
53+
name = local.tde_key_name
5254
key_type = var.key_type
5355
key_size = var.key_size
5456
key_vault_id = each.value
5557
key_opts = var.key_opts
58+
59+
depends_on = [
60+
azurerm_key_vault_access_policy.tde_policy
61+
]
5662
}
5763

5864
resource "azurerm_mssql_server_transparent_data_encryption" "this" {

variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,18 @@ variable "azure_ad_admin_object_id" {
3838
description = "The object id of the Azure AD Administrator of this SQL Server"
3939
}
4040

41+
variable "custom_mssql_server_name" {
42+
type = string
43+
description = "The name of the Microsoft SQL Server"
44+
default = null
45+
}
46+
47+
variable "custom_tde_key_name" {
48+
type = string
49+
description = "Specifies the name of the Key Vault Key"
50+
default = null
51+
}
52+
4153
variable "server_version" {
4254
type = string
4355
description = "Server version"

versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
required_providers {
55
azurerm = {
66
source = "hashicorp/azurerm"
7-
version = ">= 3.23.0"
7+
version = ">= 3.40.0"
88
}
99
}
1010
}

0 commit comments

Comments
 (0)