Common Azure module to generate a Virtual Network Subnet. This module must be used within a Virtual Network.
Module version | Terraform version | AzureRM version |
---|---|---|
>= 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 "azure_region" {
source = "claranet/regions/azurerm"
version = "x.x.x"
azure_region = var.azure_region
}
module "rg" {
source = "claranet/rg/azurerm"
version = "x.x.x"
location = module.azure_region.location
client_name = var.client_name
environment = var.environment
stack = var.stack
}
module "azure_network_vnet" {
source = "claranet/vnet/azurerm"
version = "x.x.x"
environment = var.environment
location = module.azure_region.location
location_short = module.azure_region.location_short
client_name = var.client_name
stack = var.stack
resource_group_name = module.rg.resource_group_name
vnet_cidr = ["10.0.1.0/24"]
}
module "azure_network_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.resource_group_name
}
module "azure_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.resource_group_name
}
module "azure_network_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.resource_group_name
virtual_network_name = module.azure_network_vnet.virtual_network_name
subnet_cidr_list = ["10.0.1.0/26"]
subnet_delegation = {
app-service-plan = [
{
name = "Microsoft.Web/serverFarms"
actions = ["Microsoft.Network/virtualNetworks/subnets/action"]
}
]
}
route_table_name = module.azure_network_route_table.route_table_name
network_security_group_name = module.azure_network_security_group.network_security_group_name
service_endpoints = ["Microsoft.Storage", "Microsoft.KeyVault", "Microsoft.ServiceBus", "Microsoft.Web"]
}
Name | Version |
---|---|
azurecaf | ~> 1.2, >= 1.2.22 |
azurerm | ~> 3.18 |
No modules.
Name | Type |
---|---|
azurerm_subnet.subnet | resource |
azurerm_subnet_network_security_group_association.subnet_association | resource |
azurerm_subnet_route_table_association.route_table_association | resource |
azurecaf_name.subnet | data source |
azurerm_subscription.current | data source |
Name | Description | Type | Default | Required |
---|---|---|---|---|
client_name | Client name/account used in naming | string |
n/a | yes |
custom_subnet_name | Optional custom subnet name | string |
null |
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_link_endpoint_enabled | Enable or disable network policies for the Private Endpoint on the subnet. | bool |
null |
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 |
subnet_cidr_list | The address prefix list to use for the subnet. | list(string) |
n/a | yes |
subnet_delegation | Configuration delegations on subnet object({ name = object({ name = string, actions = list(string) }) }) |
map(list(any)) |
{} |
no |
use_caf_naming | Use the Azure CAF naming provider to generate default resource name. custom_subnet_name override this if set. Legacy default name is used if this is set to false . |
bool |
true |
no |
virtual_network_name | Virtual network name | string |
n/a | yes |
Name | Description |
---|---|
subnet_cidr_list | CIDR list of the created subnets |
subnet_cidrs_map | Map with names and CIDRs of the created subnets |
subnet_id | Id of the created subnet |
subnet_ips | The collection of IPs within this subnet |
subnet_name | Name of the created subnet |
Microsoft Azure documentation: docs.microsoft.com/en-us/azure/virtual-network/virtual-network-manage-subnet