Skip to content

Commit

Permalink
routing zone constraint resource
Browse files Browse the repository at this point in the history
todo:
- resource tests
- constraint data source
- constraints data source
  • Loading branch information
chrismarget-j committed Dec 19, 2024
1 parent 5b05612 commit 76a8f08
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 0 deletions.
1 change: 1 addition & 0 deletions apstra/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,7 @@ func (p *Provider) Resources(_ context.Context) []func() resource.Resource {
func() resource.Resource { return &resourceDatacenterPropertySet{} },
func() resource.Resource { return &resourceDatacenterRack{} },
func() resource.Resource { return &resourceDatacenterRoutingZone{} },
func() resource.Resource { return &resourceDatacenterRoutingZoneConstraint{} },

Check failure on line 631 in apstra/provider.go

View workflow job for this annotation

GitHub Actions / go-tools

undefined: resourceDatacenterRoutingZoneConstraint

Check failure on line 631 in apstra/provider.go

View workflow job for this annotation

GitHub Actions / go-tools

undefined: resourceDatacenterRoutingZoneConstraint
func() resource.Resource { return &resourceDatacenterRoutingPolicy{} },
func() resource.Resource { return &resourceDatacenterSecurityPolicy{} },
func() resource.Resource { return &resourceDatacenterIpLinkAddressing{} },
Expand Down
68 changes: 68 additions & 0 deletions docs/resources/datacenter_routing_zone_constraint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
page_title: "apstra_datacenter_routing_zone_constraint Resource - terraform-provider-apstra"
subcategory: "Reference Design: Datacenter"
description: |-
This resource creates a Routing Zone Constraint within a Datacenter Blueprint.
---

# apstra_datacenter_routing_zone_constraint (Resource)

This resource creates a Routing Zone Constraint within a Datacenter Blueprint.


## Example Usage

```terraform
# This example creates a Routing Zone Constraint which permits exactly one "dev"
# Routing Zone anywhere it is applied.
# First, collect all routing zone IDs in the blueprint
data "apstra_datacenter_routing_zones" "all" {
blueprint_id = local.blueprint_id
}
# Second, collect details about each of those routing zones
data "apstra_datacenter_routing_zone" "all" {
for_each = data.apstra_datacenter_routing_zones.all.ids
blueprint_id = local.blueprint_id
id = each.key
}
# Finally, create the Routing Zone Constraint
resource "apstra_datacenter_routing_zone_constraint" "example" {
blueprint_id = local.blueprint_id
name = "Permit 1 dev RZ"
max_count_constraint = 1
routing_zones_list_constraint = "allow"
# Constraints is created as a list comprehension by iterating over
# details of each RZ in data.apstra_datacenter_routing_zone.all
constraints = [
for rz in data.apstra_datacenter_routing_zone.all : rz.id
if strcontains(rz.name, "dev") // select those with "dev" in their name
]
}
```

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

### Required

- `blueprint_id` (String) Apstra Blueprint ID.
- `name` (String) Name displayed in the Apstra web UI.
- `routing_zones_list_constraint` (String) Instance constraint mode.
- `allow` - only allow the specified routing zones (add specific routing zones to allow)
- `deny` - denies allocation of specified routing zones (add specific routing zones to deny)
- `none` - no additional constraints on routing zones (any routing zones)

### Optional

- `constraints` (Set of String) When `allow` instance constraint mode is chosen, only VNs from selected Routing Zones are allowed to have endpoints on the interface(s) the policy is applied to. The permitted Routing Zones may be specified directly or indirectly (via Routing Zone Groups)
- `max_count_constraint` (Number) The maximum number of Routing Zones that the Application Point can be part of.

### Read-Only

- `id` (String) Apstra graph node ID.



Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This example creates a Routing Zone Constraint which permits exactly one "dev"
# Routing Zone anywhere it is applied.

# First, collect all routing zone IDs in the blueprint
data "apstra_datacenter_routing_zones" "all" {
blueprint_id = local.blueprint_id
}

# Second, collect details about each of those routing zones
data "apstra_datacenter_routing_zone" "all" {
for_each = data.apstra_datacenter_routing_zones.all.ids
blueprint_id = local.blueprint_id
id = each.key
}

# Finally, create the Routing Zone Constraint
resource "apstra_datacenter_routing_zone_constraint" "example" {
blueprint_id = local.blueprint_id
name = "Permit 1 dev RZ"
max_count_constraint = 1
routing_zones_list_constraint = "allow"
# Constraints is created as a list comprehension by iterating over
# details of each RZ in data.apstra_datacenter_routing_zone.all
constraints = [
for rz in data.apstra_datacenter_routing_zone.all : rz.id
if strcontains(rz.name, "dev") // select those with "dev" in their name
]
}

0 comments on commit 76a8f08

Please sign in to comment.