Skip to content

Commit

Permalink
fix: removed multiple variables in main.tf file
Browse files Browse the repository at this point in the history
  • Loading branch information
pranaydeokar committed Dec 21, 2023
1 parent 53ca73e commit 05cc023
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 43 deletions.
6 changes: 3 additions & 3 deletions _example/basic/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ module "vnet" {
source = "../../"
name = local.name
environment = local.environment
resource_group_name = "testsg"
resource_group_name = "testrg"
location = "NorthEurope"
address_space = "10.0.0.0/16"
address_spaces = ["10.0.0.0/16"]
enable_network_watcher = false # To be set true when network security group flow logs are to be tracked and network watcher with specific name is to be deployed.
}
}
4 changes: 2 additions & 2 deletions _example/basic/versions.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Terraform version
terraform {
required_version = ">= 1.6.5"
required_version = ">= 1.6.6"
}

terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = ">=3.83.0"
version = ">=3.85.0"
}
}
}
2 changes: 1 addition & 1 deletion _example/complete/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module "vnet" {
environment = local.environment
resource_group_name = module.resource_group.resource_group_name
location = module.resource_group.resource_group_location
address_space = "10.0.0.0/16"
address_spaces = ["10.0.0.0/16"]
enable_ddos_pp = false
enable_network_watcher = false # To be set true when network security group flow logs are to be tracked and network watcher with specific name is to be deployed.
}
4 changes: 2 additions & 2 deletions _example/complete/versions.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Terraform version
terraform {
required_version = ">= 1.6.5"
required_version = ">= 1.6.6"
}

terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = ">=3.83.0"
version = ">=3.85.0"
}
}
}
4 changes: 2 additions & 2 deletions _example/vnet_with_existing_ddos_id/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module "vnet" {
environment = local.environment
resource_group_name = module.resource_group.resource_group_name
location = module.resource_group.resource_group_location
address_space = "10.0.0.0/16"
existing_ddos_pp = "/subscriptions/068245d4-3c94-42fe-9c4d-9e5e1cabc60c/resourceGroups/"
address_spaces = ["10.0.0.0/16"]
existing_ddos_pp = "/subscriptions/c/ddosProtectionPlans/vnetddos"
enable_network_watcher = false # To be set true when network security group flow logs are to be tracked and network watcher with specific name is to be deployed.
}
4 changes: 2 additions & 2 deletions _example/vnet_with_existing_ddos_id/versions.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Terraform version
terraform {
required_version = ">= 1.6.5"
required_version = ">= 1.6.6"
}

terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = ">=3.83.0"
version = ">=3.85.0"
}
}
}
11 changes: 1 addition & 10 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module "labels" {
resource "azurerm_virtual_network" "vnet" {
count = var.enable == true ? 1 : 0
name = format("%s-vnet", module.labels.id)
address_space = length(var.address_spaces) == 0 ? [var.address_space] : var.address_spaces
address_space = var.address_spaces
resource_group_name = var.resource_group_name
flow_timeout_in_minutes = var.flow_timeout_in_minutes
location = var.location
Expand All @@ -36,15 +36,6 @@ resource "azurerm_virtual_network" "vnet" {
enforcement = var.enforcement
}

dynamic "subnet" {
for_each = var.subnets == null ? [] : var.subnets
content {
name = subnets.value.name
address_prefix = subnets.value.address_prefix
security_group = subnets.security_group
}
}

dynamic "ddos_protection_plan" {
for_each = local.ddos_pp_id != null ? ["ddos_protection_plan"] : []
content {
Expand Down
24 changes: 5 additions & 19 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#Description : Terraform label module variables.
variable "name" {
type = string
default = ""
default = null
description = "Name (e.g. `app` or `cluster`)."
}

Expand All @@ -20,7 +20,7 @@ variable "repository" {

variable "environment" {
type = string
default = ""
default = null
description = "Environment (e.g. `prod`, `dev`, `staging`)."
}

Expand All @@ -44,22 +44,16 @@ variable "enable" {

variable "resource_group_name" {
type = string
default = ""
default = null
description = "The name of the resource group in which to create the virtual network. Changing this forces a new resource to be created."
}

variable "location" {
type = string
default = ""
default = null
description = "The location/region where the virtual network is created. Changing this forces a new resource to be created."
}

variable "address_space" {
type = string
default = ""
description = "The address space that is used by the virtual network."
}

variable "address_spaces" {
type = list(string)
default = []
Expand Down Expand Up @@ -112,12 +106,4 @@ variable "enforcement" {
description = "Specifies if the encrypted Virtual Network allows VM that does not support encryption. Possible values are DropUnencrypted and AllowUnencrypted."
}

variable "subnets" {
type = list(object({
name = string
address_prefix = string
security_group = list(any)
}))
default = null
description = "Can be specified multiple times to define multiple subnets. Each subnet block supports fields documented below."
}

4 changes: 2 additions & 2 deletions versions.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Terraform version
terraform {
required_version = ">= 1.6.5"
required_version = ">= 1.6.6"
}

terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = ">=3.83.0"
version = ">=3.85.0"
}
}
}

0 comments on commit 05cc023

Please sign in to comment.