Skip to content

clouddrove/terraform-azure-vnet

Terraform AZURE VNET

Terraform module to create VIRTUAL-NETWORK resource on AZURE.

Terraform Licence


We eat, drink, sleep and most importantly love DevOps. We are working towards strategies for standardizing architecture while ensuring security for the infrastructure. We are strong believer of the philosophy Bigger problems are always solved by breaking them into smaller manageable problems. Resonating with microservices architecture, it is considered best-practice to run database, cluster, storage in smaller connected yet manageable pieces within the infrastructure.

This module is basically combination of Terraform open source and includes automatation tests and examples. It also helps to create and improve your infrastructure with minimalistic code instead of maintaining the whole infrastructure code yourself.

We have fifty plus terraform modules. A few of them are comepleted and are available for open source usage while a few others are in progress.

Prerequisites

This module has a few dependencies:

Examples

IMPORTANT: Since the master branch used in source varies based on new modifications, we suggest that you use the release versions here.

Simple Example

Here is an example of how you can use this module in your inventory structure:

module "virtual-network" {
 source              = "clouddrove/vnet/azure"
 name                = "app"
 environment         = "test"
 label_order         = ["name", "environment"]
 resource_group_name = module.resource_group.resource_group_name
 location            = module.resource_group.resource_group_location
 address_space       = "10.0.0.0/16"
 }

##vnet with flow log

module "virtual-network" {
 source              = "clouddrove/vnet/azure"
 name                = "app"
 environment         = "test"
 label_order         = ["name", "environment"]
 resource_group_name = module.resource_group.resource_group_name
 location            = module.resource_group.resource_group_location
 address_space       = "10.0.0.0/16"
 ## For enabling network flow logs for vnet.
 enable_flow_logs          = true
 enable_network_watcher    = true
 enable_traffic_analytics  = true
 network_security_group_id = module.security_group.id
 storage_account_id        = module.storage.default_storage_account_id
 workspace_id              = module.log-analytics.workspace_customer_id
 workspace_resource_id     = module.log-analytics.workspace_id
 }

Inputs

Name Description Type Default Required
address_space The address space that is used by the virtual network. string "" no
address_spaces The list of the address spaces that is used by the virtual network. list(string) [] no
attributes Additional attributes (e.g. 1). list(any) [] no
bgp_community The BGP community attribute in format :. number null no
delimiter Delimiter to be used between organization, environment, name and attributes. string "-" no
dns_servers The DNS servers to be used with vNet. list(string) [] 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
enable Flag to control the module creation bool true no
enable_ddos_pp Flag to control the resource creation bool false no
enable_flow_logs Flag to control creation of flow logs for nsg. bool false no
enable_network_watcher Flag to control creation of network watcher. bool false no
enable_traffic_analytics Flag to control creation of traffic analytics. bool true no
environment Environment (e.g. prod, dev, staging). string "" no
flow_timeout_in_minutes 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 10 no
label_order Label order, e.g. name,application. list(any) [] no
location The location/region where the virtual network is created. Changing this forces a new resource to be created. string "" no
managedby ManagedBy, eg 'CloudDrove'. string "[email protected]" no
name Name (e.g. app or cluster). string "" no
network_security_group_id Id of network security group for which flow are to be calculated string null no
repository Terraform current module repo string "https://github.com/clouddrove/terraform-azure-virtual-network" no
resource_group_name The name of the resource group in which to create the virtual network. Changing this forces a new resource to be created. string "" no
retention_policy_days The number of days to retain flow log records. number 30 no
retention_policy_enabled Boolean flag to enable/disable retention. bool true no
storage_account_id Id of storage account. string null no
tags Additional tags (e.g. map(BusinessUnit,XYZ). map(any) {} no
workspace_id Log analytics workspace id string null no
workspace_resource_id Resource id of workspace string null no

Outputs

Name Description
ddos_protection_plan_id The ID of the DDoS Protection Plan
network_watcher_id The ID of the Network Watcher.
vnet_address_space The address space of the newly created vNet
vnet_guid The GUID of the virtual network.
vnet_id The id of the newly created vNet
vnet_location The location of the newly created vNet
vnet_name The name of the newly created vNet
vnet_rg_name The name of the resource group in which to create the virtual network. Changing this forces a new resource to be created

Testing

In this module testing is performed with terratest and it creates a small piece of infrastructure, matches the output like ARN, ID and Tags name etc and destroy infrastructure in your AWS account. This testing is written in GO, so you need a GO environment in your system.

You need to run the following command in the testing folder:

  go test -run Test

Feedback

If you come accross a bug or have any feedback, please log it in our issue tracker, or feel free to drop us an email at [email protected].

If you have found it worth your time, go ahead and give us a ★ on our GitHub!

About us

At CloudDrove, we offer expert guidance, implementation support and services to help organisations accelerate their journey to the cloud. Our services include docker and container orchestration, cloud migration and adoption, infrastructure automation, application modernisation and remediation, and performance engineering.

We are The Cloud Experts!


We ❤️ Open Source and you can check out our other modules to get help with your new Cloud ideas.