# 从 Fabric v3 (ecx) 迁移到 Fabric v4 (fabric) 2023年12月,Fabric v3 API 已弃用,并将达到 该服务将于 2024 年 6 月终止服务 (EOL)。`ecx` Terraform 资源构建于这些服务之上。 这些 API 也将于 2024 年 6 月停止服务。如果您正在使用这些 API,请参阅本指南。 这将帮助您迁移到已构建的 `fabric` Terraform 资源 使用 Fabric v4 API。 Fabric v3 资源包括以下数据源和资源: 数据来源: * `data "equinix_ecx_l2_sellerprofile"` * `data "equinix_ecx_l2_sellerprofiles"` * `data "equinix_ecx_port"` 资源: * `resource "equinix_ecx_l2_connection"` * `resource "equinix_ecx_l2_connection_accepter"` * `resource "equinix_ecx_l2_service_profile"` 它们正被拥有资源的家庭所取代 `equinix_fabric_` 前缀。 ## 将 ECX 映射到 Fabric[​](#将-ecx-映射到-fabric "直接链接至将 ECX 映射到 Fabric") 所有 ECX 资源均仅限于二层连接。这是由于…… Fabric v3 时代所存在的可能性是有限的。 Fabric v4 API 支持第 2 层和第 3 层连接。 这意味着 Fabric 资源更加健壮,因此不会出现问题。 并非完全一对一映射,而是 ECX 连接类型现在 Fabric 资源的一个子集。 ### 数据源映射:[​](#数据源映射 "直接链接至数据源映射:") * 请使用`data "equinix_fabric_service_profile"`代替`data "equinix_ecx_sellerprofile"` * 请使用`data "equinix_fabric_service_profiles"`代替`data "equinix_ecx_sellerprofiles"` * 请使用`data "equinix_fabric_port"`代替`data "equinix_ecx_port"` #### 模板更改内容如下:[​](#模板更改内容如下 "直接链接至模板更改内容如下:") 卖家简介: ``` data "equinix_ecx_l2_sellerprofile" "aws" { name = "AWS Direct Connect" } output "id" { value = data.equinix_ecx_l2_sellerprofile.aws.id } ``` 到 ``` data "equinix_fabric_service_profile" "aws" { uuid = "" } output "id" { value = data.equinix_fabric_service_profile.aws.id } ``` 或者,如果您仍然想按名称搜索,则可以使用 `equinix_fabric_service_profiles` 数据源。 ``` data "equinix_fabric_service_profiles" "aws" { filter { property = "/name" operator = "=" values = ["AWS Direct Connect"] } } output "id" { value = data.equinix_fabric_service_profile.aws.data.0.id } ``` 卖家简介: ``` data "equinix_ecx_l2_sellerprofiles" "aws" { organization_global_name = "AWS" } ``` 到 ``` data "equinix_fabric_service_profiles" "aws" { filter { property = "/name" operator = "=" values = ["AWS"] } } ``` 港口: ``` data "equinix_ecx_port" "tf-pri-dot1q" { name = "sit-001-CX-NY5-NL-Dot1q-BO-10G-PRI-JP-157" } output "id" { value = data.equinix_ecx_port.tf-pri-dot1q.id } ``` 到 ``` data "equinix_fabric_ports" "tf-pri-dot1q" { filters { name = "sit-001-CX-NY5-NL-Dot1q-BO-10G-PRI-JP-157" } } output "id" { value = data.equinix_fabric_ports.tf-pri-dot1q.0.id } ``` ### 资源映射[​](#资源映射 "直接链接至资源映射") * 请使用`resource "equinix_fabric_connection"`代替`resource "equinix_ecx_l2_connection"` * `resource "equinix_ecx_l2_connection_acceptor` 已弃用。 * 将您的 AWS Secret Key 和 AWS Access Key 添加到 `resource "equinix_fabric_connection"` 中的 `additional_info` 属性中,以便 AWS * 或者改用“AWS”提供程序中的等效资源`aws_dx_connection_confirmation`。 * 请使用`resource "equinix_fabric_service_profile"`代替`resource "equinix_ecx_l2_service_profile"` #### 模板更改[​](#模板更改 "直接链接至模板更改") L2 连接: ``` resource "equinix_ecx_l2_connection" "port-2-aws" { name = "tf-aws" profile_uuid = "" speed = 200 speed_unit = "MB" notifications = ["marry@equinix.com", "john@equinix.com"] port_uuid = "" vlan_stag = 777 vlan_ctag = 1000 seller_region = "us-west-1" seller_metro_code = "SV" authorization_key = "" } ``` 到 ``` resource "equinix_fabric_connection" "port2aws" { name = "tf-aws" type = "EVPL_VC" # L2 Connection notifications { type = "ALL" emails = ["marry@equinix.com", "john@equinix.com"] } bandwidth = 200 # Speed unit is defaulted to MB redundancy { priority= "PRIMARY" } order { purchase_order_number= "1-323929" } a_side { access_point { type= "COLO" port { uuid = "" } link_protocol { type = "QINQ" vlan_s_tag = "777" vlan_c_tag = "1000" } } } z_side { access_point { type = "SP" authentication_key = "" seller_region = "us-west-1" profile { type = "L2_PROFILE" uuid = "" } location { metro_code = "SV" } } } additional_info = [ { key = "accessKey", value = "" }, { key = "secretKey", value = "" } ] } ``` 服务简介: ``` resource "equinix_ecx_l2_serviceprofile" "private-profile" { name = "private-profile" description = "my private profile" connection_name_label = "Connection" bandwidth_threshold_notifications = ["John.Doe@example.com", "Marry.Doe@example.com"] profile_statuschange_notifications = ["John.Doe@example.com", "Marry.Doe@example.com"] vc_statuschange_notifications = ["John.Doe@example.com", "Marry.Doe@example.com"] private = true private_user_emails = ["John.Doe@example.com", "Marry.Doe@example.com"] features { allow_remote_connections = true test_profile = false } port { uuid = "a867f685-422f-22f7-6de0-320a5c00abdd" metro_code = "NY" } port { uuid = "a867f685-4231-2317-6de0-320a5c00abdd" metro_code = "NY" } speed_band { speed = 1000 speed_unit = "MB" } speed_band { speed = 500 speed_unit = "MB" } speed_band { speed = 100 speed_unit = "MB" } } ``` 到 ``` resource "equinix_fabric_service_profile" "private-profile" { name = "private-profile" description = "my private profile" type = "L2_PROFILE" # Need to specify to make it an Layer 2 Profile visibility = "PRIVATE" notifications = [ { emails = ["John.Doe@example.com", "Marry.Doe@example.com"] type = "BANDWIDTH_ALERT" }, { emails = ["John.Doe@example.com", "Marry.Doe@example.com"] type = "PROFILE_LIFECYCLE" }, { emails = ["John.Doe@example.com", "Marry.Doe@example.com"] type = "CONNECTION_APPROVAL" } ] allowed_emails = ["John.Doe@example.com", "Marry.Doe@example.com"] ports = [ { uuid = "c791f8cb-5cc9-cc90-8ce0-306a5c00a4ee" type = "XF_PORT" }, { uuid = "a867f685-4231-2317-6de0-320a5c00abdd" type = "XF_PORT" } ] access_point_type_configs { type = "COLO" allow_remote_connections = true connection_label = "Connection" supported_bandwidths = [ 100, 500, 1000 ] } } ``` ## 迁移 Terraform 状态[​](#迁移-terraform-状态 "直接链接至迁移 Terraform 状态") 一旦我们相应地更改了模板,我们就可以从 Terraform 状态中删除旧的 `equinix_ecx_` 资源,并通过它们的 UUID 将新的资源作为 `equinix_fabric_` 资源导入。 在 Terraform 状态和导入命令中,我们使用资源类型和名称,用点号分隔: ``` terraform state rm equinix_ecx_l2_connection.example terraform import equinix_fabric_connection.example ``` 之后,我们的模板应该与 Terraform 状态以及 Equinix Fabric 中的上游资源保持一致。我们可以通过运行 `terraform plan` 来验证迁移,它应该显示基础设施已更新。