diff --git a/README.yaml b/README.yaml index b93a59c..ae2a398 100644 --- a/README.yaml +++ b/README.yaml @@ -49,12 +49,10 @@ usage: |- virtual_network_name = join("", module.vnet.vnet_name) #subnet - default_name_subnet = true subnet_names = ["subnet1", "subnet2"] subnet_prefixes = ["10.0.1.0/24", "10.0.2.0/24"] # route_table - enable_route_table = false routes = [ { name = "rt-test" @@ -81,7 +79,6 @@ usage: |- subnet_prefixes = ["10.0.1.0/24"] # route_table - enable_route_table = false routes = [ { name = "rt-test" @@ -103,13 +100,11 @@ usage: |- virtual_network_name = join("", module.vnet.vnet_name) #subnet - default_name_subnet = true create_nat_gateway = true subnet_names = ["subnet1", "subnet2"] subnet_prefixes = ["10.0.1.0/24", "10.0.2.0/24"] # route_table - enable_route_table = false routes = [ { name = "rt-test" diff --git a/_example/default_subnet/example.tf b/_example/default_subnet/example.tf index 174a1f3..0bd6ca4 100644 --- a/_example/default_subnet/example.tf +++ b/_example/default_subnet/example.tf @@ -4,7 +4,7 @@ provider "azurerm" { module "resource_group" { source = "clouddrove/resource-group/azure" - version = "1.0.0" + version = "1.0.1" name = "app" environment = "test" @@ -14,7 +14,7 @@ module "resource_group" { module "vnet" { source = "clouddrove/vnet/azure" - version = "1.0.0" + version = "1.0.1" name = "app" environment = "test" @@ -22,7 +22,6 @@ module "vnet" { resource_group_name = module.resource_group.resource_group_name location = module.resource_group.resource_group_location address_space = "10.0.0.0/16" - enable_ddos_pp = false } module "subnet" { @@ -30,18 +29,16 @@ module "subnet" { name = "app" environment = "test" - label_order = ["name", "environment"] + resource_group_name = module.resource_group.resource_group_name location = module.resource_group.resource_group_location virtual_network_name = join("", module.vnet.vnet_name) #subnet - default_name_subnet = true - subnet_names = ["subnet1", "subnet2"] - subnet_prefixes = ["10.0.1.0/24", "10.0.2.0/24"] + subnet_names = ["subnet1", "subnet2"] + subnet_prefixes = ["10.0.1.0/24", "10.0.2.0/24"] # route_table - enable_route_table = false routes = [ { name = "rt-test" diff --git a/_example/name-specific_subnet/example.tf b/_example/name-specific_subnet/example.tf index 7fe84e6..7962a22 100644 --- a/_example/name-specific_subnet/example.tf +++ b/_example/name-specific_subnet/example.tf @@ -4,7 +4,7 @@ provider "azurerm" { module "resource_group" { source = "clouddrove/resource-group/azure" - version = "1.0.0" + version = "1.0.1" name = "app" environment = "test" @@ -22,7 +22,6 @@ module "vnet" { resource_group_name = module.resource_group.resource_group_name location = module.resource_group.resource_group_location address_space = "10.0.0.0/16" - enable_ddos_pp = false } module "name_specific_subnet" { @@ -30,7 +29,7 @@ module "name_specific_subnet" { name = "app" environment = "test" - label_order = ["name", "environment"] + resource_group_name = module.resource_group.resource_group_name location = module.resource_group.resource_group_location virtual_network_name = join("", module.vnet.vnet_name) @@ -41,7 +40,6 @@ module "name_specific_subnet" { subnet_prefixes = ["10.0.1.0/24"] # route_table - enable_route_table = false routes = [ { name = "rt-test" diff --git a/_example/nat-gateway_subnet/example.tf b/_example/nat-gateway_subnet/example.tf index 460b751..0729c1f 100644 --- a/_example/nat-gateway_subnet/example.tf +++ b/_example/nat-gateway_subnet/example.tf @@ -4,7 +4,7 @@ provider "azurerm" { module "resource_group" { source = "clouddrove/resource-group/azure" - version = "1.0.0" + version = "1.0.1" name = "app" environment = "test" @@ -22,7 +22,6 @@ module "vnet" { resource_group_name = module.resource_group.resource_group_name location = module.resource_group.resource_group_location address_space = "10.0.0.0/16" - enable_ddos_pp = false } module "subnet" { @@ -30,19 +29,17 @@ module "subnet" { name = "app" environment = "test" - label_order = ["name", "environment"] + resource_group_name = module.resource_group.resource_group_name location = module.resource_group.resource_group_location virtual_network_name = join("", module.vnet.vnet_name) #subnet - default_name_subnet = true - create_nat_gateway = true - subnet_names = ["subnet1", "subnet2"] - subnet_prefixes = ["10.0.1.0/24", "10.0.2.0/24"] + create_nat_gateway = true + subnet_names = ["subnet1", "subnet2"] + subnet_prefixes = ["10.0.1.0/24", "10.0.2.0/24"] # route_table - enable_route_table = false routes = [ { name = "rt-test" diff --git a/main.tf b/main.tf index 2c661aa..ce743e7 100644 --- a/main.tf +++ b/main.tf @@ -17,7 +17,7 @@ module "labels" { #Subnet resource "azurerm_subnet" "subnet" { - count = var.enable && var.default_name_subnet == true ? length(var.subnet_names) : 0 + count = var.enable && var.specific_name_subnet == false ? length(var.subnet_names) : 0 name = "${var.name}-${var.subnet_names[count.index]}" resource_group_name = var.resource_group_name address_prefixes = [var.subnet_prefixes[count.index]] @@ -97,9 +97,9 @@ resource "azurerm_nat_gateway_public_ip_association" "pip_assoc" { } resource "azurerm_subnet_nat_gateway_association" "subnet_assoc" { - count = var.create_nat_gateway ? (var.default_name_subnet == true ? length(azurerm_subnet.subnet.*.id) : length(azurerm_subnet.subnet2.*.id)) : 0 + count = var.create_nat_gateway ? (var.specific_name_subnet == false ? length(azurerm_subnet.subnet.*.id) : length(azurerm_subnet.subnet2.*.id)) : 0 nat_gateway_id = join("", azurerm_nat_gateway.natgw.*.id) - subnet_id = var.default_name_subnet == true ? azurerm_subnet.subnet.*.id[count.index] : azurerm_subnet.subnet2.*.id[count.index] + subnet_id = var.specific_name_subnet == false ? azurerm_subnet.subnet.*.id[count.index] : azurerm_subnet.subnet2.*.id[count.index] } #Route Table @@ -122,7 +122,7 @@ resource "azurerm_route_table" "rt" { } resource "azurerm_subnet_route_table_association" "main" { - count = var.enable && var.enable_route_table && var.default_name_subnet ? length(var.subnet_prefixes) : 0 + count = var.enable && var.enable_route_table && var.specific_name_subnet == false ? length(var.subnet_prefixes) : 0 subnet_id = element(azurerm_subnet.subnet.*.id, count.index) route_table_id = join("", azurerm_route_table.rt.*.id) } diff --git a/variable.tf b/variable.tf index d03d62f..a52ce54 100644 --- a/variable.tf +++ b/variable.tf @@ -27,7 +27,7 @@ variable "environment" { variable "label_order" { type = list(any) - default = [] + default = ["name", "environment"] description = "Label order, e.g. `name`,`application`." } @@ -117,11 +117,6 @@ EOD default = {} } -variable "default_name_subnet" { - type = bool - default = false -} - variable "specific_name_subnet" { type = bool default = false @@ -159,7 +154,7 @@ variable "create_nat_gateway" { variable "enable_route_table" { type = bool - default = false + default = true description = "Flag to control route table creation." }