virtual network manager - initial commit (#226)
* initial commit --------- Co-authored-by: Michael Bender <michael.bender@microsoft.com>
This commit is contained in:
parent
dba97b976b
commit
aae1a9af55
91
quickstart/101-virtual-network-manager-create-mesh/main.tf
Normal file
91
quickstart/101-virtual-network-manager-create-mesh/main.tf
Normal file
@ -0,0 +1,91 @@
|
||||
|
||||
# Create the Resource Group
|
||||
|
||||
resource "random_pet" "rg_name" {
|
||||
prefix = var.resource_group_name_prefix
|
||||
}
|
||||
|
||||
resource "azurerm_resource_group" "rg" {
|
||||
location = var.resource_group_location
|
||||
name = random_pet.rg_name.id
|
||||
}
|
||||
|
||||
# Create three virtual networks
|
||||
|
||||
resource "random_pet" "virtual_network_name" {
|
||||
prefix = "vnet"
|
||||
}
|
||||
resource "azurerm_virtual_network" "vnet" {
|
||||
count = 3
|
||||
|
||||
name = "${random_pet.virtual_network_name.id}-0${count.index}"
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
location = azurerm_resource_group.rg.location
|
||||
address_space = ["10.${count.index}.0.0/16"]
|
||||
}
|
||||
|
||||
# Add a subnet to each virtual network
|
||||
|
||||
resource "azurerm_subnet" "subnet_vnet" {
|
||||
count = 3
|
||||
|
||||
name = "default"
|
||||
virtual_network_name = azurerm_virtual_network.vnet[count.index].name
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
address_prefixes = ["10.${count.index}.0.0/24"]
|
||||
}
|
||||
|
||||
# Create a Virtual Network Manager instance
|
||||
|
||||
data "azurerm_subscription" "current" {
|
||||
}
|
||||
|
||||
resource "azurerm_network_manager" "network_manager_instance" {
|
||||
name = "network-manager"
|
||||
location = azurerm_resource_group.rg.location
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
scope_accesses = ["Connectivity"]
|
||||
description = "example network manager"
|
||||
scope {
|
||||
subscription_ids = [data.azurerm_subscription.current.id]
|
||||
}
|
||||
}
|
||||
|
||||
# Create a network group
|
||||
|
||||
resource "azurerm_network_manager_network_group" "network_group" {
|
||||
name = "network-group"
|
||||
network_manager_id = azurerm_network_manager.network_manager_instance.id
|
||||
}
|
||||
|
||||
# Add the three virtual networks to the network group as static members
|
||||
|
||||
resource "azurerm_network_manager_static_member" "static_members" {
|
||||
count = 3
|
||||
|
||||
name = "static-member-0${count.index}"
|
||||
network_group_id = azurerm_network_manager_network_group.network_group.id
|
||||
target_virtual_network_id = azurerm_virtual_network.vnet[count.index].id
|
||||
}
|
||||
|
||||
# Create a connectivity configuration
|
||||
|
||||
resource "azurerm_network_manager_connectivity_configuration" "connectivity_config" {
|
||||
name = "connectivity-config"
|
||||
network_manager_id = azurerm_network_manager.network_manager_instance.id
|
||||
connectivity_topology = "Mesh"
|
||||
applies_to_group {
|
||||
group_connectivity = "None"
|
||||
network_group_id = azurerm_network_manager_network_group.network_group.id
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Commit deployment
|
||||
|
||||
resource "azurerm_network_manager_deployment" "commit_deployment" {
|
||||
network_manager_id = azurerm_network_manager.network_manager_instance.id
|
||||
location = azurerm_resource_group.rg.location
|
||||
scope_access = "Connectivity"
|
||||
configuration_ids = [azurerm_network_manager_connectivity_configuration.connectivity_config.id]
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
output "resource_group_name" {
|
||||
value = azurerm_resource_group.rg.name
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
terraform {
|
||||
required_version = ">=1.0"
|
||||
required_providers {
|
||||
azurerm = {
|
||||
source = "hashicorp/azurerm"
|
||||
version = ">= 3.56.0"
|
||||
}
|
||||
random = {
|
||||
source = "hashicorp/random"
|
||||
version = "~>3.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
provider "azurerm" {
|
||||
features {}
|
||||
}
|
26
quickstart/101-virtual-network-manager-create-mesh/readme.md
Normal file
26
quickstart/101-virtual-network-manager-create-mesh/readme.md
Normal file
@ -0,0 +1,26 @@
|
||||
# Azure resource group
|
||||
|
||||
This template deploys an Azure Virtual Network Manager instance with a connectivity configuration for a Mesh topology. It includes resources including virtual networks, subnets, and more.
|
||||
|
||||
## Terraform resource types
|
||||
|
||||
- [random_pet](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet)
|
||||
- [azurerm_resource_group](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group)
|
||||
- [azurerm_virtual_network](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_network)
|
||||
- [azurerm_subnet](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/subnet)
|
||||
- [azurerm_virtual_network_manager](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/network_manager)
|
||||
- [azurerm_network_manager_network_group](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/network_manager_network_group)
|
||||
- [azurerm_network_manager_static_member](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/network_manager_static_member)
|
||||
- [azurerm_network_manager_connectivity_configuration](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/network_manager_connectivity_configuration)
|
||||
- [azurerm_network_manager_deployment](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/network_manager_deployment)
|
||||
|
||||
## Variables
|
||||
|
||||
| **Name** | **Description** | **Default** |
|
||||
|---|---|---|
|
||||
| `resource_group_name_prefix` | Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription. | rg |
|
||||
| `resource_group_location` | Location of the resource group. | eastus |
|
||||
|
||||
## Example
|
||||
|
||||
To see how to run this example, see [Quickstart: Deploy a Virtual Network Manager in Azure using Terraform](https://learn.microsoft.com/azure/virtual-network-manager/create-virtual-network-manager-terraform).
|
@ -0,0 +1,11 @@
|
||||
variable "resource_group_location" {
|
||||
type = string
|
||||
default = "eastus"
|
||||
description = "Location of the resource group."
|
||||
}
|
||||
|
||||
variable "resource_group_name_prefix" {
|
||||
type = string
|
||||
description = "Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription."
|
||||
default = "rg"
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user