From ad5d499711243ebde6b5ca1d1537e09c34693ca3 Mon Sep 17 00:00:00 2001 From: Srushti Patel <137830748+srushti-patl@users.noreply.github.com> Date: Wed, 17 Jan 2024 14:41:47 -0800 Subject: [PATCH] CXF-83184 Adding Virtual Device & Adding VD 2 Azure Example (#23) * CXF-83184 Adding Virtual Device & Adding VD 2 Azure Example * CXF-83184 Updating changes for VD2Azure example * CXF-83184 fixing change for virtual interface type * CXF-83184 fixing style for versions.tf file --- .../README.md | 0 .../virtual-device-2-azure-connection/main.tf | 98 ++++++++ .../outputs.tf | 6 + .../terraform.tfvars.example | 60 +++++ .../variables.tf | 213 ++++++++++++++++++ .../versions.tf | 13 ++ modules/virtual-device-connection/README.md | 0 modules/virtual-device-connection/main.tf | 177 +++++++++++++++ modules/virtual-device-connection/outputs.tf | 6 + .../virtual-device-connection/variables.tf | 116 ++++++++++ modules/virtual-device-connection/versions.tf | 9 + 11 files changed, 698 insertions(+) create mode 100644 examples/virtual-device-2-azure-connection/README.md create mode 100644 examples/virtual-device-2-azure-connection/main.tf create mode 100644 examples/virtual-device-2-azure-connection/outputs.tf create mode 100644 examples/virtual-device-2-azure-connection/terraform.tfvars.example create mode 100644 examples/virtual-device-2-azure-connection/variables.tf create mode 100644 examples/virtual-device-2-azure-connection/versions.tf create mode 100644 modules/virtual-device-connection/README.md create mode 100644 modules/virtual-device-connection/main.tf create mode 100644 modules/virtual-device-connection/outputs.tf create mode 100644 modules/virtual-device-connection/variables.tf create mode 100644 modules/virtual-device-connection/versions.tf diff --git a/examples/virtual-device-2-azure-connection/README.md b/examples/virtual-device-2-azure-connection/README.md new file mode 100644 index 00000000..e69de29b diff --git a/examples/virtual-device-2-azure-connection/main.tf b/examples/virtual-device-2-azure-connection/main.tf new file mode 100644 index 00000000..116dd26f --- /dev/null +++ b/examples/virtual-device-2-azure-connection/main.tf @@ -0,0 +1,98 @@ +provider "equinix" { + client_id = var.equinix_client_id + client_secret = var.equinix_client_secret + endpoint = var.equinix_endpoint +} +provider "azurerm" { + features {} + client_id = var.azure_client_id + client_secret = var.azure_client_secret + tenant_id = var.azure_tenant_id + subscription_id = var.azure_subscription_id + + skip_provider_registration = true +} + +#Network Edge Module +resource "equinix_network_acl_template" "wan-acl-template" { + name = var.template_name + description = var.template_description + inbound_rule { + subnet = var.template_subnet + protocol = var.template_protocol + src_port = var.template_src_port + dst_port = var.template_dst_port + } +} + +resource "equinix_network_device" "C8KV-SV" { + name = var.ne_name + metro_code = var.ne_metro_code + type_code = var.ne_type_code + self_managed = true + byol = true + package_code = var.ne_package_code + notifications = var.ne_notifications + hostname = var.ne_hostname + account_number = var.ne_account_number + version = var.ne_version + core_count = var.ne_core_count + term_length = var.ne_term_length + + ssh_key { + username = var.ne_ssh_key_username + key_name = var.ne_ssh_key_name + } + acl_template_id = equinix_network_acl_template.wan-acl-template.id +} + +resource "equinix_network_ssh_key" "suneeth-ssh" { + name = var.network_public_key_name + public_key = var.network_public_key +} + +#Azure Provider +resource "azurerm_resource_group" "port2azure" { + name = var.azure_resource_name + location = var.azure_location +} +resource "azurerm_express_route_circuit" "port2azure" { + name = var.azure_service_key_name + resource_group_name = azurerm_resource_group.port2azure.name + location = azurerm_resource_group.port2azure.location + service_provider_name = var.azure_service_provider_name + peering_location = var.azure_peering_location + bandwidth_in_mbps = var.bandwidth + sku { + tier = var.azure_tier + family = var.azure_family + } + allow_classic_operations = false + tags = { + environment = var.azure_environment + } +} + +#Connection +module "create_virtual_device_2_azure_connection" { + source = "../../modules/virtual-device-connection" + + connection_name = var.connection_name + connection_type = var.connection_type + notifications_type = var.notifications_type + notifications_emails = var.notifications_emails + bandwidth = azurerm_express_route_circuit.port2azure.bandwidth_in_mbps + purchase_order_number = var.purchase_order_number + + # A-side + aside_vd_type = var.aside_vd_type + aside_vd_uuid = equinix_network_device.C8KV-SV.id + + # Z-side + zside_ap_type = var.zside_ap_type + zside_peering_type = var.zside_peering_type + zside_ap_authentication_key = azurerm_express_route_circuit.port2azure.service_key + zside_ap_profile_type = var.zside_ap_profile_type + zside_location = var.zside_location + zside_sp_name = var.zside_sp_name +} diff --git a/examples/virtual-device-2-azure-connection/outputs.tf b/examples/virtual-device-2-azure-connection/outputs.tf new file mode 100644 index 00000000..fbb76c08 --- /dev/null +++ b/examples/virtual-device-2-azure-connection/outputs.tf @@ -0,0 +1,6 @@ +output "virtual_device_id" { + value = equinix_network_device.C8KV-SV.id +} +output "azure_connection_id" { + value = module.create_virtual_device_2_azure_connection.primary_connection_id +} diff --git a/examples/virtual-device-2-azure-connection/terraform.tfvars.example b/examples/virtual-device-2-azure-connection/terraform.tfvars.example new file mode 100644 index 00000000..0a68c861 --- /dev/null +++ b/examples/virtual-device-2-azure-connection/terraform.tfvars.example @@ -0,0 +1,60 @@ +equinix_client_id = "MyEquinixClientId" +equinix_client_secret = "MyEquinixSecret" +equinix_endpoint = "endpointURL" + +#NE Acl Template +template_name = "test-wan-acl-template" +template_description = "WAN ACL template" +template_subnet = "172.16.25.0/24" +template_protocol = "TCP" +template_src_port = "any" +template_dst_port = "22" + +#Network Edge +ne_name = "Terra_Test_router" +ne_metro_code = "SV" +ne_type_code = "C8000V" +ne_package_code = "network-essentials" +ne_notifications = ["test@eq.com"] +ne_hostname = "C8KV" +ne_account_number = "182390403" +ne_version = "17.11.01a" +ne_core_count = 2 +ne_term_length = 1 + +ne_ssh_key_username = "" +ne_ssh_key_name = "