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..003236e2e --- /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 +} diff --git a/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2serviceprofile/terraform.tf b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2serviceprofile/terraform.tf new file mode 100644 index 000000000..fd41df1c0 --- /dev/null +++ b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2serviceprofile/terraform.tf @@ -0,0 +1,7 @@ +terraform { + required_providers { + equinix = { + source = "equinix/equinix" + } + } +} 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..7c5e34e41 --- /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" diff --git a/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2serviceprofile/variable.tf b/examples/fabric/v4/cloudRouterConnectivity/cloudRouter2serviceprofile/variable.tf new file mode 100644 index 000000000..d9b7f3dc5 --- /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" {} 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) +}