Skip to content

avidhara/terraform-azurerm-subnets

Repository files navigation

Terraform module for Azure Subnets

How to use it as a module

module "subnets" {
  source  = "./"
  resource_group_name       = "terraform-test"
  virtual_network_name      = "terraform-test"
  address_prefixes          = ["10.0.1.0/24"]
  service_endpoints         = ["Microsoft.KeyVault", "Microsoft.ServiceBus", "Microsoft.ContainerRegistry", "Microsoft.EventHub", "Microsoft.Storage"]
  associate_nat_gateway     = true
  nat_gateway_id            = "/subscriptions/xxxxx/resourceGroups/terraform-test/providers/Microsoft.Network/natGateways/terraform-test"
}

Requirements

Name Version
terraform >= 0.13.1
azurerm >= 3.0.0

Providers

Name Version
azurerm >= 3.0.0

Modules

No modules.

Resources

Name Type
azurerm_subnet.this resource
azurerm_subnet_nat_gateway_association.this resource
azurerm_subnet_network_security_group_association.this resource

Inputs

Name Description Type Default Required
address_prefixes (Required) The address prefixes to use for the subnet. list(string) n/a yes
associate_nat_gateway (Optional) Do you want to associate NAT Gateway to subnets bool false no
associate_nsg (Optional) Do you want to associate nsg with subnet bool true no
create_subnets Do you want to create subnet bool true no
delegation (Optional) One or more delegation blocks any [] no
name (Required) The name of the subnet. Changing this forces a new resource to be created. string n/a yes
nat_gateway_id (Optional) The ID of the NAT Gateway which should be associated with the Subnet. Changing this forces a new resource to be created. string null no
network_security_group_id (Required) The ID of the Network Security Group which should be associated with the Subnet. Changing this forces a new resource to be created. string null no
private_endpoint_network_policies_enabled (Optional) Enable or Disable network policies for the private endpoint on the subnet. Setting this to true will Enable the policy and setting this to false will Disable the policy. Defaults to true. bool true no
private_link_service_network_policies_enabled (Optional) Enable or Disable network policies for the private link service on the subnet. Setting this to true will Enable the policy and setting this to false will Disable the policy. Defaults to true. bool true no
resource_group_name (Required) The name of the resource group in which to create the subnet. Changing this forces a new resource to be created. string n/a yes
service_endpoint_policy_ids (Optional) The list of IDs of Service Endpoint Policies to associate with the subnet. list(string) null no
service_endpoints (Optional) The list of Service endpoints to associate with the subnet. Possible values include: Microsoft.AzureActiveDirectory, Microsoft.AzureCosmosDB, Microsoft.ContainerRegistry, Microsoft.EventHub, Microsoft.KeyVault, Microsoft.ServiceBus, Microsoft.Sql, Microsoft.Storage, and Microsoft.Web. list(string) null no
virtual_network_name (Required) The name of the virtual network to which to attach the subnet. Changing this forces a new resource to be created. string n/a yes

Outputs

Name Description
id The subnet ID.