Skip to content

Added Details of Private DNS Zone Group. #78

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 6 additions & 42 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,12 @@
resource_group_name = var.resource_group_name
subnet_id = var.subnet_id
tags = module.labels.tags

private_dns_zone_group {
name = format("%s-sa-dns-zone-group", module.labels.id)
private_dns_zone_ids = var.existing_private_dns_zone == null ? [azurerm_private_dns_zone.dnszone[0].id] : [var.existing_private_dns_zone_id]
}

private_service_connection {
name = format("%s-psc-kv", module.labels.id)
is_manual_connection = false
Expand All @@ -233,7 +239,7 @@
##-----------------------------------------------------------------------------
## Data block to retreive private ip of private endpoint.
##-----------------------------------------------------------------------------
data "azurerm_private_endpoint_connection" "private-ip" {

Check warning on line 242 in main.tf

View workflow job for this annotation

GitHub Actions / tf-lint / tflint

data "azurerm_private_endpoint_connection" "private-ip" is declared but not used
provider = azurerm.main_sub
count = var.enabled && var.enable_private_endpoint ? 1 : 0

Expand Down Expand Up @@ -316,48 +322,6 @@
tags = module.labels.tags
}

##-----------------------------------------------------------------------------
## Below resource will create dns A record for private ip of private endpoint in private dns zone.
##-----------------------------------------------------------------------------
resource "azurerm_private_dns_a_record" "arecord" {
provider = azurerm.main_sub
count = var.enabled && var.enable_private_endpoint && var.diff_sub == false ? 1 : 0

name = azurerm_key_vault.key_vault[0].name
zone_name = local.private_dns_zone_name
resource_group_name = local.valid_rg_name
ttl = 3600
records = [data.azurerm_private_endpoint_connection.private-ip[0].private_service_connection[0].private_ip_address]
tags = module.labels.tags
lifecycle {
ignore_changes = [
tags,
]
}
}

##-----------------------------------------------------------------------------
## Below resource will create dns A record for private ip of private endpoint in private dns zone.
## This resource will be created when private dns is in different subscription.
##-----------------------------------------------------------------------------
resource "azurerm_private_dns_a_record" "arecord-1" {
provider = azurerm.dns_sub
count = var.enabled && var.enable_private_endpoint && var.diff_sub == true ? 1 : 0


name = azurerm_key_vault.key_vault[0].name
zone_name = local.private_dns_zone_name
resource_group_name = local.valid_rg_name
ttl = 3600
records = [data.azurerm_private_endpoint_connection.private-ip[0].private_service_connection[0].private_ip_address]
tags = module.labels.tags
lifecycle {
ignore_changes = [
tags,
]
}
}

##-----------------------------------------------------------------------------
## Below resources will create diagnostic setting for key vault and its components.
##-----------------------------------------------------------------------------
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ variable "existing_private_dns_zone_resource_group_name" {
description = "The name of the existing resource group"
}

variable "existing_private_dns_zone_id" {
description = "The ID of an existing private DNS zone."
type = string
default = null
}

variable "public_network_access_enabled" {
type = bool
default = true
Expand Down
Loading