Skip to content

Commit

Permalink
feat: Support for suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
dploeger committed Aug 3, 2022
1 parent 060dedc commit 762d6d9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Type: `string`

### target\_vnet

Description: The Terraform resource of the target vnet
Description: ID and name of the target vnet to connect the VPN vnet to

Type:

Expand Down Expand Up @@ -148,6 +148,14 @@ Default:
]
```

### suffix

Description: Additional suffix for this vpn

Type: `string`

Default: `""`

### vnetgwsku

Description: SKU to use for the virtual network gateway
Expand Down
8 changes: 4 additions & 4 deletions connections.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ resource "azurerm_local_network_gateway" "local" {
address_space = var.local_nets
gateway_address = var.local_gateway_ip
location = var.location
name = "${lower(var.project)}${lower(var.stage)}netlocalgw"
name = "${lower(var.project)}${lower(var.stage)}netlocalgw${var.suffix}"
resource_group_name = var.resource_group
}

resource "azurerm_virtual_network_gateway_connection" "connection" {
location = var.location
name = "${lower(var.project)}${lower(var.stage)}netvnconnection"
name = "${lower(var.project)}${lower(var.stage)}netvnconnection${var.suffix}"
resource_group_name = var.resource_group
type = "IPsec"
virtual_network_gateway_id = azurerm_virtual_network_gateway.vnetgw.id
Expand All @@ -29,7 +29,7 @@ resource "azurerm_virtual_network_gateway_connection" "connection" {
}

resource "azurerm_virtual_network_peering" "peeringvpn" {
name = "${lower(var.project)}${lower(var.stage)}netpeering"
name = "${lower(var.project)}${lower(var.stage)}netpeering${var.suffix}"
remote_virtual_network_id = var.target_vnet.id
resource_group_name = var.resource_group
virtual_network_name = azurerm_virtual_network.vpnnet.name
Expand All @@ -40,7 +40,7 @@ resource "azurerm_virtual_network_peering" "peeringvpn" {
}

resource "azurerm_virtual_network_peering" "peeringvpnrev" {
name = "${lower(var.project)}${lower(var.stage)}netpeeringrev"
name = "${lower(var.project)}${lower(var.stage)}netpeeringrev${var.suffix}"
remote_virtual_network_id = azurerm_virtual_network.vpnnet.id
resource_group_name = var.resource_group
virtual_network_name = var.target_vnet.name
Expand Down
6 changes: 3 additions & 3 deletions gateway.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ resource "azurerm_virtual_network" "vpnnet" {
var.gatewaynet
]
location = var.location
name = "${lower(var.project)}${lower(var.stage)}netvnetworkvpn"
name = "${lower(var.project)}${lower(var.stage)}netvnetworkvpn${var.suffix}"
resource_group_name = var.resource_group
}

Expand All @@ -16,14 +16,14 @@ resource "azurerm_subnet" "gateway" {

resource "azurerm_public_ip" "publicip" {
location = var.location
name = "${lower(var.project)}${lower(var.stage)}ipvpn"
name = "${lower(var.project)}${lower(var.stage)}ipvpn${var.suffix}"
resource_group_name = var.resource_group
allocation_method = "Dynamic"
}

resource "azurerm_virtual_network_gateway" "vnetgw" {
location = var.location
name = "${lower(var.project)}${lower(var.stage)}netvirtualgw"
name = "${lower(var.project)}${lower(var.stage)}netvirtualgw${var.suffix}"
resource_group_name = var.resource_group
sku = var.vnetgwsku
type = "Vpn"
Expand Down
8 changes: 7 additions & 1 deletion vars.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ variable "stage" {
description = "Stage for this ressource group"
}

variable "suffix" {
type = string
default = ""
description = "Additional suffix for this vpn"
}

variable "gatewaynet" {
type = string
description = "IP network to use for the gateway"
Expand All @@ -34,7 +40,7 @@ variable "target_vnet" {
id = string
name = string
})
description = "The Terraform resource of the target vnet"
description = "ID and name of the target vnet to connect the VPN vnet to"
}

variable "local_nets" {
Expand Down

0 comments on commit 762d6d9

Please sign in to comment.