Skip to content

Commit e87aa58

Browse files
authored
Merge pull request #4 from data-platform-hq/custom-prefix-var
fix: added prefix variable
2 parents d453d35 + e484b0e commit e87aa58

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ No modules.
7272
| <a name="input_project"></a> [project](#input\_project) | Project/stream name (e.g. datalake) | `string` | n/a | yes |
7373
| <a name="input_resource_group"></a> [resource\_group](#input\_resource\_group) | The Azure Region in which all resources in this example should be created. | `string` | n/a | yes |
7474
| <a name="input_tags"></a> [tags](#input\_tags) | list of tags | `map(string)` | `{}` | no |
75+
| <a name="input_prefix"></a> [prefix](#input\_prefix) | Custom prefix to add to resource name | `string` | `""` | no |
7576
| <a name="input_dns_zone_name"></a> [dns\_zone\_name](#input\_dns\_zone\_name) | Name of Private DNS Zone | `string` | `""` | no |
7677
| <a name="input_vnet_map"></a> [vnet_map](#input\_vnet\_map) | Map of Virtual Network Name to Id, used to create VNet Link to Private DNS | `map(string)` | `{}` | no |
7778
| <a name="input_external_dns_zone_name"></a> [external\_dns\_zone\_name](#input\_external\_dns\_zone\_name) | Name of Imported Private DNS Zone. Provide value in case creation of new Private DNS Zone is disabled | `string` | `""` | no |

main.tf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
locals {
2+
prefix = length(var.prefix) == 0 ? "" : "${var.prefix}-"
3+
}
4+
15
resource "azurerm_private_dns_zone" "this" {
26
count = length(var.dns_zone_name) == 0 ? 0 : 1
37

@@ -9,7 +13,7 @@ resource "azurerm_private_dns_zone" "this" {
913
resource "azurerm_private_dns_zone_virtual_network_link" "this" {
1014
for_each = var.vnet_map
1115

12-
name = "link-${each.key}"
16+
name = "link-${local.prefix}${each.key}"
1317
private_dns_zone_name = length(var.dns_zone_name) == 0 ? var.external_dns_zone_name : azurerm_private_dns_zone.this[0].name
1418
resource_group_name = var.resource_group
1519
virtual_network_id = each.value

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ variable "tags" {
99
default = {}
1010
}
1111

12+
variable "prefix" {
13+
type = string
14+
description = "Custom prefix to add to resource name"
15+
default = ""
16+
}
17+
1218
variable "dns_zone_name" {
1319
type = string
1420
description = "Name of Private DNS Zone"

0 commit comments

Comments
 (0)