Skip to content

Commit

Permalink
feat: Adds Fabric cloud router to IPWAN network connection support (#408
Browse files Browse the repository at this point in the history
)

- Adds support for a new connection type: FCR to IPWAN
- Includes changes to the connection schema to support the above type
- Incudes tests and terraform examples
  • Loading branch information
manu-equinix authored Oct 16, 2023
1 parent 53e84e5 commit 7846729
Show file tree
Hide file tree
Showing 8 changed files with 162 additions and 5 deletions.
2 changes: 1 addition & 1 deletion equinix/fabric_connection_read_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ func readFabricConnectionResourceSchema() map[string]*schema.Schema {
"type": {
Type: schema.TypeString,
Computed: true,
Description: "Defines the connection type like VG_VC, EVPL_VC, EPL_VC, EC_VC, IP_VC, ACCESS_EPL_VC",
Description: "Defines the connection type like VG_VC, EVPL_VC, EPL_VC, EC_VC, IP_VC, IPWAN_VC, ACCESS_EPL_VC",
},
"bandwidth": {
Type: schema.TypeInt,
Expand Down
32 changes: 28 additions & 4 deletions equinix/fabric_connection_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,21 @@ func createVirtualGatewaySch() map[string]*schema.Schema {
}
}

func createNetworkSch() map[string]*schema.Schema {
return map[string]*schema.Schema{
"uuid": {
Type: schema.TypeString,
Optional: true,
Description: "Equinix-assigned Network identifier",
},
"href": {
Type: schema.TypeString,
Computed: true,
Description: "Unique Resource Identifier",
},
}
}

var createGatewayProjectSchRes = &schema.Resource{
Schema: createGatewayProjectSch(),
}
Expand Down Expand Up @@ -296,8 +311,8 @@ func createConnectionSideAccessPointRes() *schema.Resource {
"type": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"COLO", "VD", "VG", "SP", "IGW", "SUBNET", "CLOUD_ROUTER"}, true),
Description: "Access point type - COLO, VD, VG, SP, IGW, SUBNET, CLOUD_ROUTER",
ValidateFunc: validation.StringInSlice([]string{"COLO", "VD", "VG", "SP", "IGW", "SUBNET", "CLOUD_ROUTER", "NETWORK"}, true),
Description: "Access point type - COLO, VD, VG, SP, IGW, SUBNET, CLOUD_ROUTER, NETWORK",
},
"authentication_key": {
Type: schema.TypeString,
Expand Down Expand Up @@ -360,6 +375,15 @@ func createConnectionSideAccessPointRes() *schema.Resource {
Schema: createVirtualGatewaySch(),
},
},
"network": {
Type: schema.TypeSet,
Optional: true,
Description: "network access point information",
MaxItems: 1,
Elem: &schema.Resource{
Schema: createNetworkSch(),
},
},
"link_protocol": {
Type: schema.TypeSet,
Optional: true,
Expand Down Expand Up @@ -760,8 +784,8 @@ func createFabricConnectionResourceSchema() map[string]*schema.Schema {
"type": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{"VG_VC", "EVPL_VC", "EPL_VC", "EC_VC", "IP_VC", "ACCESS_EPL_VC"}, true),
Description: "Defines the connection type like VG_VC, EVPL_VC, EPL_VC, EC_VC, IP_VC, ACCESS_EPL_VC",
ValidateFunc: validation.StringInSlice([]string{"VG_VC", "EVPL_VC", "EPL_VC", "EC_VC", "IP_VC", "IPWAN_VC", "ACCESS_EPL_VC"}, true),
Description: "Defines the connection type like VG_VC, EVPL_VC, EPL_VC, EC_VC, IP_VC, IPWAN_VC,ACCESS_EPL_VC",
},
"bandwidth": {
Type: schema.TypeInt,
Expand Down
17 changes: 17 additions & 0 deletions equinix/fabric_mapping_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func accessPointToFabric(accessPointRequest []interface{}) v4.AccessPoint {
portList := accessPointMap["port"].(*schema.Set).List()
profileList := accessPointMap["profile"].(*schema.Set).List()
locationList := accessPointMap["location"].(*schema.Set).List()
networkList := accessPointMap["network"].(*schema.Set).List()
typeVal := accessPointMap["type"].(string)
authenticationKey := accessPointMap["authentication_key"].(string)
if authenticationKey != "" {
Expand Down Expand Up @@ -79,6 +80,13 @@ func accessPointToFabric(accessPointRequest []interface{}) v4.AccessPoint {
accessPoint.Port = &port
}
}

if len(networkList) != 0 {
network := networkToFabric(networkList)
if network.Uuid != "" {
accessPoint.Network = &network
}
}
linkProtocolList := accessPointMap["link_protocol"].(*schema.Set).List()

if len(linkProtocolList) != 0 {
Expand Down Expand Up @@ -205,6 +213,15 @@ func portToFabric(portList []interface{}) v4.SimplifiedPort {
}
return p
}
func networkToFabric(networkList []interface{}) v4.SimplifiedNetwork {
p := v4.SimplifiedNetwork{}
for _, pl := range networkList {
plMap := pl.(map[string]interface{})
uuid := plMap["uuid"].(string)
p = v4.SimplifiedNetwork{Uuid: uuid}
}
return p
}

func simplifiedServiceProfileToFabric(profileList []interface{}) v4.SimplifiedServiceProfile {
ssp := v4.SimplifiedServiceProfile{}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# ECX Fabric Layer2 Connection from fabric cloud router to ipwan

This example shows how create connection from Fabric Cloud Router to ipwan, 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
`network_uuid` - UUID of ipwan network on z-side
`connection_name` - the name of the connection
`connection_type` - connection type, please refer schema
`notifications_type` - notification type
`notifications_emails` - List of emails
`purchase_order_number` - Purchase order number
`bandwidth` - bandwidth in MBs
`aside_ap_type` - Fabric Cloud Router type
`zside_ap_type` - Z side access point type, ipwan

## 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 fcr2wan connection can be found at examples/fcr2port/.

- Change directory into - `CD examples/fabric/v4/cloudRouterConnectivity/cloudRouter2wan/`
- Initialize Terraform plugins - `terraform init`

## Fabric Cloud Router to wan 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 fcr2wan connection resource |
| READ | `terraform show` | Reads/Shows the current state of the fcr2wan connection resource |
| UPDATE | `terraform apply -refresh` | Updates the fcr2wan with values provided in the terraform.tfvars file |
| DELETE | `terraform destroy –auto-approve` | Deletes the created fcr2wan connection resource |
40 changes: 40 additions & 0 deletions examples/fabric/v4/cloudRouterConnectivity/cloudRouter2wan/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
provider "equinix" {
client_id = var.equinix_client_id
client_secret = var.equinix_client_secret
}


resource "equinix_fabric_connection" "fcr2ipwan"{
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
network {
uuid = var.network_uuid
}
}
}
}

output "connection_result" {
value = equinix_fabric_connection.fcr2ipwan.id
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
terraform {
required_providers {
equinix = {
source = "equinix/equinix"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
equinix_client_id = “”
equinix_client_secret = “”
notifications_type = “ALL”
notifications_emails = [“[email protected]”,“[email protected]”]
purchase_order_number = “1-323292"
fcr_uuid = “<fcr-uuid>”
connection_name = “terraform_fcr2wan”
connection_type = “IPWAN_VC”
bandwidth = 50
aside_ap_type = “CLOUD_ROUTER”
zside_ap_type = “NETWORK”
network_uuid = “<network-uuid>”
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
variable "equinix_client_id" {}
variable "equinix_client_secret" {}

variable "fcr_uuid" {}
variable "network_uuid" {}

variable "notifications_type" {}
variable "notifications_emails" {}
variable "purchase_order_number" {}

variable "connection_name" {}
variable "connection_type" {}
variable "bandwidth" {}

variable "aside_ap_type" {}
variable "zside_ap_type" {}


0 comments on commit 7846729

Please sign in to comment.