Skip to content

Commit 8c589ab

Browse files
authored
added location field to NSG (#51)
1 parent 7b9c4fd commit 8c589ab

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ resource "azurerm_resource_group" "test" {
2424
module "network-security-group" {
2525
source = "Azure/network-security-group/azurerm"
2626
resource_group_name = azurerm_resource_group.test.name
27+
location = "EastUS" # Optional; if not provided, will use Resource Group location
2728
security_group_name = "nsg"
2829
source_address_prefix = ["10.0.3.0/24"]
2930
predefined_rules = [

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ data "azurerm_resource_group" "nsg" {
44

55
resource "azurerm_network_security_group" "nsg" {
66
name = var.security_group_name
7-
location = data.azurerm_resource_group.nsg.location
7+
location = var.location != "" ? var.location : data.azurerm_resource_group.nsg.location
88
resource_group_name = data.azurerm_resource_group.nsg.name
99
tags = var.tags
1010
}

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ variable "tags" {
1414
default = {}
1515
}
1616

17+
variable "location" {
18+
description = "Location (Azure Region) for the network security group."
19+
# No default - if it's not specified, use the resource group location (see main.tf)
20+
default = ""
21+
}
22+
1723
# Security Rules definition
1824

1925
# Predefined rules

0 commit comments

Comments
 (0)