From 9ce4e6ffaf2d6eb633df68f19546299f24873a67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EC=A0=95=EA=B2=BD?= Date: Tue, 2 Aug 2022 19:16:09 +0900 Subject: [PATCH 1/2] add ddos_protection_plan configuration to vnet --- main.tf | 8 ++++++++ variables.tf | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/main.tf b/main.tf index 131a6c9..34efc18 100644 --- a/main.tf +++ b/main.tf @@ -10,6 +10,14 @@ resource "azurerm_virtual_network" "vnet" { address_space = var.address_space dns_servers = var.dns_servers tags = var.tags + dynamic "ddos_protection_plan" { + for_each = var.ddos_protection_plan + + content { + enable = ddos_protection_plan.value["enable"] + id = ddos_protection_plan.value["id"] + } + } } resource "azurerm_subnet" "subnet" { diff --git a/variables.tf b/variables.tf index 755f2b1..aa28cc4 100644 --- a/variables.tf +++ b/variables.tf @@ -86,3 +86,14 @@ variable "vnet_location" { type = string default = null } + +variable "ddos_protection_plan" { + description = "The set of DDos protection plan configuration" + type = set(object( + { + enable = bool + id = string + } + )) + default = [] +} From c2aa49b656ae61b7fa83f81685fa2e4eba030b89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EC=A0=95=EA=B2=BD?= Date: Thu, 4 Aug 2022 12:17:47 +0900 Subject: [PATCH 2/2] Fix typo. Modify var.ddos_protection_plan type to object --- main.tf | 7 ++++--- variables.tf | 14 ++++++-------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/main.tf b/main.tf index 34efc18..57636ba 100644 --- a/main.tf +++ b/main.tf @@ -10,12 +10,13 @@ resource "azurerm_virtual_network" "vnet" { address_space = var.address_space dns_servers = var.dns_servers tags = var.tags + dynamic "ddos_protection_plan" { - for_each = var.ddos_protection_plan + for_each = var.ddos_protection_plan != null ? [var.ddos_protection_plan] : [] content { - enable = ddos_protection_plan.value["enable"] - id = ddos_protection_plan.value["id"] + enable = ddos_protection_plan.value.enable + id = ddos_protection_plan.value.id } } } diff --git a/variables.tf b/variables.tf index aa28cc4..9133350 100644 --- a/variables.tf +++ b/variables.tf @@ -88,12 +88,10 @@ variable "vnet_location" { } variable "ddos_protection_plan" { - description = "The set of DDos protection plan configuration" - type = set(object( - { - enable = bool - id = string - } - )) - default = [] + description = "The set of DDoS protection plan configuration" + type = object({ + enable = bool + id = string + }) + default = null }