With this module you can create a virtual network with subnets and security groups in Azure.
module "virtual_network" {
source = "<module-source>"
resource_group_name = "<resource-group-name>"
location = "<location>"
name = "<virtual-network-name>"
subnets = [
{
name = "<subnet-name>"
address_prefixes = ["<subnet-address-prefixes>"]
},
{
name = "<subnet-name>"
address_prefixes = ["<subnet-address-prefixes>"]
}
]
}
This module can also create security groups and assign them to subnets.By default they're not being attached so to do that, specify assign_to
variable with the name of the subnet to which the security group should be assigned.
module "virtual_network" {
source = "<module-source>"
resource_group_name = "<resource-group-name>"
location = "<location>"
name = "<virtual-network-name>"
subnets = [
{
name = "<subnet-name>"
address_prefixes = ["<subnet-address-prefixes>"]
},
{
name = "<subnet-name>"
address_prefixes = ["<subnet-address-prefixes>"]
}
]
security_groups = [
{
name = "<security-group-name>"
assign_to = "<subnet-name>"
rules = [
{
name = "<rule-name>"
protocol = "<rule-protocol>"
access = "<rule-access>"
priority = "<rule-priority>"
direction = "<rule-direction>"
source_port_range = "*"
destination_port_range = "*"
source_address_prefix = "*"
destination_address_prefix = "*"
}
]
}
]
}
If you want to get specific ID of either the subnet or security group, you can use the following syntax:
module.virtual_network.subnet_ids["<subnet-name>"]
module.virtual_network.security_group_ids["<security-group-name>"]
Name | Version |
---|---|
terraform | >= 1.3.1 |
azurerm | >=3.33 |
Name | Version |
---|---|
azurerm | >=3.33 |
No modules.
Name | Type |
---|---|
azurerm_network_security_group.this | resource |
azurerm_subnet.this | resource |
azurerm_subnet_network_security_group_association.this | resource |
azurerm_virtual_network.this | resource |
Name | Description | Type | Default | Required |
---|---|---|---|---|
address_space | (Required) The address space that is used the Virtual Network. | list(string) |
n/a | yes |
bgp_community | (Optional) The BGP community attribute in format :. | string |
null |
no |
ddos_protection_plan | (Optional) A configuration block for DDoS protection plan. | object({ |
null |
no |
dns_servers | (Optional) List of IP addresses of DNS servers. | list(string) |
null |
no |
edge_zone | (Optional) Specifies the Edge Zone within the Azure Region where this Virtual Network should exist. Changing this forces a new Virtual Network to be created. | string |
null |
no |
flow_timeout_in_minutes | (Optional) The flow timeout in minutes for the Virtual Network, which is used to enable connection tracking for intra-VM flows. Possible values are between 4 and 30 minutes. | number |
null |
no |
location | (Required) The location in which to create the Kubernetes Cluster. | string |
n/a | yes |
name | (Required) The name of the Virtual Network. | string |
n/a | yes |
resource_group_name | (Required) The name of the resource group in which to create the Kubernetes Cluster. | string |
n/a | yes |
security_groups | (Optional) A list of security groups to create. | list(object({ |
[] |
no |
subnets | (Required) A list of subnets to create within the Virtual Network. | list(object({ |
n/a | yes |
tags | (Optional) A mapping of tags to assign to the resource. | map(string) |
null |
no |
Name | Description |
---|---|
id | The ID of the virtual network. |
name | The name of the virtual network. |
security_group_ids | The IDs of the security groups. |
subnet_ids | The IDs of the subnets within the virtual network. |