Skip to content
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

Add ip_configuration block to private endpoints #1691

Merged
1 change: 1 addition & 0 deletions .github/workflows/standalone-networking.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"networking/pip_prefix/100-simple-pip-prefix",
"networking/private_dns_vnet_link/100_pvtdns_vnetlink",
"networking/private_dns/100-private-dns-vnet-links",
"networking/private_endpoint",
"networking/private_links/endpoints/centralized",
"networking/virtual_network/100-import-rg",
"networking/virtual_network/100-simple-vnet-subnets-nsgs",
Expand Down
19 changes: 19 additions & 0 deletions examples/networking/private_endpoint/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
You can test this module outside of a landingzone using
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
You can test this module outside of a landingzone using
You can test this module outside of a rover using


```bash
sudo terraform init
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sudo terraform init
terraform init


terraform [plan|apply|destroy] \
-var-file ../configuration.tfvars \
-var-file ../keyvaults.tfvars \
-var-file ../nsg_definitions.tfvars \
-var-file ../virtual_networks.tfvars \
-var-file ../public_ip_addresses.tfvars \
-var-file ../virtual_machines.tfvars


```

sudo terraform plan -var-file examples/networking/private_endpoint/configuration.tfvars
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sudo terraform plan -var-file examples/networking/private_endpoint/configuration.tfvars
terraform plan -var-file examples/networking/private_endpoint/configuration.tfvars

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sudo terraform plan -var-file examples/networking/private_endpoint/configuration.tfvars
terraform plan -var-file examples/networking/private_endpoint/configuration.tfvars


sudo terraform plan -var-file configuration.tfvars
100 changes: 100 additions & 0 deletions examples/networking/private_endpoint/configuration.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
global_settings = {
default_region = "region1"
regions = {
region1 = "australiaeast"
}
}

resource_groups = {
kv_region1 = {
name = "keyvault-rg1"
region = "region1"
}
}

keyvaults = {

#
# Keyvault with private endpoint enabled and configured with two static ips
#
kv01_rg1 = {
name = "certificates"
resource_group_key = "kv_region1"
sku_name = "premium"

creation_policies = {
logged_in_user = {
secret_permissions = ["Set", "Get", "List", "Delete", "Purge"]
certificate_permissions = ["ManageContacts", "ManageIssuers"]
}
}

network = {
bypass = "AzureServices"
default_action = "Deny"
}

private_endpoints = {
# Require enforce_private_link_endpoint_network_policies set to true on the subnet
private-link1 = {
name = "keyvault-certificates"
vnet_key = "vnet_security"
subnet_key = "private_link"
resource_group_key = "kv_region1"
# if the private_endpoint must be deployed in a remote resource group
# resource_group = {
# lz_key = ""
# key = ""
# }

private_service_connection = {
name = "keyvault-certificates"
is_manual_connection = false
subresource_names = ["vault"]
}

ip_configurations = {
static1= {
name = "kv01_rg1-name1"
private_ip_address = "10.150.100.140"
subresource_name = "vault"
member_name = "default"
}
static2 = {
name = "kv01_rg1-name2"
private_ip_address = "10.150.100.150"
subresource_name = "vault"
member_name = "default2"
}
}

# private_dns = {
# lz_key = ""
# keys = ["vaultcore"]
# }
}
}
}
}

vnets = {
vnet_security = {
resource_group_key = "kv_region1"
vnet = {
name = "keyvaults"
address_space = ["10.150.100.0/24"]
}
subnets = {
keyvault_endpoints = {
name = "keyvault"
cidr = ["10.150.100.64/26"]
service_endpoints = ["Microsoft.KeyVault"]
}
private_link = {
name = "private-links"
cidr = ["10.150.100.128/26"]
enforce_private_link_endpoint_network_policies = true
}
}
}
}
13 changes: 12 additions & 1 deletion modules/networking/private_endpoint/private_endpoint.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,15 @@ resource "azurerm_private_endpoint" "pep" {
}
}

}
dynamic "ip_configuration" {
for_each = try(var.settings.ip_configurations, {})

content {
name = ip_configuration.value.name
private_ip_address = ip_configuration.value.private_ip_address
subresource_name = lookup(ip_configuration.value, "subresource_name", null)
member_name = lookup(ip_configuration.value, "member_name", null)
}
}

}