Skip to content

Commit

Permalink
fix: Fixing VD to Azure connection resource (#435)
Browse files Browse the repository at this point in the history
Fixed resource_fabric_connection by adding Type and Interface parameters
to access_point.
Updated equinix_fabric_connection.md file
  • Loading branch information
srushti-patl authored Nov 3, 2023
2 parents d161d42 + 32f410d commit 89a173b
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/resources/equinix_ecx_l2_connection.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ resource "equinix_ecx_l2_connection" "ports-2-azure" {
vlan_ctag = 2512
seller_metro_code = "SV"
named_tag = "PRIVATE"
authorization_key = "c4dff8e8-b52f-4b34-b0d4-c4588f7338f3
authorization_key = "c4dff8e8-b52f-4b34-b0d4-c4588f7338f3"
secondary_connection {
name = "tf-azure-sec"
port_uuid = data.equinix_ecx_port.sv-qinq-sec.id
Expand Down
10 changes: 10 additions & 0 deletions docs/resources/equinix_fabric_connection.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ Optional:
- **Deprecated** `gateway` Use `router` attribute instead; (Block Set) (see [below for nested schema](#nestedblock--a_side--access_point--router))
- `router` (Block Set) Cloud Router access point information that replaces `gateway` (refers to [below for nested schema](#nestedblock--a_side--access_point--router))
- `interface` (Block Set) Virtual device interface (see [below for nested schema](#nestedblock--a_side--access_point--interface))
- `network` (Block Set) Simplified Network (see [below for nested schema](#nestedblock--a_side--access_point--network))
- `link_protocol` (Block Set) Connection link protocol (see [below for nested schema](#nestedblock--a_side--access_point--link_protocol))
- `location` (Block Set) Access point location (see [below for nested schema](#nestedblock--a_side--access_point--location))
- `peering_type` (String) Peering Type- PRIVATE,MICROSOFT,PUBLIC, MANUAL
Expand Down Expand Up @@ -103,6 +104,12 @@ Read-Only:

- `id` (String) id

<a id="nestedblock--a_side--access_point--network"></a>
### Nested Schema for `a_side.access_point.network`

Required:
- `uuid` (String) Equinix-assigned network identifier


<a id="nestedblock--a_side--access_point--link_protocol"></a>
### Nested Schema for `a_side.access_point.link_protocol`
Expand Down Expand Up @@ -190,8 +197,10 @@ Optional:
Optional:

- `type` (String) Virtual Device type
- `name` (String) Customer-assigned Virtual Device Name
- `uuid` (String) Equinix-assigned Virtual Device identifier


Read-Only:

- `href` (String) Unique Resource Identifier
Expand Down Expand Up @@ -220,6 +229,7 @@ Optional:
- `key` (String) Additional information key
- `value` (String) Additional information value

~> **NOTE:** Port to IBM Connections could be modified from IBM Service Provider Side by using parameters passed to additional_info field: `{"key": "ASN", "value": "1111"}` `{"key": "Global", "value": "false"}` `{"key": "BGP_IBM_CIDR", "value": "172.16.0.18/30"}` `{"key": "BGP_CER_CIDR", "value": "172.16.0.19/30"}`

<a id="nestedblock--a_side--service_token"></a>
### Nested Schema for `a_side.service_token`
Expand Down
7 changes: 6 additions & 1 deletion equinix/fabric_connection_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,11 @@ func createAccessPointVirtualDeviceSch() map[string]*schema.Schema {
Optional: true,
Description: "Virtual Device type",
},
"name": {
Type: schema.TypeString,
Optional: true,
Description: "Customer-assigned Virtual Device Name",
},
}
}

Expand All @@ -240,7 +245,7 @@ func createAccessPointInterface() map[string]*schema.Schema {
Description: "Equinix-assigned interface identifier",
},
"id": {
Type: schema.TypeString,
Type: schema.TypeInt,
Computed: true,
Description: "id",
},
Expand Down
37 changes: 37 additions & 0 deletions equinix/fabric_mapping_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ func accessPointToFabric(accessPointRequest []interface{}) v4.AccessPoint {
portList := accessPointMap["port"].(*schema.Set).List()
profileList := accessPointMap["profile"].(*schema.Set).List()
locationList := accessPointMap["location"].(*schema.Set).List()
virtualdeviceList := accessPointMap["virtual_device"].(*schema.Set).List()
interfaceList := accessPointMap["interface"].(*schema.Set).List()
networkList := accessPointMap["network"].(*schema.Set).List()
typeVal := accessPointMap["type"].(string)
authenticationKey := accessPointMap["authentication_key"].(string)
Expand Down Expand Up @@ -108,6 +110,16 @@ func accessPointToFabric(accessPointRequest []interface{}) v4.AccessPoint {
accessPoint.Location = &sl
}

if len(virtualdeviceList) != 0 {
vd := virtualdeviceToFabric(virtualdeviceList)
accessPoint.VirtualDevice = &vd
}

if len(interfaceList) != 0 {
il := interfaceToFabric(interfaceList)
accessPoint.Interface_ = &il
}

}
return accessPoint
}
Expand Down Expand Up @@ -252,6 +264,31 @@ func locationToFabric(locationList []interface{}) v4.SimplifiedLocation {
return sl
}

func virtualdeviceToFabric(virtualdeviceList []interface{}) v4.VirtualDevice {
vd := v4.VirtualDevice{}
for _, ll := range virtualdeviceList {
llMap := ll.(map[string]interface{})
hr := llMap["href"].(string)
tp := llMap["type"].(string)
ud := llMap["uuid"].(string)
na := llMap["name"].(string)
vd = v4.VirtualDevice{Href: hr, Type_: tp, Uuid: ud, Name: na}
}
return vd
}

func interfaceToFabric(interfaceList []interface{}) v4.ModelInterface {
il := v4.ModelInterface{}
for _, ll := range interfaceList {
llMap := ll.(map[string]interface{})
ud := llMap["uuid"].(string)
tp := llMap["type"].(string)
id := llMap["id"].(int)
il = v4.ModelInterface{Type_: tp, Uuid: ud, Id: int32(id)}
}
return il
}

func accountToCloudRouter(accountList []interface{}) v4.SimplifiedAccount {
sa := v4.SimplifiedAccount{}
for _, ll := range accountList {
Expand Down
6 changes: 6 additions & 0 deletions examples/fabric/v4/portConnectivity/ibm/ibm2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ At minimum, you must set below variables in `terraform.tfvars` file:
`seller_asn` - Seller ASN Number
`seller_region` - Seller Region

## Note
* You can modify the IBM side of the connection using parameters passed to additional_info field
`{"key": "Global", "value": "false"}`
`{"key": "BGP_IBM_CIDR", "value": "172.16.0.18/30"}`
`{"key": "BGP_CER_CIDR", "value": "172.16.0.19/30"}`

## IBM login

Log in to IBM portal with an account that has permission to create necessary resources.
Expand Down
2 changes: 1 addition & 1 deletion examples/fabric/v4/portConnectivity/ibm/ibm2/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ resource "equinix_fabric_connection" "ibm2" {

bandwidth = var.bandwidth

additional_info = [{key = "ASN", value = var.seller_asn }, {"key"= "Global","value" = "false"}, {"key" = "BGP_IBM_CIDR","value" = "172.16.0.18/30"},{"key" = "BGP_CER_CIDR","value" = "172.16.0.19/30"} ]
additional_info = [{key = "ASN", value = var.seller_asn }]

redundancy { priority = var.redundancy }
order {
Expand Down

0 comments on commit 89a173b

Please sign in to comment.