From 470d38111374b0bcfd79bac8a5af6bf710a8f15d Mon Sep 17 00:00:00 2001 From: Dima Date: Tue, 16 Apr 2024 13:13:18 +0300 Subject: [PATCH] fix: asg support --- README.md | 39 ++++++++++++++++++--------------------- main.tf | 29 +++++++++++++++-------------- variables.tf | 29 +++++++++++++++-------------- 3 files changed, 48 insertions(+), 49 deletions(-) diff --git a/README.md b/README.md index 3ffda25..67317c8 100644 --- a/README.md +++ b/README.md @@ -36,15 +36,15 @@ module "network_security_group" { ## Requirements -| Name | Version | -| ------------------------------------------------------------------------- | --------- | -| [terraform](#requirement\_terraform) | >= 1.0.0 | -| [azurerm](#requirement\_azurerm) | >= 3.40.0 | +| Name | Version | +|------|---------| +| [terraform](#requirement\_terraform) | >= 1.0.0 | +| [azurerm](#requirement\_azurerm) | >= 3.40.0 | ## Providers -| Name | Version | -| ------------------------------------------------------------- | --------- | +| Name | Version | +|------|---------| | [azurerm](#provider\_azurerm) | >= 3.40.0 | ## Modules @@ -53,28 +53,25 @@ No modules. ## Resources -| Name | Type | -| ------------------------------------------------------------------------------------------------------------------------------------------------ | -------- | -| [azurerm_network_security_group.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/network_security_group) | resource | +| Name | Type | +|------|------| +| [azurerm_network_security_group.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/network_security_group) | resource | ## Inputs -| Name | Description | Type | Default | Required | -| --------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| ------- | :------: | +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [location](#input\_location) | Specifies the supported Azure location where the resource exists | `string` | n/a | yes | | [nsg\_name](#input\_nsg\_name) | Network Security Group name | `string` | n/a | yes | -| [location](#input\_location) | Specifies the supported Azure location where the resource exists | `string`| n/a | yes | -| [resource\_group](#input\_resource\_group) | The name of the resource group in which resources is created | `string`| n/a | yes | -| [tags](#input\_tags) | A mapping of tags to assign to the resource | `map(string)`| {} | no | -| [security\_rules](#input\_security\_rules) | List of objects representing security rules |
list(object({
name = string
priority = number
direction = string
access = string
protocol = string
description = optional(string)
source_port_range = optional(string)
source_port_ranges = optional(list(string))
destination_port_range = optional(string)
destination_port_ranges = optional(list(string))
source_address_prefix = optional(string)
source_address_prefixes = optional(list(string))
destination_address_prefix = optional(string)
destination_address_prefixes = optional(list(string))
}))
| [] | no | - - +| [resource\_group](#input\_resource\_group) | The name of the resource group in which resources is created | `string` | n/a | yes | +| [security\_rules](#input\_security\_rules) | List of objects representing security rules |
list(object({
name = string
priority = number
direction = string
access = string
protocol = string
description = optional(string, null)
source_port_range = optional(string, null)
source_port_ranges = optional(list(string), [])
destination_port_range = optional(string, null)
destination_port_ranges = optional(list(string), [])
source_address_prefix = optional(string, null)
source_address_prefixes = optional(list(string), [])
destination_address_prefix = optional(string, null)
destination_address_prefixes = optional(list(string), [])
destination_application_security_group_ids = optional(list(string), [])
}))
| `[]` | no | +| [tags](#input\_tags) | A mapping of tags to assign to the resource | `map(string)` | `{}` | no | ## Outputs -| Name | Description | -| ------------------------------------------------------------------------------------------------------------- | ------------------------------------- | -| [id](#output\_id) | The ID of the Network Security Group | - +| Name | Description | +|------|-------------| +| [id](#output\_id) | The ID of the Network Security Group | diff --git a/main.tf b/main.tf index d94e6df..1faf2cd 100644 --- a/main.tf +++ b/main.tf @@ -7,20 +7,21 @@ resource "azurerm_network_security_group" "this" { dynamic "security_rule" { for_each = var.security_rules content { - name = security_rule.value.name - priority = security_rule.value.priority - direction = security_rule.value.direction - access = security_rule.value.access - protocol = security_rule.value.protocol - description = security_rule.value.description - source_port_range = security_rule.value.source_port_range - source_port_ranges = security_rule.value.source_port_ranges - destination_port_range = security_rule.value.destination_port_range - destination_port_ranges = security_rule.value.destination_port_ranges - source_address_prefix = security_rule.value.source_address_prefix - source_address_prefixes = security_rule.value.source_address_prefixes - destination_address_prefix = security_rule.value.destination_address_prefix - destination_address_prefixes = security_rule.value.destination_address_prefixes + name = security_rule.value.name + priority = security_rule.value.priority + direction = security_rule.value.direction + access = security_rule.value.access + protocol = security_rule.value.protocol + description = security_rule.value.description + source_port_range = security_rule.value.source_port_range + source_port_ranges = security_rule.value.source_port_ranges + destination_port_range = security_rule.value.destination_port_range + destination_port_ranges = security_rule.value.destination_port_ranges + source_address_prefix = security_rule.value.source_address_prefix + source_address_prefixes = security_rule.value.source_address_prefixes + destination_address_prefix = security_rule.value.destination_address_prefix + destination_address_prefixes = security_rule.value.destination_address_prefixes + destination_application_security_group_ids = security_rule.value.destination_application_security_group_ids } } } diff --git a/variables.tf b/variables.tf index 932d6a6..c560e08 100644 --- a/variables.tf +++ b/variables.tf @@ -21,20 +21,21 @@ variable "tags" { variable "security_rules" { type = list(object({ - name = string - priority = number - direction = string - access = string - protocol = string - description = optional(string, null) - source_port_range = optional(string, null) - source_port_ranges = optional(list(string), []) - destination_port_range = optional(string, null) - destination_port_ranges = optional(list(string), []) - source_address_prefix = optional(string, null) - source_address_prefixes = optional(list(string), []) - destination_address_prefix = optional(string, null) - destination_address_prefixes = optional(list(string), []) + name = string + priority = number + direction = string + access = string + protocol = string + description = optional(string, null) + source_port_range = optional(string, null) + source_port_ranges = optional(list(string), []) + destination_port_range = optional(string, null) + destination_port_ranges = optional(list(string), []) + source_address_prefix = optional(string, null) + source_address_prefixes = optional(list(string), []) + destination_address_prefix = optional(string, null) + destination_address_prefixes = optional(list(string), []) + destination_application_security_group_ids = optional(list(string), []) })) description = "List of objects representing security rules" default = []