Skip to content

Commit

Permalink
feat: Route filter rules (#787)
Browse files Browse the repository at this point in the history
* Addition of:
   * data equinix_fabric_route_filter_rule
   * data equinix_fabric_route_filter_rules
   * equinix_fabric_route_filter_rule
* Includes testing and documentation
* Fixes typo for equinix_fabric_route_filter examples and docs
  • Loading branch information
thogarty authored Oct 1, 2024
1 parent 33aff72 commit 03493f8
Show file tree
Hide file tree
Showing 18 changed files with 1,227 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/data-sources/fabric_route_filter.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ output "state" {
}
output "not_matched_rules_action" {
value = data.equinix_fabric_route_filter.rf_policy.not_matched_rules_action
value = data.equinix_fabric_route_filter.rf_policy.not_matched_rule_action
}
output "connections_count" {
Expand Down
87 changes: 87 additions & 0 deletions docs/data-sources/fabric_route_filter_rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
---
subcategory: "Fabric"
---

# equinix_fabric_route_filter_rule (Data Source)

Fabric V4 API compatible data resource that allow user to fetch route filter for a given UUID

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_route_filter_rule" "rf_rule" {
route_filter_id = "<route_filter_policy_id>"
uuid = "<route_filter_rule_uuid>"
}
output "route_filter_rule_name" {
value = data.equinix_fabric_route_filter_rule.rf_rule.name
}
output "route_filter_rule_description" {
value = data.equinix_fabric_route_filter_rule.rf_rule.description
}
output "route_filter_rule_prefix" {
value = data.equinix_fabric_route_filter_rule.rf_rule.prefix
}
output "route_filter_rule_prefix_match" {
value = data.equinix_fabric_route_filter_rule.rf_rule.prefix_match
}
```

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

### Required

- `route_filter_id` (String) UUID of the Route Filter Policy the rule is attached to
- `uuid` (String) Equinix Assigned ID for Route Filter Rule to retrieve data for

### Read-Only

- `action` (String) Action that will be taken on IP Addresses matching the rule
- `change` (Set of Object) An object with the details of the previous change applied on the Route Filter (see [below for nested schema](#nestedatt--change))
- `change_log` (Set of Object) (see [below for nested schema](#nestedatt--change_log))
- `description` (String) Optional description to add to the Route Filter you will be creating
- `href` (String) Route filter rules URI
- `id` (String) The ID of this resource.
- `name` (String) Name of the Route Filter
- `prefix` (String) IP Address Prefix to Filter on
- `prefix_match` (String) Prefix matching operator. One of [ orlonger, exact ] Default: "orlonger"
- `state` (String) State of the Route Filter Rule in its lifecycle
- `type` (String) Route Filter Type. One of [ BGP_IPv4_PREFIX_FILTER_RULE, BGP_IPv6_PREFIX_FILTER_RULE ]

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

Read-Only:

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


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

Read-Only:

- `created_by` (String)
- `created_by_email` (String)
- `created_by_full_name` (String)
- `created_date_time` (String)
- `deleted_by` (String)
- `deleted_by_email` (String)
- `deleted_by_full_name` (String)
- `deleted_date_time` (String)
- `updated_by` (String)
- `updated_by_email` (String)
- `updated_by_full_name` (String)
- `updated_date_time` (String)
113 changes: 113 additions & 0 deletions docs/data-sources/fabric_route_filter_rules.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
---
subcategory: "Fabric"
---

# equinix_fabric_route_filter_rules (Data Source)

Fabric V4 API compatible data resource that allow user to fetch route filter for a given search data set

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_route_filter_rules" "rf_rules" {
route_filter_id = "<route_filter_policy_id"
limit = 100
offset = 5
}
output "first_route_filter_rule_name" {
value = data.equinix_fabric_route_filter_rules.rf_rules.data.0.name
}
output "first_route_filter_rule_description" {
value = data.equinix_fabric_route_filter_rules.rf_rules.data.0.description
}
output "first_route_filter_rule_prefix" {
value = data.equinix_fabric_route_filter_rules.rf_rules.data.0.prefix
}
output "first_route_filter_rule_prefix_match" {
value = data.equinix_fabric_route_filter_rules.rf_rules.data.0.prefix_match
}
```

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

### Required

- `route_filter_id` (String) UUID of the Route Filter Policy the rule is attached to

### Optional

- `limit` (Number) Number of elements to be requested per page. Number must be between 1 and 100. Default is 20
- `offset` (Number) The page offset for the pagination request. Index of the first element. Default is 0.

### 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:

- `action` (String)
- `change` (Set of Object) (see [below for nested schema](#nestedobjatt--data--change))
- `change_log` (Set of Object) (see [below for nested schema](#nestedobjatt--data--change_log))
- `description` (String)
- `href` (String)
- `name` (String)
- `prefix` (String)
- `prefix_match` (String)
- `state` (String)
- `type` (String)
- `uuid` (String)

<a id="nestedobjatt--data--change"></a>
### Nested Schema for `data.change`

Read-Only:

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


<a id="nestedobjatt--data--change_log"></a>
### Nested Schema for `data.change_log`

Read-Only:

- `created_by` (String)
- `created_by_email` (String)
- `created_by_full_name` (String)
- `created_date_time` (String)
- `deleted_by` (String)
- `deleted_by_email` (String)
- `deleted_by_full_name` (String)
- `deleted_date_time` (String)
- `updated_by` (String)
- `updated_by_email` (String)
- `updated_by_full_name` (String)
- `updated_date_time` (String)



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

Read-Only:

- `limit` (Number)
- `next` (String)
- `offset` (Number)
- `previous` (String)
- `total` (Number)
2 changes: 1 addition & 1 deletion docs/resources/fabric_route_filter.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ output "state" {
}
output "not_matched_rules_action" {
value = equinix_fabric_route_filter.rf_policy.not_matched_rules_action
value = equinix_fabric_route_filter.rf_policy.not_matched_rule_action
}
output "connections_count" {
Expand Down
104 changes: 104 additions & 0 deletions docs/resources/fabric_route_filter_rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
---
subcategory: "Fabric"
---

# equinix_fabric_route_filter_rule (Resource)

Fabric V4 API compatible resource allows creation and management of Equinix Fabric Route Filter Rule

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
resource "equinix_fabric_route_filter_rule" "rf_rule" {
route_filter_id = "<route_filter_policy_id>"
name = "Route Filter Rule Name"
prefix = "192.168.0.0/24"
prefix_match = "exact"
description = "Route Filter Rule for X Purpose"
}
output "route_filter_rule_id" {
value = equinix_fabric_route_filter_rule.rf_rule.id
}
output "route_filter_id" {
value = equinix_fabric_route_filter_rule.rf_rule.route_filter_id
}
output "route_filter_rule_prefix" {
value = equinix_fabric_route_filter_rule.rf_rule.prefix
}
output "route_filter_rule_prefix_match" {
value = equinix_fabric_route_filter_rule.rf_rule.prefix_match
}
```

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

### Required

- `prefix` (String) IP Address Prefix to Filter on
- `route_filter_id` (String) UUID of the Route Filter Policy to apply this Rule to

### Optional

- `description` (String) Optional description to add to the Route Filter you will be creating
- `name` (String) Name of the Route Filter
- `prefix_match` (String) Prefix matching operator. One of [ orlonger, exact ] Default: "orlonger"
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))

### Read-Only

- `action` (String) Action that will be taken on IP Addresses matching the rule
- `change` (Set of Object) An object with the details of the previous change applied on the Route Filter (see [below for nested schema](#nestedatt--change))
- `change_log` (Set of Object) (see [below for nested schema](#nestedatt--change_log))
- `href` (String) Route filter rules URI
- `id` (String) The ID of this resource.
- `state` (String) State of the Route Filter Rule in its lifecycle
- `type` (String) Route Filter Type. One of [ BGP_IPv4_PREFIX_FILTER_RULE, BGP_IPv6_PREFIX_FILTER_RULE ]
- `uuid` (String) Equinix Assigned ID for Route Filter Rule

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

Optional:

- `create` (String)
- `delete` (String)
- `read` (String)
- `update` (String)


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

Read-Only:

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


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

Read-Only:

- `created_by` (String)
- `created_by_email` (String)
- `created_by_full_name` (String)
- `created_date_time` (String)
- `deleted_by` (String)
- `deleted_by_email` (String)
- `deleted_by_full_name` (String)
- `deleted_date_time` (String)
- `updated_by` (String)
- `updated_by_email` (String)
- `updated_by_full_name` (String)
- `updated_date_time` (String)
4 changes: 4 additions & 0 deletions equinix/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
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"
fabric_route_filter_rule "github.com/equinix/terraform-provider-equinix/internal/resources/fabric/route_filter_rule"
metal_device "github.com/equinix/terraform-provider-equinix/internal/resources/metal/device"
metal_port "github.com/equinix/terraform-provider-equinix/internal/resources/metal/port"
"github.com/equinix/terraform-provider-equinix/internal/resources/metal/virtual_circuit"
Expand Down Expand Up @@ -94,6 +95,8 @@ func Provider() *schema.Provider {
"equinix_fabric_ports": dataSourceFabricGetPortsByName(),
"equinix_fabric_route_filter": fabric_route_filter.DataSource(),
"equinix_fabric_route_filters": fabric_route_filter.DataSourceSearch(),
"equinix_fabric_route_filter_rule": fabric_route_filter_rule.DataSource(),
"equinix_fabric_route_filter_rules": fabric_route_filter_rule.DataSourceGetAllRules(),
"equinix_fabric_service_profile": dataSourceFabricServiceProfileReadByUuid(),
"equinix_fabric_service_profiles": dataSourceFabricSearchServiceProfilesByName(),
"equinix_network_account": dataSourceNetworkAccount(),
Expand Down Expand Up @@ -123,6 +126,7 @@ func Provider() *schema.Provider {
"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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ output "state" {
}

output "not_matched_rules_action" {
value = data.equinix_fabric_route_filter.rf_policy.not_matched_rules_action
value = data.equinix_fabric_route_filter.rf_policy.not_matched_rule_action
}

output "connections_count" {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
data "equinix_fabric_route_filter_rule" "rf_rule" {
route_filter_id = "<route_filter_policy_id>"
uuid = "<route_filter_rule_uuid>"
}

output "route_filter_rule_name" {
value = data.equinix_fabric_route_filter_rule.rf_rule.name
}


output "route_filter_rule_description" {
value = data.equinix_fabric_route_filter_rule.rf_rule.description
}

output "route_filter_rule_prefix" {
value = data.equinix_fabric_route_filter_rule.rf_rule.prefix
}

output "route_filter_rule_prefix_match" {
value = data.equinix_fabric_route_filter_rule.rf_rule.prefix_match
}
Loading

0 comments on commit 03493f8

Please sign in to comment.