Skip to content

Commit

Permalink
Merge pull request #19 from vasubabu/vk_module_name
Browse files Browse the repository at this point in the history
Add provider equinix and module_name in Equinix Metal TF configs
  • Loading branch information
ctreatma authored May 12, 2023
2 parents cf8db04 + 1af1a11 commit 0816a4b
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 100 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ override.tf
override.tf.json
*_override.tf
*_override.tf.json
*.terraform.lock.hcl

# Include override files you do wish to add to version control using negated pattern
#
Expand All @@ -28,4 +29,4 @@ override.tf.json
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*
terraform.tfvars
vyos.conf
vyos.conf
76 changes: 0 additions & 76 deletions .terraform.lock.hcl

This file was deleted.

34 changes: 17 additions & 17 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
provider "metal" {
provider "equinix" {
auth_token = var.auth_token
}

resource "metal_vlan" "private_vlan" {
resource "equinix_metal_vlan" "private_vlan" {
metro = var.metro
project_id = var.project_id
description = "Private Network"
Expand All @@ -24,7 +24,7 @@ resource "random_string" "ipsec_psk" {
special = false
}

resource "metal_device" "router" {
resource "equinix_metal_device" "router" {
hostname = var.hostname
plan = var.plan
metro = var.metro
Expand All @@ -35,16 +35,16 @@ resource "metal_device" "router" {
always_pxe = var.always_pxe
}

resource "metal_device_network_type" "convert-networking" {
device_id = metal_device.router.id
resource "equinix_metal_device_network_type" "convert-networking" {
device_id = equinix_metal_device.router.id
type = "hybrid"
}

resource "metal_port_vlan_attachment" "router_vlan_attach" {
depends_on = [metal_device_network_type.convert-networking]
device_id = metal_device.router.id
resource "equinix_metal_port_vlan_attachment" "router_vlan_attach" {
depends_on = [equinix_metal_device_network_type.convert-networking]
device_id = equinix_metal_device.router.id
port_name = "eth1"
vlan_vnid = metal_vlan.private_vlan.vxlan
vlan_vnid = equinix_metal_vlan.private_vlan.vxlan
}

data "template_file" "vyos_config" {
Expand All @@ -66,14 +66,14 @@ data "template_file" "vyos_config" {
private_net_gateway_ip = cidrhost(var.private_net_cidr, 2)
public_dns_1_ip = var.public_dns_1_ip
public_dns_2_ip = var.public_dns_2_ip
router_ipv6_gateway_ip = metal_device.router.network.1.gateway
router_ipv6_ip_cidr = format("%s/%s", metal_device.router.network.1.address, metal_device.router.network.1.cidr)
router_private_cidr = format("%s/%s", cidrhost(format("%s/%s", metal_device.router.network.2.address, metal_device.router.network.2.cidr), 0), metal_device.router.network.2.cidr)
router_private_gateway_ip = metal_device.router.network.2.gateway
router_private_ip_cidr = format("%s/%s", metal_device.router.network.2.address, metal_device.router.network.2.cidr)
router_public_gateway_ip = metal_device.router.network.0.gateway
router_public_ip_cidr = format("%s/%s", metal_device.router.network.0.address, metal_device.router.network.0.cidr)
router_public_ip = metal_device.router.network.0.address
router_ipv6_gateway_ip = equinix_metal_device.router.network.1.gateway
router_ipv6_ip_cidr = format("%s/%s", equinix_metal_device.router.network.1.address, equinix_metal_device.router.network.1.cidr)
router_private_cidr = format("%s/%s", cidrhost(format("%s/%s", equinix_metal_device.router.network.2.address, equinix_metal_device.router.network.2.cidr), 0), equinix_metal_device.router.network.2.cidr)
router_private_gateway_ip = equinix_metal_device.router.network.2.gateway
router_private_ip_cidr = format("%s/%s", equinix_metal_device.router.network.2.address, equinix_metal_device.router.network.2.cidr)
router_public_gateway_ip = equinix_metal_device.router.network.0.gateway
router_public_ip_cidr = format("%s/%s", equinix_metal_device.router.network.0.address, equinix_metal_device.router.network.0.cidr)
router_public_ip = equinix_metal_device.router.network.0.address
}
}

Expand Down
6 changes: 3 additions & 3 deletions outputs.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
output "SSH" {
value = "ssh vyos@${metal_device.router.network.0.address}"
value = "ssh vyos@${equinix_metal_device.router.network.0.address}"
description = "Command to SSH into the VyOS Router"
}

output "Out_of_Band_Console" {
value = "ssh ${metal_device.router.id}@sos.${lower(metal_device.router.deployed_facility)}.platformequinix.com"
value = "ssh ${equinix_metal_device.router.id}@sos.${lower(equinix_metal_device.router.metro)}.platformequinix.com"
description = "Command to SSH into the Serial over Lan Console of the VyOS Router"
}

Expand All @@ -24,7 +24,7 @@ output "IPSec_Pre_Shared_Key" {
}

output "IPSec_Public_IP" {
value = metal_device.router.network.0.address
value = equinix_metal_device.router.network.0.address
description = "Public IP for IPSec VPN"
}

Expand Down
9 changes: 6 additions & 3 deletions versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ terraform {
required_version = ">= 1.0"

required_providers {
metal = {
source = "equinix/metal"
version = ">= 3.2.0"
equinix = {
source = "equinix/equinix"
version = "~> 1.14"
}
}
provider_meta "equinix" {
module_name = "equinix-vyos-router"
}
}

0 comments on commit 0816a4b

Please sign in to comment.