Skip to content

Commit

Permalink
Make subnet-network-security-group-association module optional (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
nachoalonsoportillo committed Feb 8, 2023
1 parent 72f570c commit 0c50b86
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions terraform/subnet-network-security-group-association/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
resource "azurerm_subnet_network_security_group_association" "adl_snet_nsg_association" {
subnet_id = var.subnet_id
network_security_group_id = var.network_security_group_id

count = var.module_enabled ? 1 : 0
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
output "id" {
value = azurerm_subnet_network_security_group_association.adl_snet_nsg_association.id
value = (
length(azurerm_subnet_network_security_group_association.adl_snet_nsg_association) > 0 ?
azurerm_subnet_network_security_group_association.adl_snet_nsg_association[0].id : ""
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,10 @@ variable "subnet_id" {
variable "network_security_group_id" {
type = string
description = "The ID of the Subnet."
}

variable "module_enabled" {
type = bool
description = "Variable to enable or disable the module."
default = true
}

0 comments on commit 0c50b86

Please sign in to comment.