Skip to content

Commit

Permalink
ADD variable to configure service endpoints (#60)
Browse files Browse the repository at this point in the history
* feat: add variable subnet_service_endpoints to set service_endpoints

* test: udpate fixture

* docs: add subnet_service_endpoints in example in README
  • Loading branch information
goatwu1993 authored May 31, 2021
1 parent 176721b commit 7070853
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ module "network" {
subnet_prefixes = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
subnet_names = ["subnet1", "subnet2", "subnet3"]
subnet_service_endpoints = {
"subnet1" : ["Microsoft.Sql"],
"subnet2" : ["Microsoft.Sql"],
"subnet3" : ["Microsoft.Sql"]
}
tags = {
environment = "dev"
costcenter = "it"
Expand Down Expand Up @@ -57,6 +63,12 @@ module "network" {
"subnet1" : true
}
subnet_service_endpoints = {
"subnet1" : ["Microsoft.Sql"],
"subnet2" : ["Microsoft.Sql"],

This comment has been minimized.

Copy link
@kriesto

kriesto Sep 13, 2021

Hi,

Is there a way to replace "Subnet1" "Subnet2" and "Subnet3" with variables. when setting up subnet_service_endpoints ?

"subnet3" : ["Microsoft.Sql"]
}
tags = {
environment = "dev"
costcenter = "it"
Expand Down
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ resource "azurerm_subnet" "subnet" {
address_prefixes = [var.subnet_prefixes[count.index]]
virtual_network_name = azurerm_virtual_network.vnet.name
enforce_private_link_endpoint_network_policies = lookup(var.subnet_enforce_private_link_endpoint_network_policies, var.subnet_names[count.index], false)
service_endpoints = lookup(var.subnet_service_endpoints, var.subnet_names[count.index], [])
}
4 changes: 4 additions & 0 deletions test/fixture/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ module "network" {
"subnet1" : true
}

subnet_service_endpoints = {
"subnet1" : ["Microsoft.Sql"]
}

tags = {
environment = "dev"
costcenter = "it"
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,9 @@ variable "subnet_enforce_private_link_endpoint_network_policies" {
type = map(bool)
default = {}
}

variable "subnet_service_endpoints" {
description = "A map with key (string) `subnet name`, value (list(string)) to indicate enabled service endpoints on the subnet. Default value is []."
type = map(list(string))
default = {}
}

0 comments on commit 7070853

Please sign in to comment.