Git Product home page Git Product logo

terraform-azurerm-subnet's Introduction

Azure network - Subnet

Changelog Notice Apache V2 License TF Registry

Common Azure module to generate a Virtual Network Subnet. This module must be used within a Virtual Network.

Global versioning rule for Claranet Azure modules

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

Contributing

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.

Usage

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"]
}

Providers

Name Version
azurecaf ~> 1.2, >= 1.2.22
azurerm ~> 3.18

Modules

No modules.

Resources

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

Inputs

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 Subnet delegations configuration.
map(list(object({
name = string
actions = list(string)
})))
{} 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

Outputs

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.
subnet_nsg_association_id Subnet network security group association ID.
subnet_rt_association_id Subnet route table association ID.

Related documentation

Microsoft Azure documentation: docs.microsoft.com/en-us/azure/virtual-network/virtual-network-manage-subnet

terraform-azurerm-subnet's People

Contributors

bd-clara avatar bzspi avatar jmapro avatar rossifumax avatar semantic-release-bot avatar shr3ps avatar taoufik07 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

terraform-azurerm-subnet's Issues

AZ-DOP-1309: Add variables custom_service_endpoints, custom_enforce_private_links

Issue

I was not able to set the following attributes of the azurerm resource azurerm_subnet

  • service_endpoints

  • enforce_private_link

when my set of subnets are not using the same value.

That prevent to easly build/manage a set subnets without invoking an instance of this module by subnet.

Suggestion

Add variables custom_service_endpoints, custom_enforce_private_links, respectively

  • to set custom service_endpoints and by subnet

  • to set custom enforce_private_link_endpoint_network_policies by subnet.

@Shr3ps

subnet_association and route_table_association as output variables

Community Note

  • Please vote on this issue by adding a ๐Ÿ‘ reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

Add subnet_association and route_table_association resource id's as output variables

New or Affected Resource(s)/Data Source(s)

azurem_rm > 3.X.X

Potential Terraform Configuration

No response

References

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.