跳到主要内容

通过 Terraform 连接到 Equinix Fabric 云平台

->注意: 有关更多详细信息,请参阅Equinix Fabric文档。

Equinix Fabric™是一种软件定义的互连服务,允许任何企业

通过全球互连网络将其自己的分布式基础设施连接到Platform Equinix®上任何其他公司的基础设施或服务提供商。本指南主要介绍 如何建立与云服务提供商的互连, 以及如何利用 Equinix Fabric连接地形模块, 以获取更多详细信息和其他选项, 请参阅下方参考部分。

入门指南 - 实现互联​

无论您是设置多云还是混合云架构,您都 需要定义的主要资源是Equinix _Fabric_CONNECTION,该资源 将允许Equinix代表您启用与指定云提供商的互连。 但是,Equinix和您的云 提供商都必须配置其他必需资源,才能确保互连正常运行。下面我们以 Azure ExpressRoute为例介绍了这些常规步骤。

**1.**在云提供商中启用互连-这通常意味着创建云路由器 和互连资产(例如Google云路由器和VLAN附件,Oracle FastConnect等 )。在此示例中,需要一个azurerm_express_route_circuity 资源,其中Equinix必须指定服务提供商(即)才能生成 有效的配对密钥。

provider "azurerm" {
features {}
}

resource "azurerm_express_route_circuit" "example" {
name = "my-circuit"
resource_group_name = "my-resource-group"
location = "Germany West Central"
service_provider_name = "Equinix"
peering_location = "Frankfurt"
bandwidth_in_mbps = 100
sku {
tier = "Premium"
family = "UnlimitedData"
}
allow_classic_operations = false
}

**2.**请求Equinix Fabric连接-从 Equinix Fabric端口/ Network Edge设备/ Equinix服务令牌/ Equinix Fabric Cloud Router 连接到云虚拟互连资产。

在此示例中,我们将从云路由器 资源建立连接)。请注意,的值authorization_key必须为azurerm_express_route_circuit.example.service_key (即上面提到的配对密钥)。

provider "equinix" {}

data "equinix_fabric_service_profile" "azure" {
name = "Azure ExpressRoute"
filter {
property = "/name"
operator = "="
values = ["Azure ExpressRoute"]
}
}

resource "equinix_fabric_connection" "fcr2azure"{
name = "ConnectionName"
type = "IP_VC"
notifications{
type = "ALL"
emails = ["example@equinix.com","test1@equinix.com"]
}
bandwidth = azurerm_express_route_circuit.example.bandwidth_in_mbps
order {
purchase_order_number = "1-323292"
}
a_side {
access_point {
type = "CLOUD_ROUTER"
router {
uuid = "<cloud_router_uuid>"
}
}
}
z_side {
access_point {
type = "SP"
authentication_key = azurerm_express_route_circuit.example.service_key
peering_type = "PRIVATE"
profile {
type = "L2_PROFILE"
uuid = data.equinix_fabric_service_profile.azure.data.0.id
}
location {
metro_code = "SV"
}
}
}
}

**3.**在云端配置BGP (称为电路对等互连或虚拟接口),所有云 提供商都提供了添加BGP对等方的资源。需要 提供的一些常见详细信息包括:

  • 客户路由器 IP(云提供商应将数据发送到的目标路由器对等 IP) 交通)。
  • 云路由器 IP(用于向云端发送流量的虚拟路由器对等 IP)。
  • 客户 BGP ASN(您的本地对等体的边界网关协议自治系统编号) 路由器)。

在此示例中,我们需要创建,azurerm_express_route_circuit_peering其中 必须定义主要和次要连接的详细信息。

resource "azurerm_express_route_circuit_peering" "example" {
express_route_circuit_name = azurerm_express_route_circuit.example.name
resource_group_name = "my-resource-group"

peering_type = "AzurePrivatePeering"
peer_asn = 100
primary_peer_address_prefix = "123.0.0.0/30"
secondary_peer_address_prefix = "123.0.0.4/30"
vlan_id = 300
bandwidth_in_mpbs = 50
}

**4.**在Equinix端配置BGP -最后,客户端必须使用相同的 信息进行配置。在本示例中,连接的源是Fabric Cloud Router,您可以 利用该equinix_fabric_routing_protocol资源在云 路由器中配置BGP对等互连。

resource "equinix_fabric_routing_protocol" "direct"{
connection_uuid = equinix_fabric_connection.fcr2azure.id
type = "DIRECT"
name = "direct_rp"
direct_ipv4 {
equinix_iface_ip = "190.1.1.1/30"
}
direct_ipv6{
equinix_iface_ip = "190::1:1/126"
}
}

resource "equinix_fabric_routing_protocol" "bgp" {
depends_on = [
equinix_fabric_routing_protocol.direct
]
connection_uuid = equinix_fabric_connection.fcr2azure.id
type = "BGP"
name = "bgp_rp"
bgp_ipv4 {
customer_peer_ip = "190.1.1.2"
enabled = true
}
bgp_ipv6 {
customer_peer_ip = "190::1:2"
enabled = true
}
customer_asn = 4532
}

Terraform 模块——最简单的方法​

Equinix端的配置看似类似,但 完成配置所需的所有资源都将取决于每个云提供商。这要求您事先掌握 如何在每个平台上配置互连的知识。您也可以利用 Equinix Fabric Terraform模块。

terraform模块容纳在配置中一起使用的多个资源。 使用Equinix Fabric Terraform云路由器2 Azure连接示例模块 和Equinix Fabric Terraform路由协议模块 ,您只需定义三个资源即可配置上述所有内容。

以下代码足以完全替换上面的示例:

# main.tf
provider "equinix" {}

provider "azurerm" {}

module "equinix-fabric-connection-azure" {
source = "equinix/fabric/equinix//examples/cloud-router-2-azure-connection"


# Connection Details
connection_name = "fcr_2_azure"
connection_type = "IP_VC"
notifications_type = "ALL"
notifications_emails = ["example@equinix.com","test1@equinix.com"]
purchase_order_number = "1-323292"
bandwidth = 50
aside_ap_type = "CLOUD_ROUTER"
aside_fcr_uuid = "<Primary Fabric Cloud router UUID>"
zside_ap_type = "SP"
zside_ap_profile_type = "L2_PROFILE"
zside_location = "SV"
zside_peering_type = "PRIVATE"
zside_fabric_sp_name = "Azure ExpressRoute"

# Azure details
azure_client_id = "<Azure Client Id>"
azure_client_secret = "<Azure Client Secret Value>"
azure_tenant_id = "<Azure Tenant Id>"
azure_subscription_id = "<Azure Subscription Id>"
azure_resource_name = "my-resource-group"
azure_location = "West US 2"
azure_service_key_name = "Test_Azure_Key"
azure_service_provider_name = "<Service Provider Name>"
azure_peering_location = "Silicon Valley Test"
azure_tier = "Standard"
azure_family = "UnlimitedData"
azure_environment = "PROD"
}

resource "azurerm_express_route_circuit_peering" "example" {
express_route_circuit_name = module.equinix-fabric-connection-azure.azurerm_express_route_circuit_name
resource_group_name = "my-resource-group"

peering_type = "AzurePrivatePeering"
peer_asn = 100
primary_peer_address_prefix = "123.0.0.0/30"
secondary_peer_address_prefix = "123.0.0.4/30"
vlan_id = 300
bandwidth_in_mpbs = 50
}

module "routing_protocols" {
source = "equinix/fabric/equinix//modules/routing-protocols"

connection_uuid = module.equinix-fabric-connection-azure.module_output

# Direct RP Details
direct_rp_name = "direct_rp"
direct_equinix_ipv4_ip = "190.1.1.1/30"
direct_equinix_ipv6_ip = "190::1:1/126"

# BGP RP Details
bgp_rp_name = "bgp_rp"
bgp_customer_asn = 4532
bgp_customer_peer_ipv4 = "190.1.1.2"
bgp_enabled_ipv4 = true
bgp_customer_peer_ipv6 = var.bgp_customer_peer_ipv6
bgp_enabled_ipv6 = "190::1:2"
}

您可以在GitHub存储库中打开 请求单。

参考资料​

  • 请参阅API操作指南以了解进一步信息 详细说明各云服务提供商的要求。
  • 查看可用提供商 在 Equinix® 平台上查找您所需的服务提供商。
这个页面对您有帮助吗?