Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: asg support #5

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 18 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ module "network_security_group" {
<!-- BEGIN_TF_DOCS -->
## Requirements

| Name | Version |
| ------------------------------------------------------------------------- | --------- |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0.0 |
| <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) | >= 3.40.0 |
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0.0 |
| <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) | >= 3.40.0 |

## Providers

| Name | Version |
| ------------------------------------------------------------- | --------- |
| Name | Version |
|------|---------|
| <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) | >= 3.40.0 |

## Modules
Expand All @@ -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 |
|------|-------------|------|---------|:--------:|
| <a name="input_location"></a> [location](#input\_location) | Specifies the supported Azure location where the resource exists | `string` | n/a | yes |
| <a name="input_nsg_name"></a> [nsg\_name](#input\_nsg\_name) | Network Security Group name | `string` | n/a | yes |
| <a name="input_location"></a> [location](#input\_location) | Specifies the supported Azure location where the resource exists | `string`| n/a | yes |
| <a name="input_resource_group"></a> [resource\_group](#input\_resource\_group) | The name of the resource group in which resources is created | `string`| n/a | yes |
| <a name="input_tags"></a> [tags](#input\_tags) | A mapping of tags to assign to the resource | `map(string)`| {} | no |
| <a name="input_security_rules"></a> [security\_rules](#input\_security\_rules) | List of objects representing security rules | <pre>list(object({<br> name = string<br> priority = number<br> direction = string<br> access = string<br> protocol = string<br> description = optional(string)<br> source_port_range = optional(string)<br> source_port_ranges = optional(list(string))<br> destination_port_range = optional(string)<br> destination_port_ranges = optional(list(string))<br> source_address_prefix = optional(string)<br> source_address_prefixes = optional(list(string))<br> destination_address_prefix = optional(string)<br> destination_address_prefixes = optional(list(string))<br>}))</pre> | [] | no |


| <a name="input_resource_group"></a> [resource\_group](#input\_resource\_group) | The name of the resource group in which resources is created | `string` | n/a | yes |
| <a name="input_security_rules"></a> [security\_rules](#input\_security\_rules) | List of objects representing security rules | <pre>list(object({<br> name = string<br> priority = number<br> direction = string<br> access = string<br> protocol = string<br> description = optional(string, null)<br> source_port_range = optional(string, null)<br> source_port_ranges = optional(list(string), [])<br> destination_port_range = optional(string, null)<br> destination_port_ranges = optional(list(string), [])<br> source_address_prefix = optional(string, null)<br> source_address_prefixes = optional(list(string), [])<br> destination_address_prefix = optional(string, null)<br> destination_address_prefixes = optional(list(string), [])<br> destination_application_security_group_ids = optional(list(string), [])<br> }))</pre> | `[]` | no |
| <a name="input_tags"></a> [tags](#input\_tags) | A mapping of tags to assign to the resource | `map(string)` | `{}` | no |

## Outputs

| Name | Description |
| ------------------------------------------------------------------------------------------------------------- | ------------------------------------- |
| <a name="output_id"></a> [id](#output\_id) | The ID of the Network Security Group |

| Name | Description |
|------|-------------|
| <a name="output_id"></a> [id](#output\_id) | The ID of the Network Security Group |

<!-- END_TF_DOCS -->

Expand Down
29 changes: 15 additions & 14 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
29 changes: 15 additions & 14 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
Loading