Skip to content

Commit

Permalink
feat: fabric resource connection_route_filter (#795)
Browse files Browse the repository at this point in the history
* Add equinix_fabric_connection_route_filter resource to attach route
filter policies to fabric cloud router connections
* Add data source for retrieving connection_route_filters by connection
and route filter uuids
* Add data source to get all route filters for a given connection uuid
* Add docs with make docs
* Add acceptance tests for resource and data sources

Local tests passing:
<img width="1278" alt="image"
src="https://github.com/user-attachments/assets/bbf2f520-5219-440a-944c-59aaf7b24278">
  • Loading branch information
thogarty authored Oct 14, 2024
1 parent 37cd736 commit 343c8fc
Show file tree
Hide file tree
Showing 14 changed files with 990 additions and 26 deletions.
57 changes: 57 additions & 0 deletions docs/data-sources/fabric_connection_route_filter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
subcategory: "Fabric"
---

# equinix_fabric_connection_route_filter (Data Source)

Fabric V4 API compatible data resource that allow user to fetch route filter policy attachment to a fabric connection

Additional Documentation:
* Getting Started: https://docs.equinix.com/en-us/Content/Interconnection/FCR/FCR-route-filters.htm
* API: https://developer.equinix.com/dev-docs/fabric/api-reference/fabric-v4-apis#route-filter-rules

## Example Usage

```terraform
data "equinix_fabric_connection_route_filter" "attached_policy" {
connection_id = "<connection_uuid>"
route_filter_id = "<route_filter_uuid>"
}
output "connection_route_filter_id" {
value = data.equinix_fabric_connection_route_filter.attached_policy.id
}
output "connection_route_filter_connection_id" {
value = data.equinix_fabric_connection_route_filter.attached_policy.connection_id
}
output "connection_route_filter_direction" {
value = data.equinix_fabric_connection_route_filter.attached_policy.direction
}
output "connection_route_filter_type" {
value = data.equinix_fabric_connection_route_filter.attached_policy.type
}
output "connection_route_filter_attachment_status" {
value = data.equinix_fabric_connection_route_filter.attached_policy.attachment_status
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `connection_id` (String) Equinix Assigned UUID of the Equinix Connection to attach the Route Filter Policy to
- `route_filter_id` (String) Equinix Assigned UUID of the Route Filter Policy to attach to the Equinix Connection

### Read-Only

- `attachment_status` (String) Status of the Route Filter Policy attachment lifecycle
- `direction` (String) Direction of the filtering of the attached Route Filter Policy
- `href` (String) URI to the attached Route Filter Policy on the Connection
- `id` (String) The ID of this resource.
- `type` (String) Route Filter Type. One of [ "BGP_IPv4_PREFIX_FILTER", "BGP_IPv6_PREFIX_FILTER" ]
- `uuid` (String) Equinix Assigned ID for Route Filter Policy
75 changes: 75 additions & 0 deletions docs/data-sources/fabric_connection_route_filters.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
subcategory: "Fabric"
---

# equinix_fabric_connection_route_filters (Data Source)

Fabric V4 API compatible data resource that allow user to fetch all route filter policies attached to a fabric connection

Additional Documentation:
* Getting Started: https://docs.equinix.com/en-us/Content/Interconnection/FCR/FCR-route-filters.htm
* API: https://developer.equinix.com/dev-docs/fabric/api-reference/fabric-v4-apis#route-filter-rules

## Example Usage

```terraform
data "equinix_connection_route_filters" "attached_policies" {
connection_id = "<connection_uuid>"
}
output "connection_first_route_filter_uuid" {
value = data.equinix_fabric_connection_route_filter.attached_policies.0.uuid
}
output "connection_first_route_filter_connection_id" {
value = data.equinix_fabric_connection_route_filter.attached_policies.0.connection_id
}
output "connection_first_route_filter_direction" {
value = data.equinix_fabric_connection_route_filter.attached_policies.0.direction
}
output "connection_first_route_filter_type" {
value = data.equinix_fabric_connection_route_filter.attached_policies.0.type
}
output "connection_first_route_filter_attachment_status" {
value = data.equinix_fabric_connection_route_filter.attached_policies.0.attachment_status
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `connection_id` (String) Equinix Assigned UUID of the Equinix Connection to attach the Route Filter Policy to

### Read-Only

- `data` (List of Object) The list of Rules attached to the given Route Filter Policy UUID (see [below for nested schema](#nestedatt--data))
- `id` (String) The ID of this resource.
- `pagination` (Set of Object) Pagination details for the Data Source Search Request (see [below for nested schema](#nestedatt--pagination))

<a id="nestedatt--data"></a>
### Nested Schema for `data`

Read-Only:

- `attachment_status` (String)
- `direction` (String)
- `href` (String)
- `type` (String)
- `uuid` (String)


<a id="nestedatt--pagination"></a>
### Nested Schema for `pagination`

Read-Only:

- `limit` (Number)
- `next` (String)
- `offset` (Number)
- `previous` (String)
- `total` (Number)
72 changes: 72 additions & 0 deletions docs/resources/fabric_connection_route_filter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
subcategory: "Fabric"
---

# equinix_fabric_connection_route_filter (Resource)

Fabric V4 API compatible resource allows attachment of Route Filter Polices to Fabric Connections

Additional Documentation:
* Getting Started: https://docs.equinix.com/en-us/Content/Interconnection/FCR/FCR-route-filters.htm
* API: https://developer.equinix.com/dev-docs/fabric/api-reference/fabric-v4-apis#route-filters

## Example Usage

```terraform
resource "equinix_fabric_connection_route_filter" "policy_attachment" {
connection_id = "<connection_uuid>"
route_filter_id = "<route_filter_policy_uuid>"
direction = "INBOUND"
}
output "connection_route_filter_id" {
value = equinix_fabric_connection_route_filter.policy_attachment.id
}
output "connection_route_filter_connection_id" {
value = equinix_fabric_connection_route_filter.policy_attachment.connection_id
}
output "connection_route_filter_direction" {
value = equinix_fabric_connection_route_filter.policy_attachment.direction
}
output "connection_route_filter_type" {
value = equinix_fabric_connection_route_filter.policy_attachment.type
}
output "connection_route_filter_attachment_status" {
value = equinix_fabric_connection_route_filter.policy_attachment.attachment_status
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `connection_id` (String) Equinix Assigned UUID of the Equinix Connection to attach the Route Filter Policy to
- `direction` (String) Direction of the filtering of the attached Route Filter Policy
- `route_filter_id` (String) Equinix Assigned UUID of the Route Filter Policy to attach to the Equinix Connection

### Optional

- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))

### Read-Only

- `attachment_status` (String) Status of the Route Filter Policy attachment lifecycle
- `href` (String) URI to the attached Route Filter Policy on the Connection
- `id` (String) The ID of this resource.
- `type` (String) Route Filter Type. One of [ "BGP_IPv4_PREFIX_FILTER", "BGP_IPv6_PREFIX_FILTER" ]
- `uuid` (String) Equinix Assigned ID for Route Filter Policy

<a id="nestedblock--timeouts"></a>
### Nested Schema for `timeouts`

Optional:

- `create` (String)
- `delete` (String)
- `read` (String)
- `update` (String)
56 changes: 30 additions & 26 deletions equinix/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/equinix/terraform-provider-equinix/internal/config"
fabric_connection "github.com/equinix/terraform-provider-equinix/internal/resources/fabric/connection"
fabric_connection_route_filter "github.com/equinix/terraform-provider-equinix/internal/resources/fabric/connection_route_filter"
fabric_market_place_subscription "github.com/equinix/terraform-provider-equinix/internal/resources/fabric/marketplace"
fabric_network "github.com/equinix/terraform-provider-equinix/internal/resources/fabric/network"
fabric_route_filter "github.com/equinix/terraform-provider-equinix/internal/resources/fabric/route_filter"
Expand Down Expand Up @@ -86,6 +87,8 @@ func Provider() *schema.Provider {
"equinix_fabric_routing_protocol": dataSourceRoutingProtocol(),
"equinix_fabric_connection": fabric_connection.DataSource(),
"equinix_fabric_connections": fabric_connection.DataSourceSearch(),
"equinix_fabric_connection_route_filter": fabric_connection_route_filter.DataSource(),
"equinix_fabric_connection_route_filters": fabric_connection_route_filter.DataSourceGetAllRules(),
"equinix_fabric_cloud_router": dataSourceFabricCloudRouter(),
"equinix_fabric_cloud_routers": dataSourceFabricGetCloudRouters(),
"equinix_fabric_market_place_subscription": fabric_market_place_subscription.DataSourceFabricMarketplaceSubscription(),
Expand Down Expand Up @@ -122,32 +125,33 @@ func Provider() *schema.Provider {
"equinix_metal_vrf": vrf.DataSource(),
},
ResourcesMap: map[string]*schema.Resource{
"equinix_fabric_network": fabric_network.Resource(),
"equinix_fabric_cloud_router": resourceFabricCloudRouter(),
"equinix_fabric_connection": fabric_connection.Resource(),
"equinix_fabric_route_filter": fabric_route_filter.Resource(),
"equinix_fabric_route_filter_rule": fabric_route_filter_rule.Resource(),
"equinix_fabric_routing_protocol": resourceFabricRoutingProtocol(),
"equinix_fabric_service_profile": resourceFabricServiceProfile(),
"equinix_network_device": resourceNetworkDevice(),
"equinix_network_ssh_user": resourceNetworkSSHUser(),
"equinix_network_bgp": resourceNetworkBGP(),
"equinix_network_ssh_key": resourceNetworkSSHKey(),
"equinix_network_acl_template": resourceNetworkACLTemplate(),
"equinix_network_device_link": resourceNetworkDeviceLink(),
"equinix_network_file": resourceNetworkFile(),
"equinix_metal_user_api_key": resourceMetalUserAPIKey(),
"equinix_metal_project_api_key": resourceMetalProjectAPIKey(),
"equinix_metal_device": metal_device.Resource(),
"equinix_metal_device_network_type": resourceMetalDeviceNetworkType(),
"equinix_metal_port": metal_port.Resource(),
"equinix_metal_reserved_ip_block": resourceMetalReservedIPBlock(),
"equinix_metal_ip_attachment": resourceMetalIPAttachment(),
"equinix_metal_spot_market_request": resourceMetalSpotMarketRequest(),
"equinix_metal_virtual_circuit": virtual_circuit.Resource(),
"equinix_metal_vrf": vrf.Resource(),
"equinix_metal_bgp_session": resourceMetalBGPSession(),
"equinix_metal_port_vlan_attachment": resourceMetalPortVlanAttachment(),
"equinix_fabric_network": fabric_network.Resource(),
"equinix_fabric_cloud_router": resourceFabricCloudRouter(),
"equinix_fabric_connection": fabric_connection.Resource(),
"equinix_fabric_connection_route_filter": fabric_connection_route_filter.Resource(),
"equinix_fabric_route_filter": fabric_route_filter.Resource(),
"equinix_fabric_route_filter_rule": fabric_route_filter_rule.Resource(),
"equinix_fabric_routing_protocol": resourceFabricRoutingProtocol(),
"equinix_fabric_service_profile": resourceFabricServiceProfile(),
"equinix_network_device": resourceNetworkDevice(),
"equinix_network_ssh_user": resourceNetworkSSHUser(),
"equinix_network_bgp": resourceNetworkBGP(),
"equinix_network_ssh_key": resourceNetworkSSHKey(),
"equinix_network_acl_template": resourceNetworkACLTemplate(),
"equinix_network_device_link": resourceNetworkDeviceLink(),
"equinix_network_file": resourceNetworkFile(),
"equinix_metal_user_api_key": resourceMetalUserAPIKey(),
"equinix_metal_project_api_key": resourceMetalProjectAPIKey(),
"equinix_metal_device": metal_device.Resource(),
"equinix_metal_device_network_type": resourceMetalDeviceNetworkType(),
"equinix_metal_port": metal_port.Resource(),
"equinix_metal_reserved_ip_block": resourceMetalReservedIPBlock(),
"equinix_metal_ip_attachment": resourceMetalIPAttachment(),
"equinix_metal_spot_market_request": resourceMetalSpotMarketRequest(),
"equinix_metal_virtual_circuit": virtual_circuit.Resource(),
"equinix_metal_vrf": vrf.Resource(),
"equinix_metal_bgp_session": resourceMetalBGPSession(),
"equinix_metal_port_vlan_attachment": resourceMetalPortVlanAttachment(),
},
ProviderMetaSchema: map[string]*schema.Schema{
"module_name": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
data "equinix_fabric_connection_route_filter" "attached_policy" {
connection_id = "<connection_uuid>"
route_filter_id = "<route_filter_uuid>"
}

output "connection_route_filter_id" {
value = data.equinix_fabric_connection_route_filter.attached_policy.id
}

output "connection_route_filter_connection_id" {
value = data.equinix_fabric_connection_route_filter.attached_policy.connection_id
}

output "connection_route_filter_direction" {
value = data.equinix_fabric_connection_route_filter.attached_policy.direction
}

output "connection_route_filter_type" {
value = data.equinix_fabric_connection_route_filter.attached_policy.type
}

output "connection_route_filter_attachment_status" {
value = data.equinix_fabric_connection_route_filter.attached_policy.attachment_status
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
data "equinix_connection_route_filters" "attached_policies" {
connection_id = "<connection_uuid>"
}

output "connection_first_route_filter_uuid" {
value = data.equinix_fabric_connection_route_filter.attached_policies.0.uuid
}

output "connection_first_route_filter_connection_id" {
value = data.equinix_fabric_connection_route_filter.attached_policies.0.connection_id
}

output "connection_first_route_filter_direction" {
value = data.equinix_fabric_connection_route_filter.attached_policies.0.direction
}

output "connection_first_route_filter_type" {
value = data.equinix_fabric_connection_route_filter.attached_policies.0.type
}

output "connection_first_route_filter_attachment_status" {
value = data.equinix_fabric_connection_route_filter.attached_policies.0.attachment_status
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
resource "equinix_fabric_connection_route_filter" "policy_attachment" {
connection_id = "<connection_uuid>"
route_filter_id = "<route_filter_policy_uuid>"
direction = "INBOUND"
}

output "connection_route_filter_id" {
value = equinix_fabric_connection_route_filter.policy_attachment.id
}

output "connection_route_filter_connection_id" {
value = equinix_fabric_connection_route_filter.policy_attachment.connection_id
}

output "connection_route_filter_direction" {
value = equinix_fabric_connection_route_filter.policy_attachment.direction
}

output "connection_route_filter_type" {
value = equinix_fabric_connection_route_filter.policy_attachment.type
}

output "connection_route_filter_attachment_status" {
value = equinix_fabric_connection_route_filter.policy_attachment.attachment_status
}
Loading

0 comments on commit 343c8fc

Please sign in to comment.