From d7dde085f5da5bd84f8f36437f55947e9b8ef083 Mon Sep 17 00:00:00 2001 From: Manu Bhat Date: Tue, 19 Sep 2023 14:45:20 -0700 Subject: [PATCH] feat: Add Azure and Oracle Fabric Cloud Router connections (#382) Adds the below Fabric cloud router(FCR) connections types and related tests and examples - FCR to Azure cloud - FCR to Oracle cloud --------- Co-authored-by: srushti-patl Co-authored-by: Tim Hogarty --- docs/resources/equinix_fabric_connection.md | 3 +- equinix/fabric_connection_schema.go | 1 + equinix/fabric_mapping_helper.go | 6 +- .../single-connection/README.md | 47 ++++++++ .../single-connection/main.tf | 56 +++++++++ .../single-connection/terraform.tf | 7 ++ .../single-connection/terraform.tfvars | 19 +++ .../single-connection/variables.tf | 19 +++ .../two-connections/README.md | 50 ++++++++ .../cloudRouter2azure/two-connections/main.tf | 109 ++++++++++++++++++ .../two-connections/terraform.tf | 7 ++ .../two-connections/terraform.tfvars | 20 ++++ .../two-connections/variables.tf | 20 ++++ .../cloudRouter2oracle/README.md | 47 ++++++++ .../cloudRouter2oracle/main.tf | 54 +++++++++ .../cloudRouter2oracle/terraform.tf | 7 ++ .../cloudRouter2oracle/terraform.tfvars | 18 +++ .../cloudRouter2oracle/variables.tf | 18 +++ go.mod | 2 +- ...=> connection_e2e_cloudRouter2aws_test.go} | 0 ...loudRouter2azure_single_connection_test.go | 21 ++++ ..._cloudRouter2azure_two_connections_test.go | 23 ++++ ...=> connection_e2e_cloudRouter2gcp_test.go} | 0 .../connection_e2e_cloudRouter2oracle_test.go | 21 ++++ ...> connection_e2e_cloudRouter2port_test.go} | 0 ....go => connection_e2e_cloudRouter_test.go} | 0 26 files changed, 571 insertions(+), 4 deletions(-) create mode 100644 examples/fabric/v4/cloudRouterConnectivity/cloudRouter2azure/single-connection/README.md create mode 100644 examples/fabric/v4/cloudRouterConnectivity/cloudRouter2azure/single-connection/main.tf create mode 100644 examples/fabric/v4/cloudRouterConnectivity/cloudRouter2azure/single-connection/terraform.tf create mode 100644 examples/fabric/v4/cloudRouterConnectivity/cloudRouter2azure/single-connection/terraform.tfvars create mode 100644 examples/fabric/v4/cloudRouterConnectivity/cloudRouter2azure/single-connection/variables.tf create mode 100644 examples/fabric/v4/cloudRouterConnectivity/cloudRouter2azure/two-connections/README.md create mode 100644 examples/fabric/v4/cloudRouterConnectivity/cloudRouter2azure/two-connections/main.tf create mode 100644 examples/fabric/v4/cloudRouterConnectivity/cloudRouter2azure/two-connections/terraform.tf create mode 100644 examples/fabric/v4/cloudRouterConnectivity/cloudRouter2azure/two-connections/terraform.tfvars create mode 100644 examples/fabric/v4/cloudRouterConnectivity/cloudRouter2azure/two-connections/variables.tf create mode 100644 examples/fabric/v4/cloudRouterConnectivity/cloudRouter2oracle/README.md create mode 100644 examples/fabric/v4/cloudRouterConnectivity/cloudRouter2oracle/main.tf create mode 100644 examples/fabric/v4/cloudRouterConnectivity/cloudRouter2oracle/terraform.tf create mode 100644 examples/fabric/v4/cloudRouterConnectivity/cloudRouter2oracle/terraform.tfvars create mode 100644 examples/fabric/v4/cloudRouterConnectivity/cloudRouter2oracle/variables.tf rename tests/{connection_e2e_fcr2aws_test.go => connection_e2e_cloudRouter2aws_test.go} (100%) create mode 100644 tests/connection_e2e_cloudRouter2azure_single_connection_test.go create mode 100644 tests/connection_e2e_cloudRouter2azure_two_connections_test.go rename tests/{connection_e2e_fcr2gcp_test.go => connection_e2e_cloudRouter2gcp_test.go} (100%) create mode 100644 tests/connection_e2e_cloudRouter2oracle_test.go rename tests/{connection_e2e_fcr2port_test.go => connection_e2e_cloudRouter2port_test.go} (100%) rename tests/{connection_e2e_fcr_test.go => connection_e2e_cloudRouter_test.go} (100%) diff --git a/docs/resources/equinix_fabric_connection.md b/docs/resources/equinix_fabric_connection.md index cef12deec..edf9fc885 100644 --- a/docs/resources/equinix_fabric_connection.md +++ b/docs/resources/equinix_fabric_connection.md @@ -142,9 +142,10 @@ Read-Only: ### Nested Schema for `a_side.access_point.port.redundancy` -Read-Only: +Optional: - `priority` (String) +- `group` (String) diff --git a/equinix/fabric_connection_schema.go b/equinix/fabric_connection_schema.go index 80f57700e..f6a2eedfb 100755 --- a/equinix/fabric_connection_schema.go +++ b/equinix/fabric_connection_schema.go @@ -453,6 +453,7 @@ func createRedundancySch() map[string]*schema.Schema { "group": { Type: schema.TypeString, Computed: true, + Optional: true, Description: "Redundancy group identifier", }, "priority": { diff --git a/equinix/fabric_mapping_helper.go b/equinix/fabric_mapping_helper.go index b320b3dab..a029cc439 100644 --- a/equinix/fabric_mapping_helper.go +++ b/equinix/fabric_mapping_helper.go @@ -156,9 +156,11 @@ func redundancyToFabric(schemaRedundancy []interface{}) v4.ConnectionRedundancy red := v4.ConnectionRedundancy{} for _, r := range schemaRedundancy { redundancyMap := r.(map[string]interface{}) - priorityCont := v4.ConnectionPriority(redundancyMap["priority"].(string)) + connectionPriority := v4.ConnectionPriority(redundancyMap["priority"].(string)) + redundancyGroup := redundancyMap["group"].(string) red = v4.ConnectionRedundancy{ - Priority: &priorityCont, + Priority: &connectionPriority, + Group: redundancyGroup, } } return red diff --git a/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2azure/single-connection/README.md b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2azure/single-connection/README.md new file mode 100644 index 000000000..de7cc7d10 --- /dev/null +++ b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2azure/single-connection/README.md @@ -0,0 +1,47 @@ +# ECX Fabric Layer2 Single Connection from fabric cloud router to Azure + +This example shows how create single connection from Fabric Cloud Router to Azure, on ECX Fabric ports. + +## Adjust variables +At minimum, you must set below variables in `terraform.tfvars` file: + +* `equinix_client_id` - Equinix client ID (consumer key), obtained after + registering app in the developer platform +* `equinix_client_secret` - Equinix client secret ID (consumer secret), + obtained same way as above + +`fcr_uuid` - UUID of ECX Fabric Cloud Router on a-side +`connection_name` - the name of the connection +`connection_type` - connection type, please refer schema +`notifications_type` - notification type +`notifications_emails` - List of emails +`bandwidth` - bandwidth in MBs +`redundancy` - Port redundancy +`aside_ap_type` - Fabric Cloud Router type +`zside_ap_type` - Z side access point type +`zside_ap_authentication_key` - Azure authorization key, service key generated from Azure Portal +`zside_ap_profile_type` - Service profile type +`fabric_sp_name` - Service profile name, fetched based on Service Profile get call using Service Profile search schema +`zside_location` - Seller location +`seller_region` - Seller region code + +## Azure login + +Log in to Azure portal use account that has permission to create necessary resources. + +## Initialize +- First step is to initialize the terraform directory/resource we are going to work on. + In the given example, the folder to perform CRUD operations on a fcr2port connection can be found at examples/fcr2port/. + +- Change directory into - `CD cloudRouter2azure/single-connection` +- Initialize Terraform plugins - `terraform init` + +## Fabric Cloud Router to port connection : Create, Read, Update and Delete(CRUD) operations +Note: `–auto-approve` command does not prompt the user for validating the applying config. Remove it to get a prompt to confirm the operation. + +| Operation | Command | Description | +|:----------|:---------------------------------:|------------------------------------------------------------------------:| +| CREATE | `terraform apply –auto-approve` | Creates a fcr2azure connection resource | +| READ | `terraform show` | Reads/Shows the current state of the fcr2azure connection resource | +| UPDATE | `terraform apply -refresh` | Updates the fcr2azure with values provided in the terraform.tfvars file | +| DELETE | `terraform destroy –auto-approve` | Deletes the created fcr2azure connection resource | diff --git a/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2azure/single-connection/main.tf b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2azure/single-connection/main.tf new file mode 100644 index 000000000..b319a1058 --- /dev/null +++ b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2azure/single-connection/main.tf @@ -0,0 +1,56 @@ +provider "equinix" { + client_id = var.equinix_client_id + client_secret = var.equinix_client_secret +} + +data "equinix_fabric_service_profiles" "azure"{ + filter{ + property = "/name" + operator = "=" + values = [var.fabric_sp_name] + } +} + +resource "equinix_fabric_connection" "fcr2azure"{ + name = var.connection_name + type = var.connection_type + + notifications { + type = var.notifications_type + emails = var.notifications_emails + } + + bandwidth = var.bandwidth + redundancy {priority= var.redundancy} + order { + purchase_order_number = var.purchase_order_number + } + a_side { + access_point { + type = var.aside_ap_type + router { + uuid = var.fcr_uuid + } + } + } + + z_side { + access_point { + type = var.zside_ap_type + authentication_key = var.zside_ap_authentication_key + peering_type = var.peering_type + profile { + type = var.zside_ap_profile_type + uuid = var.zside_ap_profile_uuid + } + location { + metro_code = var.zside_location + } + } + } +} + +output "connection_result" { + value = equinix_fabric_connection.fcr2azure.id +} + diff --git a/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2azure/single-connection/terraform.tf b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2azure/single-connection/terraform.tf new file mode 100644 index 000000000..fd41df1c0 --- /dev/null +++ b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2azure/single-connection/terraform.tf @@ -0,0 +1,7 @@ +terraform { + required_providers { + equinix = { + source = "equinix/equinix" + } + } +} diff --git a/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2azure/single-connection/terraform.tfvars b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2azure/single-connection/terraform.tfvars new file mode 100644 index 000000000..882010ab3 --- /dev/null +++ b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2azure/single-connection/terraform.tfvars @@ -0,0 +1,19 @@ +equinix_client_id = "Equinix_Client_Id" +equinix_client_secret = "Equinix_Client_Secret" +connection_name = "fcr_2_azure" +connection_type = "IP_VC" +notifications_type = "ALL" +notifications_emails = ["example@equinix.com"] +bandwidth = 50 +redundancy = "PRIMARY" +redundancy_group_uuid = "" #OPTIONAL +purchase_order_number = "1-323292" +peering_type = "PRIVATE" +aside_ap_type = "CLOUD_ROUTER" +fcr_uuid = "Cloud Router UUID" +zside_ap_type = "SP" +zside_ap_authentication_key = "Azure Service Key" +zside_ap_profile_type = "L2_PROFILE" +zside_ap_profile_uuid = "" +zside_location = "SV" +fabric_sp_name = "Azure Express Route" diff --git a/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2azure/single-connection/variables.tf b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2azure/single-connection/variables.tf new file mode 100644 index 000000000..20be3beb5 --- /dev/null +++ b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2azure/single-connection/variables.tf @@ -0,0 +1,19 @@ +variable "equinix_client_id" {} +variable "equinix_client_secret" {} +variable "connection_name" {} +variable "connection_type" {} +variable "notifications_type" {} +variable "notifications_emails" {} +variable "bandwidth" {} +variable "redundancy" {} +variable "redundancy_group_uuid" {} +variable "purchase_order_number" {} +variable "peering_type" {} +variable "aside_ap_type" {} +variable "fcr_uuid" {} +variable "zside_ap_type" {} +variable "zside_ap_authentication_key" {} +variable "zside_ap_profile_type" {} +variable "zside_ap_profile_uuid" {} +variable "zside_location" {} +variable "fabric_sp_name" {} diff --git a/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2azure/two-connections/README.md b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2azure/two-connections/README.md new file mode 100644 index 000000000..423b27d38 --- /dev/null +++ b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2azure/two-connections/README.md @@ -0,0 +1,50 @@ +# ECX Fabric Layer2 Two Redundant Connections from fabric cloud router to Azure + +This example shows how create two redundant connections from Fabric Cloud Router to Azure, on ECX Fabric ports. + +## Adjust variables +At minimum, you must set below variables in `terraform.tfvars` file: + +* `equinix_client_id` - Equinix client ID (consumer key), obtained after + registering app in the developer platform +* `equinix_client_secret` - Equinix client secret ID (consumer secret), + obtained same way as above + +`pri_connection_name` - the name of the primary connection +`sec_connection_name` - the name of the secondary connection +`connection_type` - connection type, please refer schema +`notifications_type` - notification type +`notifications_emails` - List of emails +`bandwidth` - bandwidth in MBs +`aside_ap_type` - Fabric Cloud Router type +`peering_type` - Peering type for the ECX Fabric Cloud Router on the a-side; typically PRIVATE +**Note: You can use one Cloud Router for both connections if you would like** +`cloud_router_primary_uuid` - UUID of ECX Fabric Cloud Router on a-side +`cloud_router_secondary_uuid` - UUID of ECX Fabric Cloud Router on a-side for secondary connection +`zside_ap_type` - Z side access point type +`zside_ap_authentication_key` - Azure authorization key, service key generated from Azure Portal +`zside_ap_profile_type` - Service profile type +`zside_ap_profile_uuid` - Service profile UUID +`zside_location` - Seller location +`fabric_sp_name` - Service profile name, fetched based on Service Profile get call using Service Profile search schema + +## Azure login + +Log in to Azure portal use account that has permission to create necessary resources. + +## Initialize +- First step is to initialize the terraform directory/resource we are going to work on. + In the given example, the folder to perform CRUD operations on a fcr2port connection can be found at examples/fcr2port/. + +- Change directory into - `CD cloudRouter2azure/two-connections` +- Initialize Terraform plugins - `terraform init` + +## Fabric Cloud Router to port connection : Create, Read, Update and Delete(CRUD) operations +Note: `–auto-approve` command does not prompt the user for validating the applying config. Remove it to get a prompt to confirm the operation. + +| Operation | Command | Description | +|:----------|:---------------------------------:|------------------------------------------------------------------------:| +| CREATE | `terraform apply –auto-approve` | Creates a fcr2azure redundant connection resources | +| READ | `terraform show` | Reads/Shows the current state of the fcr2azure connection resources | +| UPDATE | `terraform apply -refresh` | Updates the fcr2azure with values provided in the terraform.tfvars file | +| DELETE | `terraform destroy –auto-approve` | Deletes the created fcr2azure connection resources | \ No newline at end of file diff --git a/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2azure/two-connections/main.tf b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2azure/two-connections/main.tf new file mode 100644 index 000000000..1a71b36c6 --- /dev/null +++ b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2azure/two-connections/main.tf @@ -0,0 +1,109 @@ +provider "equinix" { + client_id = var.equinix_client_id + client_secret = var.equinix_client_secret +} + +data "equinix_fabric_service_profiles" "azure"{ + filter{ + property = "/name" + operator = "=" + values = [var.fabric_sp_name] + } +} + +resource "equinix_fabric_connection" "fcr2azure"{ + name = var.pri_connection_name + type = var.connection_type + + notifications { + type = var.notifications_type + emails = var.notifications_emails + } + + bandwidth = var.bandwidth + redundancy { + priority = "PRIMARY" + } + order { + purchase_order_number = var.pri_purchase_order_number + } + a_side { + access_point { + type = var.aside_ap_type + router { + uuid = var.cloud_router_primary_uuid + } + } + } + + z_side { + access_point { + type = var.zside_ap_type + authentication_key = var.zside_ap_authentication_key + profile { + type = var.zside_ap_profile_type + uuid = var.zside_ap_profile_uuid + } + location { + metro_code = var.zside_location + } + peering_type = var.peering_type + } + } +} + +resource "equinix_fabric_connection" "fcr2azure2"{ + name = var.sec_connection_name + + type = var.connection_type + + notifications { + type = var.notifications_type + emails = var.notifications_emails + } + + bandwidth = var.bandwidth + /*`redundancy` - Cloud router redundancy **Note: in order to use resource dependency with redundancy because + it is a set type with max items of 1; put it into the one() terraform function before attempting to address + its children. + I.e. one(equinix_fabric_connection.connection_name.redundancy).group** + */ + redundancy { + priority = "SECONDARY" + group = one(equinix_fabric_connection.fcr2azure.redundancy).group + } + order { + purchase_order_number = var.sec_purchase_order_number + } + a_side { + access_point { + type = var.aside_ap_type + router { + uuid = var.cloud_router_secondary_uuid + } + } + } + + z_side { + access_point { + type = var.zside_ap_type + authentication_key = var.zside_ap_authentication_key + profile { + type = var.zside_ap_profile_type + uuid = var.zside_ap_profile_uuid + } + location { + metro_code = var.zside_location + } + peering_type = var.peering_type + } + } +} + +output "primary_connection_result" { + value = equinix_fabric_connection.fcr2azure.id +} + +output "secondary_connection_result" { + value = equinix_fabric_connection.fcr2azure2.id +} diff --git a/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2azure/two-connections/terraform.tf b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2azure/two-connections/terraform.tf new file mode 100644 index 000000000..fd41df1c0 --- /dev/null +++ b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2azure/two-connections/terraform.tf @@ -0,0 +1,7 @@ +terraform { + required_providers { + equinix = { + source = "equinix/equinix" + } + } +} diff --git a/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2azure/two-connections/terraform.tfvars b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2azure/two-connections/terraform.tfvars new file mode 100644 index 000000000..fa151fce2 --- /dev/null +++ b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2azure/two-connections/terraform.tfvars @@ -0,0 +1,20 @@ +equinix_client_id = "Equinix_Client_Id" +equinix_client_secret = "Equinix_Client_Secret" +pri_connection_name = "fcr_2_azure_pri" +sec_connection_name = "fcr_2_azure_sec" +connection_type = "IP_VC" +notifications_type = "ALL" +notifications_emails = ["example@equinix.com"] +bandwidth = 50 +pri_purchase_order_number = "1-323202" +sec_purchase_order_number = "1-323292" +peering_type="PRIVATE" +aside_ap_type = "CLOUD_ROUTER" +cloud_router_primary_uuid = "19514e72-f1c0-497c-a550-664aa75cb28c" +cloud_router_secondary_uuid = "56cfbf37-2ffd-4dac-b797-782bb5f459fc" +zside_ap_type = "SP" +zside_ap_authentication_key = "Azure Service Key" +zside_ap_profile_type = "L2_PROFILE" +zside_ap_profile_uuid = "bfb74121-7e2c-4f74-99b3-69cdafb03b41" +zside_location = "SV" +fabric_sp_name = "Azure ExpressRoute" diff --git a/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2azure/two-connections/variables.tf b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2azure/two-connections/variables.tf new file mode 100644 index 000000000..d3c24a581 --- /dev/null +++ b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2azure/two-connections/variables.tf @@ -0,0 +1,20 @@ +variable "equinix_client_id" {} +variable "equinix_client_secret" {} +variable "pri_connection_name" {} +variable "sec_connection_name" {} +variable "connection_type" {} +variable "notifications_type" {} +variable "notifications_emails" {} +variable "bandwidth" {} +variable "pri_purchase_order_number" {} +variable "sec_purchase_order_number" {} +variable "peering_type" {} +variable "aside_ap_type" {} +variable "cloud_router_primary_uuid" {} +variable "cloud_router_secondary_uuid" {} +variable "zside_ap_type" {} +variable "zside_ap_authentication_key" {} +variable "zside_ap_profile_type" {} +variable "zside_ap_profile_uuid" {} +variable "zside_location" {} +variable "fabric_sp_name" {} diff --git a/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2oracle/README.md b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2oracle/README.md new file mode 100644 index 000000000..aea16cdf9 --- /dev/null +++ b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2oracle/README.md @@ -0,0 +1,47 @@ +# ECX Fabric Layer2 Single Connection from fabric cloud router to Oracle + +This example shows how create single connection from Fabric Cloud Router to Oracle, on ECX Fabric ports. + +## Adjust variables +At minimum, you must set below variables in `terraform.tfvars` file: + +* `equinix_client_id` - Equinix client ID (consumer key), obtained after + registering app in the developer platform +* `equinix_client_secret` - Equinix client secret ID (consumer secret), + obtained same way as above + +`fcr_uuid` - UUID of ECX Fabric Cloud Router on a-sideshow +`connection_name` - the name of the connection +`connection_type` - connection type, please refer schema +`notifications_type` - notification type +`notifications_emails` - List of emails +`bandwidth` - bandwidth in MBs +`redundancy` - Port redundancy +`aside_ap_type` - Fabric Cloud Router type +`zside_ap_type` - Z side access point type +`zside_ap_authentication_key` - Oracle authorization key following a pattern, like **ocid1.virtualcircuit.oc1.phx.aaaaaaaa62hgxtczqwpaour5gnaq4qn2wupjwpqtsknr2mvxblrcdtusda1a** +`zside_ap_profile_type` - Service profile type +`fabric_sp_name` - Service profile name, fetched based on Service Profile get call using Service Profile search schema +`zside_location` - Seller location +`seller_region` - Seller region code + +## Oracle login + +Log in to Oracle Cloud portal use account that has permission to create necessary resources. + +## Initialize +- First step is to initialize the terraform directory/resource we are going to work on. + In the given example, the folder to perform CRUD operations on a fcr2port connection can be found at examples/fcr2port/. + +- Change directory into - `CD cloudRouter2oracle` +- Initialize Terraform plugins - `terraform init` + +## Fabric Cloud Router to port connection : Create, Read, Update and Delete(CRUD) operations +Note: `–auto-approve` command does not prompt the user for validating the applying config. Remove it to get a prompt to confirm the operation. + +| Operation | Command | Description | +|:----------|:---------------------------------:|-------------------------------------------------------------------------:| +| CREATE | `terraform apply –auto-approve` | Creates a fcr2oracle connection resource | +| READ | `terraform show` | Reads/Shows the current state of the fcr2oracle connection resource | +| UPDATE | `terraform apply -refresh` | Updates the fcr2oracle with values provided in the terraform.tfvars file | +| DELETE | `terraform destroy –auto-approve` | Deletes the created fcr2oracle connection resource | diff --git a/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2oracle/main.tf b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2oracle/main.tf new file mode 100644 index 000000000..e0c110515 --- /dev/null +++ b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2oracle/main.tf @@ -0,0 +1,54 @@ +provider "equinix" { + client_id = var.equinix_client_id + client_secret = var.equinix_client_secret +} + +data "equinix_fabric_service_profiles" "oracle" { + filter { + property = "/name" + operator = "=" + values = [var.fabric_sp_name] + } +} + + +resource "equinix_fabric_connection" "fcr2oracle" { + name = var.connection_name + type = var.connection_type + notifications{ + type=var.notifications_type + emails=var.notifications_emails + } + bandwidth = var.bandwidth + order { + purchase_order_number= var.purchase_order_number + } + a_side { + access_point { + type = var.aside_ap_type + router { + uuid = var.fcr_uuid + } + } + } + z_side { + access_point { + type = var.zside_ap_type + authentication_key = var.zside_ap_authentication_key + seller_region = var.seller_region + peering_type = var.peering_type + profile { + type = var.zside_ap_profile_type + uuid = var.zside_ap_profile_uuid + } + location { + metro_code = var.zside_location + } + } + } +} + +output "connection_result" { + value = equinix_fabric_connection.fcr2oracle.id +} + diff --git a/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2oracle/terraform.tf b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2oracle/terraform.tf new file mode 100644 index 000000000..fd41df1c0 --- /dev/null +++ b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2oracle/terraform.tf @@ -0,0 +1,7 @@ +terraform { + required_providers { + equinix = { + source = "equinix/equinix" + } + } +} diff --git a/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2oracle/terraform.tfvars b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2oracle/terraform.tfvars new file mode 100644 index 000000000..87b1582ae --- /dev/null +++ b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2oracle/terraform.tfvars @@ -0,0 +1,18 @@ +equinix_client_id = "Equinix_Client_Id" +equinix_client_secret = "Equinix_Client_Secret" +connection_name = "fcr_oci_pri" +connection_type = "IP_VC" +notifications_type = "ALL" +notifications_emails = ["example@equinix.com"] +bandwidth = 50 +purchase_order_number = "1-323292" +aside_ap_type = "CLOUD_ROUTER" +fcr_uuid = "Fabric CLoud Router UUID" +peering_type = "PRIVATE" +zside_ap_type = "SP" +zside_ap_authentication_key = "Oracle Authentication Key" +zside_ap_profile_type = "L2_PROFILE" +zside_ap_profile_uuid = "Service_Profile_UUID" +zside_location = "DC" +seller_region = "us-ashburn-1" +fabric_sp_name = "Oracle Cloud Infrastructure -OCI- FastConnect" diff --git a/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2oracle/variables.tf b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2oracle/variables.tf new file mode 100644 index 000000000..2746ebaf6 --- /dev/null +++ b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2oracle/variables.tf @@ -0,0 +1,18 @@ +variable "equinix_client_id" {} +variable "equinix_client_secret" {} +variable "connection_name" {} +variable "connection_type" {} +variable "notifications_type" {} +variable "notifications_emails" {} +variable "bandwidth" {} +variable "purchase_order_number" {} +variable "aside_ap_type" {} +variable "fcr_uuid" {} +variable "peering_type" {} +variable "zside_ap_type" {} +variable "zside_ap_authentication_key" {} +variable "zside_ap_profile_type" {} +variable "zside_ap_profile_uuid" {} +variable "zside_location" {} +variable "seller_region" {} +variable "fabric_sp_name" {} diff --git a/go.mod b/go.mod index 956cb970e..0ce4605c9 100644 --- a/go.mod +++ b/go.mod @@ -10,6 +10,7 @@ require ( github.com/equinix/ne-go v1.11.0 github.com/equinix/oauth2-go v1.0.0 github.com/equinix/rest-go v1.3.0 + github.com/google/uuid v1.3.0 github.com/gruntwork-io/terratest v0.43.0 github.com/hashicorp/go-cty v1.4.1-0.20200723130312-85980079f637 github.com/hashicorp/go-multierror v1.1.1 @@ -44,7 +45,6 @@ require ( github.com/golang/protobuf v1.5.3 // indirect github.com/google/go-cmp v0.5.9 // indirect github.com/google/s2a-go v0.1.4 // indirect - github.com/google/uuid v1.3.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect github.com/googleapis/gax-go/v2 v2.11.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect diff --git a/tests/connection_e2e_fcr2aws_test.go b/tests/connection_e2e_cloudRouter2aws_test.go similarity index 100% rename from tests/connection_e2e_fcr2aws_test.go rename to tests/connection_e2e_cloudRouter2aws_test.go diff --git a/tests/connection_e2e_cloudRouter2azure_single_connection_test.go b/tests/connection_e2e_cloudRouter2azure_single_connection_test.go new file mode 100644 index 000000000..8b2cf9d7c --- /dev/null +++ b/tests/connection_e2e_cloudRouter2azure_single_connection_test.go @@ -0,0 +1,21 @@ +package tests + +import ( + "testing" + + "github.com/gruntwork-io/terratest/modules/terraform" + "github.com/stretchr/testify/assert" +) + +func TestCloudRouter2AzureSingleConnectionCreateConnection(t *testing.T) { + // retryable errors in terraform testing. + terraformOptions := terraform.WithDefaultRetryableErrors(t, &terraform.Options{ + TerraformDir: "../examples/fabric/v4/cloudRouterConnectivity/cloudRouter2azure/single_connection", + }) + + defer terraform.Destroy(t, terraformOptions) + + terraform.InitAndApply(t, terraformOptions) + output := terraform.Output(t, terraformOptions, "connection_result") + assert.NotNil(t, output) +} diff --git a/tests/connection_e2e_cloudRouter2azure_two_connections_test.go b/tests/connection_e2e_cloudRouter2azure_two_connections_test.go new file mode 100644 index 000000000..1b9e3f9da --- /dev/null +++ b/tests/connection_e2e_cloudRouter2azure_two_connections_test.go @@ -0,0 +1,23 @@ +package tests + +import ( + "testing" + + "github.com/gruntwork-io/terratest/modules/terraform" + "github.com/stretchr/testify/assert" +) + +func TestCloudRouter2AzureTwoConnectionsCreateConnection(t *testing.T) { + // retryable errors in terraform testing. + terraformOptions := terraform.WithDefaultRetryableErrors(t, &terraform.Options{ + TerraformDir: "../examples/fabric/v4/cloudRouterConnectivity/cloudRouter2azure/two_connections", + }) + + defer terraform.Destroy(t, terraformOptions) + + terraform.InitAndApply(t, terraformOptions) + primaryConnection := terraform.Output(t, terraformOptions, "primary_connection_result") + secondaryConnection := terraform.Output(t, terraformOptions, "secondary_connection_result") + assert.NotNil(t, primaryConnection) + assert.NotNil(t, secondaryConnection) +} diff --git a/tests/connection_e2e_fcr2gcp_test.go b/tests/connection_e2e_cloudRouter2gcp_test.go similarity index 100% rename from tests/connection_e2e_fcr2gcp_test.go rename to tests/connection_e2e_cloudRouter2gcp_test.go diff --git a/tests/connection_e2e_cloudRouter2oracle_test.go b/tests/connection_e2e_cloudRouter2oracle_test.go new file mode 100644 index 000000000..b5cb1a60f --- /dev/null +++ b/tests/connection_e2e_cloudRouter2oracle_test.go @@ -0,0 +1,21 @@ +package tests + +import ( + "testing" + + "github.com/gruntwork-io/terratest/modules/terraform" + "github.com/stretchr/testify/assert" +) + +func TestCloudRouter2OracleCreateConnection(t *testing.T) { + // retryable errors in terraform testing. + terraformOptions := terraform.WithDefaultRetryableErrors(t, &terraform.Options{ + TerraformDir: "../examples/fabric/v4/cloudRouterConnectivity/cloudRouter2oracle", + }) + + defer terraform.Destroy(t, terraformOptions) + + terraform.InitAndApply(t, terraformOptions) + output := terraform.Output(t, terraformOptions, "connection_result") + assert.NotNil(t, output) +} diff --git a/tests/connection_e2e_fcr2port_test.go b/tests/connection_e2e_cloudRouter2port_test.go similarity index 100% rename from tests/connection_e2e_fcr2port_test.go rename to tests/connection_e2e_cloudRouter2port_test.go diff --git a/tests/connection_e2e_fcr_test.go b/tests/connection_e2e_cloudRouter_test.go similarity index 100% rename from tests/connection_e2e_fcr_test.go rename to tests/connection_e2e_cloudRouter_test.go