From a44b43ca82567b9b78d589724b210000d372ee7e Mon Sep 17 00:00:00 2001 From: srushti-patl Date: Thu, 21 Sep 2023 12:53:52 -0700 Subject: [PATCH 1/2] feat! Adding FCR2ServiceProfile example and test scripts --- .../cloudRouter2serviceprofile/README.md | 41 +++++++++++++++ .../cloudRouter2serviceprofile/main.tf | 50 +++++++++++++++++++ .../cloudRouter2serviceprofile/terraform.tf | 7 +++ .../terraform.tfvars.example | 17 +++++++ .../cloudRouter2serviceprofile/variable.tf | 17 +++++++ ...ion_e2e_cloudRouter2serviceprofile_test.go | 21 ++++++++ 6 files changed, 153 insertions(+) create mode 100644 examples/fabric/v4/cloudRouterConnectivity/cloudRouter2serviceprofile/README.md create mode 100644 examples/fabric/v4/cloudRouterConnectivity/cloudRouter2serviceprofile/main.tf create mode 100644 examples/fabric/v4/cloudRouterConnectivity/cloudRouter2serviceprofile/terraform.tf create mode 100644 examples/fabric/v4/cloudRouterConnectivity/cloudRouter2serviceprofile/terraform.tfvars.example create mode 100644 examples/fabric/v4/cloudRouterConnectivity/cloudRouter2serviceprofile/variable.tf create mode 100644 tests/connection_e2e_cloudRouter2serviceprofile_test.go diff --git a/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2serviceprofile/README.md b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2serviceprofile/README.md new file mode 100644 index 000000000..eef702e1f --- /dev/null +++ b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2serviceprofile/README.md @@ -0,0 +1,41 @@ +# ECX Fabric Layer2 Single Connection from fabric cloud router to Service Profile + +This example shows how create single connection from Fabric Cloud Router to Seller Service Profile, 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_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 + +## 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 fcr2serviceprofile connection can be found at examples/fcr2port/. + +- Change directory into - `CD cloudRouter2serviceprofile` +- Initialize Terraform plugins - `terraform init` + +## Fabric Cloud Router to ServiceProfile 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 fcr2port connection resource | +| READ | `terraform show` | Reads/Shows the current state of the fcr2port connection resource | +| UPDATE | `terraform apply -refresh` | Updates the fcr2port with values provided in the terraform.tfvars file | +| DELETE | `terraform destroy –auto-approve` | Deletes the created fcr2port connection resource | \ No newline at end of file diff --git a/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2serviceprofile/main.tf b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2serviceprofile/main.tf new file mode 100644 index 000000000..40bf21d46 --- /dev/null +++ b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2serviceprofile/main.tf @@ -0,0 +1,50 @@ +provider "equinix" { + client_id = var.equinix_client_id + client_secret = var.equinix_client_secret +} + +data "equinix_fabric_service_profiles" "sp" { + filter { + property = "/name" + operator = "=" + values = [var.fabric_sp_name] + } +} + +resource "equinix_fabric_connection" "fcr2profile" { + 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 + profile { + type= var.zside_ap_profile_type + uuid= data.equinix_fabric_service_profiles.sp.id + } + location { + metro_code= var.zside_location + } + } + } +} + +output "connection_result" { + value = equinix_fabric_connection.fcr2profile.id +} \ No newline at end of file diff --git a/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2serviceprofile/terraform.tf b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2serviceprofile/terraform.tf new file mode 100644 index 000000000..2dc81d8b0 --- /dev/null +++ b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2serviceprofile/terraform.tf @@ -0,0 +1,7 @@ +terraform { + required_providers { + equinix = { + source = "equinix/equinix" + } + } +} \ No newline at end of file diff --git a/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2serviceprofile/terraform.tfvars.example b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2serviceprofile/terraform.tfvars.example new file mode 100644 index 000000000..afca4bd96 --- /dev/null +++ b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2serviceprofile/terraform.tfvars.example @@ -0,0 +1,17 @@ +equinix_client_id = "Equnix_Client_Id" +equinix_client_secret = "Equinix_Client_Secret" +connection_name = "cloudRouter_gen_csp" +connection_type = "IP_VC" +notifications_type = "ALL" +notifications_emails = ["example@equinix.com"] +bandwidth = 50 +redundancy = "SECONDARY" #"PRIMARY" #|| +redundancy_group_uuid = "53e04795-e6da-4756-9462-8bdc9b1f96d3" #OPTIONAL +purchase_order_number = "1-323292" +peering_type="PRIVATE" +aside_ap_type = "CLOUD_ROUTER" +fcr_uuid = "Fabric Cloud Router UUID" +zside_ap_type = "SP" +zside_ap_profile_type = "L2_PROFILE" +zside_location = "SV" +fabric_sp_name = "Ajith Ops User QnQ" \ No newline at end of file diff --git a/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2serviceprofile/variable.tf b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2serviceprofile/variable.tf new file mode 100644 index 000000000..0f5489755 --- /dev/null +++ b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2serviceprofile/variable.tf @@ -0,0 +1,17 @@ +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_profile_type" {} +variable "zside_location" {} +variable "fabric_sp_name" {} \ No newline at end of file diff --git a/tests/connection_e2e_cloudRouter2serviceprofile_test.go b/tests/connection_e2e_cloudRouter2serviceprofile_test.go new file mode 100644 index 000000000..c40b77ccd --- /dev/null +++ b/tests/connection_e2e_cloudRouter2serviceprofile_test.go @@ -0,0 +1,21 @@ +package tests + +import ( + "testing" + + "github.com/gruntwork-io/terratest/modules/terraform" + "github.com/stretchr/testify/assert" +) + +func TestCloudRouter2ServiceProfileCreateConnection(t *testing.T) { + // retryable errors in terraform testing. + terraformOptions := terraform.WithDefaultRetryableErrors(t, &terraform.Options{ + TerraformDir: "../examples/fabric/v4/cloudRouterConnectivity/cloudRouter2serviceprofile", + }) + + defer terraform.Destroy(t, terraformOptions) + + terraform.InitAndApply(t, terraformOptions) + output := terraform.Output(t, terraformOptions, "connection_result") + assert.NotNil(t, output) +} From 87f0ea3bb6aed5c482809a359636603d25a810c2 Mon Sep 17 00:00:00 2001 From: srushti-patl Date: Thu, 21 Sep 2023 12:58:28 -0700 Subject: [PATCH 2/2] fix: Adding whitespaces --- .../cloudRouterConnectivity/cloudRouter2serviceprofile/main.tf | 2 +- .../cloudRouter2serviceprofile/terraform.tf | 2 +- .../cloudRouter2serviceprofile/terraform.tfvars.example | 2 +- .../cloudRouter2serviceprofile/variable.tf | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2serviceprofile/main.tf b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2serviceprofile/main.tf index 40bf21d46..003236e2e 100644 --- a/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2serviceprofile/main.tf +++ b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2serviceprofile/main.tf @@ -47,4 +47,4 @@ resource "equinix_fabric_connection" "fcr2profile" { output "connection_result" { value = equinix_fabric_connection.fcr2profile.id -} \ No newline at end of file +} diff --git a/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2serviceprofile/terraform.tf b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2serviceprofile/terraform.tf index 2dc81d8b0..fd41df1c0 100644 --- a/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2serviceprofile/terraform.tf +++ b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2serviceprofile/terraform.tf @@ -4,4 +4,4 @@ terraform { source = "equinix/equinix" } } -} \ No newline at end of file +} diff --git a/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2serviceprofile/terraform.tfvars.example b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2serviceprofile/terraform.tfvars.example index afca4bd96..7c5e34e41 100644 --- a/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2serviceprofile/terraform.tfvars.example +++ b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2serviceprofile/terraform.tfvars.example @@ -14,4 +14,4 @@ fcr_uuid = "Fabric Cloud Router UUID" zside_ap_type = "SP" zside_ap_profile_type = "L2_PROFILE" zside_location = "SV" -fabric_sp_name = "Ajith Ops User QnQ" \ No newline at end of file +fabric_sp_name = "Ajith Ops User QnQ" diff --git a/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2serviceprofile/variable.tf b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2serviceprofile/variable.tf index 0f5489755..d9b7f3dc5 100644 --- a/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2serviceprofile/variable.tf +++ b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2serviceprofile/variable.tf @@ -14,4 +14,4 @@ variable "fcr_uuid" {} variable "zside_ap_type" {} variable "zside_ap_profile_type" {} variable "zside_location" {} -variable "fabric_sp_name" {} \ No newline at end of file +variable "fabric_sp_name" {}