-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add vhub-connection submodule including example (#73)
- Loading branch information
Showing
8 changed files
with
205 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
This example showcases virtual wan integration by establishing a vhub connection (as a submodule). | ||
|
||
## Types | ||
|
||
```hcl | ||
peering = object({ | ||
vnet_name = string | ||
resource_group = string | ||
name = string | ||
vnet_id = string | ||
internet_security_enabled = optional(bool) | ||
}) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
module "naming" { | ||
source = "cloudnationhq/naming/azure" | ||
version = "~> 0.1" | ||
|
||
suffix = ["demo", "dev"] | ||
} | ||
|
||
module "rg" { | ||
source = "cloudnationhq/rg/azure" | ||
version = "~> 2.0" | ||
|
||
groups = { | ||
demo = { | ||
name = module.naming.resource_group.name | ||
location = "westeurope" | ||
} | ||
} | ||
} | ||
|
||
module "network" { | ||
source = "cloudnationhq/vnet/azure" | ||
version = "~> 8.0" | ||
|
||
naming = local.naming | ||
|
||
vnet = { | ||
name = module.naming.virtual_network.name | ||
location = module.rg.groups.demo.location | ||
resource_group = module.rg.groups.demo.name | ||
address_space = ["10.19.0.0/16"] | ||
|
||
subnets = { | ||
sn1 = { | ||
network_security_group = {} | ||
address_prefixes = ["10.19.1.0/24"] | ||
} | ||
} | ||
} | ||
} | ||
|
||
module "rg_vwan" { | ||
source = "cloudnationhq/rg/azure" | ||
version = "~> 2.0" | ||
|
||
providers = { | ||
azurerm = azurerm.connectivity | ||
} | ||
|
||
|
||
groups = { | ||
vwan = { | ||
name = module.naming.resource_group.name | ||
location = "westeurope" | ||
} | ||
} | ||
} | ||
|
||
module "vwan" { | ||
source = "cloudnationhq/vwan/azure" | ||
version = "~> 3.0" | ||
|
||
providers = { | ||
azurerm = azurerm.connectivity | ||
} | ||
|
||
naming = local.naming | ||
|
||
vwan = { | ||
name = module.naming.virtual_wan.name | ||
resource_group = module.rg_vwan.groups.vwan.name | ||
location = module.rg_vwan.groups.vwan.location | ||
allow_branch_to_branch_traffic = true | ||
disable_vpn_encryption = false | ||
|
||
|
||
vhubs = { | ||
weu = { | ||
location = "westeurope" | ||
address_prefix = "10.0.0.0/23" | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
module "vhub-connection" { | ||
source = "cloudnationhq/vwan/azure//modules/vhub-connection" | ||
version = "~> 3.0" | ||
|
||
providers = { | ||
azurerm = azurerm.connectivity | ||
} | ||
|
||
virtual_hub = { | ||
vwan_name = module.vwan.vhubs.weu.name | ||
resource_group = module.vwan.vwan.resource_group_name | ||
name = module.naming.virtual_hub_connection.name | ||
vnet_id = module.network.vnet.id | ||
|
||
} | ||
|
||
depends_on = [module.vwan] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
locals { | ||
naming = { | ||
# lookup outputs to have consistent naming | ||
for type in local.naming_types : type => lookup(module.naming, type).name | ||
} | ||
|
||
naming_types = ["subnet", "network_security_group", "virtual_hub"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
terraform { | ||
required_version = "~> 1.0" | ||
|
||
required_providers { | ||
azurerm = { | ||
source = "hashicorp/azurerm" | ||
version = "~> 4.0" | ||
} | ||
} | ||
} | ||
|
||
provider "azurerm" { | ||
features {} | ||
} | ||
|
||
provider "azurerm" { | ||
alias = "connectivity" | ||
subscription_id = "00000000-0000-0000-0000-000000000000" | ||
|
||
features {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Vhub Connection | ||
|
||
This submodule illustrates how to manage vhub connections | ||
|
||
<!-- BEGIN_TF_DOCS --> | ||
## Requirements | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | ~> 1.0 | | ||
| <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) | ~> 4.0 | | ||
|
||
## Providers | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) | ~> 4.0 | | ||
|
||
## Resources | ||
|
||
| Name | Type | | ||
|------|------| | ||
| [azurerm_virtual_hub_connection.vcon](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_hub_connection) | resource | | ||
| [azurerm_virtual_hub.vhub](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/virtual_hub) | data source | | ||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| <a name="input_virtual_hub"></a> [virtual\_hub](#input\_virtual\_hub) | n/a | `any` | n/a | yes | | ||
|
||
## Outputs | ||
|
||
No outputs. | ||
<!-- END_TF_DOCS --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# virtual hub | ||
data "azurerm_virtual_hub" "vhub" { | ||
name = var.virtual_hub.name | ||
resource_group_name = var.virtual_hub.resource_group | ||
} | ||
|
||
# connection | ||
resource "azurerm_virtual_hub_connection" "vcon" { | ||
name = var.virtual_hub.connection | ||
virtual_hub_id = data.azurerm_virtual_hub.vhub.id | ||
remote_virtual_network_id = var.virtual_hub.vnet | ||
internet_security_enabled = try(var.virtual_hub.internet_security_enabled, true) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
terraform { | ||
required_version = "~> 1.0" | ||
|
||
required_providers { | ||
azurerm = { | ||
source = "hashicorp/azurerm" | ||
version = "~> 4.0" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
variable "virtual_hub" {} |