Common Azure module to generate a Virtual Network Subnet. This module must be used within a Virtual Network.
Module version | Terraform version | OpenTofu version | AzureRM version |
---|---|---|---|
>= 8.x.x | Unverified | 1.8.x | >= 4.0 |
>= 7.x.x | 1.3.x | >= 3.0 | |
>= 6.x.x | 1.x | >= 3.0 | |
>= 5.x.x | 0.15.x | >= 2.0 | |
>= 4.x.x | 0.13.x / 0.14.x | >= 2.0 | |
>= 3.x.x | 0.12.x | >= 2.0 | |
>= 2.x.x | 0.12.x | < 2.0 | |
< 2.x.x | 0.11.x | < 2.0 |
If you want to contribute to this repository, feel free to use our pre-commit git hook configuration which will help you automatically update and format some files for you by enforcing our Terraform code module best-practices.
More details are available in the CONTRIBUTING.md file.
This module is optimized to work with the Claranet terraform-wrapper tool
which set some terraform variables in the environment needed by this module.
More details about variables set by the terraform-wrapper
available in the documentation.
module "route_table" {
source = "claranet/route-table/azurerm"
version = "x.x.x"
client_name = var.client_name
environment = var.environment
stack = var.stack
location = module.azure_region.location
location_short = module.azure_region.location_short
resource_group_name = module.rg.name
}
# module "network_security_group" {
# source = "claranet/nsg/azurerm"
# version = "x.x.x"
# client_name = var.client_name
# environment = var.environment
# location = module.azure_region.location
# location_short = module.azure_region.location_short
# stack = var.stack
# resource_group_name = module.rg.name
# }
module "subnet" {
source = "claranet/subnet/azurerm"
version = "x.x.x"
environment = var.environment
location_short = module.azure_region.location_short
client_name = var.client_name
stack = var.stack
resource_group_name = module.rg.name
virtual_network_name = module.vnet.name
cidrs = ["10.0.1.0/26"]
delegations = {
app-service-plan = [
{
name = "Microsoft.Web/serverFarms"
actions = ["Microsoft.Network/virtualNetworks/subnets/action"]
}
]
}
route_table_name = module.route_table.name
# network_security_group_name = module.network_security_group.name
service_endpoints = ["Microsoft.Storage", "Microsoft.KeyVault", "Microsoft.ServiceBus", "Microsoft.Web"]
}
Name | Version |
---|---|
azurecaf | ~> 1.2.28 |
azurerm | ~> 4.0 |
No modules.
Name | Type |
---|---|
azurerm_subnet.main | resource |
azurerm_subnet_network_security_group_association.main | resource |
azurerm_subnet_route_table_association.main | resource |
azurecaf_name.subnet | data source |
azurerm_subscription.main | data source |
Name | Description | Type | Default | Required |
---|---|---|---|---|
cidrs | The address prefix list to use for the subnet. | list(string) |
n/a | yes |
client_name | Client name/account used in naming. | string |
n/a | yes |
custom_name | Optional custom subnet name. | string |
null |
no |
default_outbound_access_enabled | Enable or disable default_outbound_access . See documentation. |
bool |
false |
no |
delegations | Subnet delegations configuration. | map(list(object({ |
{} |
no |
environment | Project environment. | string |
n/a | yes |
location_short | Short string for Azure location. | string |
n/a | yes |
name_prefix | Optional prefix for the generated name. | string |
"" |
no |
name_suffix | Optional suffix for the generated name. | string |
"" |
no |
network_security_group_name | The Network Security Group name to associate with the subnets. | string |
null |
no |
network_security_group_rg | The Network Security Group RG to associate with the subnet. Default is the same RG than the subnet. | string |
null |
no |
private_endpoint_network_policies | Enable or disable network policies for the private endpoint on the subnet. Possible values are Disabled , Enabled , NetworkSecurityGroupEnabled and RouteTableEnabled . |
string |
null |
no |
private_link_endpoint_enabled | Enable or disable network policies for the Private Endpoint on the subnet. | bool |
true |
no |
private_link_service_enabled | Enable or disable network policies for the Private Link Service on the subnet. | bool |
null |
no |
resource_group_name | Resource group name. | string |
n/a | yes |
route_table_name | The Route Table name to associate with the subnet. | string |
null |
no |
route_table_rg | The Route Table RG to associate with the subnet. Default is the same RG than the subnet. | string |
null |
no |
service_endpoint_policy_ids | The list of IDs of Service Endpoint Policies to associate with the subnet. | list(string) |
null |
no |
service_endpoints | The list of Service endpoints to associate with the subnet. | list(string) |
[] |
no |
stack | Project stack name. | string |
n/a | yes |
virtual_network_name | Virtual network name. | string |
n/a | yes |
Name | Description |
---|---|
cidrs | CIDR list of the created subnets. |
cidrs_map | Map with names and CIDRs of the created subnets. |
id | ID of the created subnet. |
ips | The collection of IPs within this subnet. |
name | Name of the created subnet. |
nsg_association | Subnet network security group association resource object. |
nsg_association_id | Subnet network security group association ID. |
resource | Subnet resource object. |
rt_association | Subnet route table association resource object. |
rt_association_id | Subnet route table association ID. |
Microsoft Azure documentation: docs.microsoft.com/en-us/azure/virtual-network/virtual-network-manage-subnet