|
| 1 | +## Requirements |
| 2 | + |
| 3 | +| Name | Version | |
| 4 | +|------|---------| |
| 5 | +| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.7.0 | |
| 6 | +| <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) | >= 4.16.0 | |
| 7 | + |
| 8 | +--- |
| 9 | + |
| 10 | +## Providers |
| 11 | + |
| 12 | +| Name | Version | |
| 13 | +|------|---------| |
| 14 | +| <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) | >= 4.16.0 | |
| 15 | + |
| 16 | +--- |
| 17 | + |
| 18 | +## Resources |
| 19 | + |
| 20 | +| Name | Type | |
| 21 | +|------|------| |
| 22 | +| [azurerm_network_security_group.this](https://registry.terraform.io/providers/hashicorp/azurerm/4.16.0/docs/resources/network_security_group) | resource | |
| 23 | +| [azurerm_network_security_rule.this](https://registry.terraform.io/providers/hashicorp/azurerm/4.16.0/docs/resources/network_security_rule) | resource | |
| 24 | + |
| 25 | +--- |
| 26 | + |
| 27 | +## Inputs |
| 28 | + |
| 29 | +### Network Security Group Configuration |
| 30 | + |
| 31 | +| Name | Description | Type | Default | Required | |
| 32 | +|------|-------------|------|---------|:--------:| |
| 33 | +| `name` | The name of the Network Security Group. | `string` | - | yes | |
| 34 | +| `location` | The Azure region where the NSG will be created. | `string` | - | yes | |
| 35 | +| `resource_group_name` | The name of the resource group in which to create the NSG. | `string` | - | yes | |
| 36 | +| `tags` | A map of tags to assign to the NSG. | `map(string)` | `{}` | no | |
| 37 | + |
| 38 | +### Network Security Rules |
| 39 | + |
| 40 | +| Name | Description | Type | Default | Required | |
| 41 | +|------|-------------|------|---------|:--------:| |
| 42 | +| `name` | The name of the security rule. | `string` | - | yes | |
| 43 | +| `priority` | The priority of the rule. | `number` | - | yes | |
| 44 | +| `direction` | The direction of the rule (Inbound/Outbound). | `string` | - | yes | |
| 45 | +| `access` | The access type (Allow/Deny). | `string` | - | yes | |
| 46 | +| `protocol` | The network protocol (Tcp, Udp, Icmp, etc.). | `string` | - | yes | |
| 47 | +| `source_port_range` | The source port range. | `string` | - | show bellow | |
| 48 | +| `source_port_ranges` | A list of source port ranges. | `list(string)` | - | show bellow | |
| 49 | +| `destination_port_range` | The destination port range. | `string` | - | show bellow | |
| 50 | +| `destination_port_ranges` | A list of destination port ranges. | `list(string)` | - | show bellow | |
| 51 | +| `source_address_prefix` | The source address prefix. | `string` | - | show bellow | |
| 52 | +| `source_address_prefixes` | A list of source address prefixes. | `list(string)` | - | show bellow | |
| 53 | +| `destination_address_prefix` | The destination address prefix. | `string` | - | show bellow | |
| 54 | +| `destination_address_prefixes` | A list of destination address prefixes. | `list(string)` | - | show bellow | |
| 55 | + |
| 56 | +**source_port_range** and **source_port_ranges** are required to have at least one of them but you can't have both at the same time. |
| 57 | + |
| 58 | +**destination_port_range** and **destination_port_ranges** are required to have at least one of them but you can't have both at the same time. |
| 59 | + |
| 60 | +**source_address_prefix** and **source_address_prefixes** are required to have at least one of them but you can't have both at the same time. |
| 61 | + |
| 62 | +**destination_address_prefix** and **destination_address_prefixes** are required to have at least one of them but you can't have both at the same time. |
| 63 | + |
| 64 | +## Example Usage |
| 65 | + |
| 66 | +```hcl |
| 67 | +
|
| 68 | +nsg = { |
| 69 | + name = "example-nsg" |
| 70 | + location = "East US" |
| 71 | + resource_group_name = "example-rg" |
| 72 | + tags = { |
| 73 | + env = "Production" |
| 74 | + } |
| 75 | +} |
| 76 | +
|
| 77 | +rules = { |
| 78 | + rule1 = { |
| 79 | + name = "AllowSSH" |
| 80 | + priority = 100 |
| 81 | + direction = "Inbound" |
| 82 | + access = "Allow" |
| 83 | + protocol = "Tcp" |
| 84 | + source_port_range = "*" |
| 85 | + destination_port_range = "22" |
| 86 | + source_address_prefix = "10.0.0.0/24" |
| 87 | + destination_address_prefix = "*" |
| 88 | + } |
| 89 | + rule2 = { |
| 90 | + name = "AllowHTTP" |
| 91 | + priority = 200 |
| 92 | + direction = "Inbound" |
| 93 | + access = "Allow" |
| 94 | + protocol = "Tcp" |
| 95 | + source_port_range = "*" |
| 96 | + destination_port_range = "80" |
| 97 | + source_address_prefix = "0.0.0.0/0" |
| 98 | + destination_address_prefix = "*" |
| 99 | + } |
| 100 | +} |
| 101 | +``` |
0 commit comments