Skip to content

Commit

Permalink
fix: force recreation of VRF if metro or project ID changes (#790)
Browse files Browse the repository at this point in the history
While testing a Terraform module that uses the VRF resource, I ran into
errors during terraform apply because I changed a metro or project ID
variable and Terraform attempted to use my existing VRF rather than
deleting it and recreating one in the correct metro or project.

This updates the `metal_vrf` resource schema so that Terraform will
delete and recreate a VRF if the metro or project ID changes, since
those values cannot be updated for a VRF.

Fixes #652
  • Loading branch information
cprivitere authored Oct 3, 2024
2 parents 03493f8 + 05c6a08 commit b165549
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 26 deletions.
24 changes: 14 additions & 10 deletions docs/resources/metal_vrf.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,24 @@ resource "equinix_metal_virtual_circuit" "example" {
}
```

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

The following arguments are supported:
### Required

* `name` - (Required) User-supplied name of the VRF, unique to the project
* `metro` - (Required) Metro ID or Code where the VRF will be deployed.
* `project_id` - (Required) Project ID where the VRF will be deployed.
* `description` - (Optional) Description of the VRF.
* `local_asn` - (Optional) The 4-byte ASN set on the VRF.
* `ip_ranges` - (Optional) All IPv4 and IPv6 Ranges that will be available to BGP Peers. IPv4 addresses must be /8 or smaller with a minimum size of /29. IPv6 must be /56 or smaller with a minimum size of /64. Ranges must not overlap other ranges within the VRF.
- `metro` (String) Metro ID or Code where the VRF will be deployed
- `name` (String) User-supplied name of the VRF, unique to the project
- `project_id` (String) Project ID where the VRF will be deployed

## Attributes Reference
### Optional

No additional attributes are exported.
- `description` (String) Description of the VRF
- `ip_ranges` (Set of String) All IPv4 and IPv6 Ranges that will be available to BGP Peers. IPv4 addresses must be /8 or smaller with a minimum size of /29. IPv6 must be /56 or smaller with a minimum size of /64. Ranges must not overlap other ranges within the VRF.
- `local_asn` (Number) The 4-byte ASN set on the VRF.

### Read-Only

- `id` (String) The ID of this resource.

## Import

Expand Down
6 changes: 4 additions & 2 deletions internal/resources/metal/vrf/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ func Resource() *schema.Resource {
"metro": {
Type: schema.TypeString,
Required: true,
Description: "Metro Code",
Description: "Metro ID or Code where the VRF will be deployed",
ForceNew: true,
},
"local_asn": {
Type: schema.TypeInt,
Expand All @@ -56,7 +57,8 @@ func Resource() *schema.Resource {
"project_id": {
Type: schema.TypeString,
Required: true,
Description: "Project ID",
Description: "Project ID where the VRF will be deployed",
ForceNew: true,
},
// TODO: created_by, created_at, updated_at, href
},
Expand Down
15 changes: 1 addition & 14 deletions templates/resources/metal_vrf.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,7 @@ Attach a Virtual Circuit from a Dedicated Metal Connection to the Metal Gateway.

{{tffile "examples/resources/equinix_metal_vrf/example_3.tf"}}

## Argument Reference

The following arguments are supported:

* `name` - (Required) User-supplied name of the VRF, unique to the project
* `metro` - (Required) Metro ID or Code where the VRF will be deployed.
* `project_id` - (Required) Project ID where the VRF will be deployed.
* `description` - (Optional) Description of the VRF.
* `local_asn` - (Optional) The 4-byte ASN set on the VRF.
* `ip_ranges` - (Optional) All IPv4 and IPv6 Ranges that will be available to BGP Peers. IPv4 addresses must be /8 or smaller with a minimum size of /29. IPv6 must be /56 or smaller with a minimum size of /64. Ranges must not overlap other ranges within the VRF.

## Attributes Reference

No additional attributes are exported.
{{ .SchemaMarkdown | trimspace }}

## Import

Expand Down

0 comments on commit b165549

Please sign in to comment.