feat!: remove deprecated Network Edge attributes#1008
Conversation
Remove deprecated attributes from equinix_network_acl_template and equinix_network_device_link resources ahead of the next major release. equinix_network_acl_template: - Remove metro_code attribute (was: Metro Code is no longer required) - Remove device_id computed attribute (replaced by device_details) - Remove inbound_rule.source_type computed attribute (was not returned) - Remove inbound_rule.subnets attribute (replaced by inbound_rule.subnet) - Simplify flattenACLTemplateInboundRules to drop the now-unused existingRules argument and checkExistingSubnets helper - Fix ImportStatePassthrough -> ImportStatePassthroughContext equinix_network_device_link: - Remove link block (replaced by metro_link) - Remove link.src_zone_code attribute (was not required) - Remove link.dst_zone_code attribute (was not required) - Remove associated expand/flatten/hash functions and schema helpers Update example_1.tf for equinix_network_device_link to use metro_link. Regenerate docs via make docs. Co-authored-by: Copilot <[email protected]>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1008 +/- ##
===========================================
+ Coverage 28.72% 41.97% +13.24%
===========================================
Files 252 252
Lines 29225 29079 -146
===========================================
+ Hits 8394 12205 +3811
+ Misses 20677 16378 -4299
- Partials 154 496 +342 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Removes deprecated attributes/blocks from the legacy (SDKv2) Network Edge resources equinix_network_acl_template and equinix_network_device_link in preparation for the next major provider release, with corresponding updates to examples and generated docs.
Changes:
- Dropped deprecated schema attributes from
equinix_network_acl_template(e.g.,metro_code,device_id, inbound rule deprecated fields) and simplified inbound rule flattening. - Dropped deprecated
linkblock fromequinix_network_device_link, leavingmetro_linkas the supported inter/intra-metro connection block. - Updated example + regenerated docs/templates to reflect the new schemas.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| templates/resources/network_device_link.md.tmpl | Removes deprecated link docs section; keeps metro_link docs. |
| templates/resources/network_acl_template.md.tmpl | Removes docs for deprecated ACL template attributes and inbound rule fields. |
| examples/resources/equinix_network_device_link/example_1.tf | Updates example config to use metro_link instead of link. |
| equinix/resource_network_device_link.go | Removes deprecated link schema + expand/flatten helpers; updates update/create/read paths. |
| equinix/resource_network_device_link_test.go | Updates unit tests to stop asserting removed link behavior. |
| equinix/resource_network_acl_template.go | Removes deprecated ACL template schema attributes; simplifies inbound rules flattening; fixes importer to ImportStatePassthroughContext. |
| equinix/resource_network_acl_template_test.go | Updates unit tests to match removed fields and new flatten function signature. |
| docs/resources/network_device_link.md | Regenerated docs reflecting metro_link usage and removal of link. |
| docs/resources/network_acl_template.md | Regenerated docs reflecting removal of deprecated ACL template attributes. |
Comments suppressed due to low confidence (3)
equinix/resource_network_device_link.go:162
metro_linkis aTypeSetbut the schema does not specify aSethash function, while the read/flatten path tries to match existing items vianetworkDeviceLinkMetroLinkHash(...). Without settingSet: networkDeviceLinkMetroLinkHash, the hashes used by Terraform for the set won't match the custom hash used inflattenNetworkDeviceLinkMetroLinks, soaccount_numberlikely won't be carried forward and diffs will persist.
networkDeviceLinkSchemaNames["MetroLinks"]: {
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Resource{
Schema: createNetworkDeviceLinkMetroResourceSchema(),
},
Description: networkDeviceLinkDescriptions["MetroLinks"],
},
equinix/resource_network_device_link.go:527
networkDeviceLinkMetroLinkKeyusesnetworkDeviceLinkConnectionSchemaNames[...]whenvis amap[string]interface{}. That map does not contain a"MetroCode"key (it uses src/dst metro codes), so the computed key/hash will be wrong and break matching of existingmetro_linkitems. UsenetworkDeviceLinkMetroSchemaNames["MetroCode"|"Throughput"|"ThroughputUnit"]for the map case.
func networkDeviceLinkMetroLinkKey(v interface{}) string {
if v, ok := v.(ne.DeviceLinkGroupMetroLink); ok {
return fmt.Sprintf("%s-%s-%s",
ne.StringValue(v.MetroCode),
ne.StringValue(v.Throughput),
ne.StringValue(v.ThroughputUnit))
}
if v, ok := v.(map[string]interface{}); ok {
return fmt.Sprintf("%s-%s-%s",
v[networkDeviceLinkConnectionSchemaNames["MetroCode"]],
v[networkDeviceLinkConnectionSchemaNames["Throughput"]],
v[networkDeviceLinkConnectionSchemaNames["ThroughputUnit"]])
}
equinix/resource_network_acl_template.go:140
inbound_rule.subnetis markedOptional: truein the schema, but the docs/templates in this PR describe it as required (and withsubnetsremoved there's no longer an alternate source definition). Consider makingsubnetrequired to match the documented contract and avoid sending incomplete rules to the API.
networkACLTemplateInboundRuleSchemaNames["Subnet"]: {
Type: schema.TypeString,
Optional: true,
Description: networkACLTemplateInboundRuleDescriptions["Subnet"],
ValidateFunc: validation.IsCIDR,
},
| @@ -171,16 +152,6 @@ | |||
| Set: networkDeviceLinkDeviceHash, | |||
| Description: networkDeviceLinkDescriptions["Device"], | |||
There was a problem hiding this comment.
device schema field pulls its Description from networkDeviceLinkDescriptions["Device"], but the map key is "Devices" (plural). As-is, the description will be empty and docs generation may omit/lose this field description. Use the existing "Devices" key (or rename the map key consistently).
| Description: networkDeviceLinkDescriptions["Device"], | |
| Description: networkDeviceLinkDescriptions["Devices"], |
| var networkDeviceLinkMetroDescriptions = map[string]string{ | ||
| "AccountNumber": "Billing account number to be used for connection charges", | ||
| "metroCode": "Connection source metro code", | ||
| "Throughput": "Connection throughput", | ||
| "ThroughputUnit": "Connection throughput unit", | ||
| } |
There was a problem hiding this comment.
networkDeviceLinkMetroDescriptions defines the metro code description under key "metroCode", but the schema looks up networkDeviceLinkMetroDescriptions["MetroCode"]. This mismatch makes the metro_code field description empty; align the map key with the lookup ("MetroCode").
| if err := d.Set(networkDeviceLinkSchemaNames["Links"], flattenNetworkDeviceLinkConnections(d.Get(networkDeviceLinkSchemaNames["Devices"]).(*schema.Set), link.Links)); err != nil { | ||
| return fmt.Errorf("error setting Links: %s", err) | ||
| } | ||
| if err := d.Set(networkDeviceLinkSchemaNames["MetroLinks"], flattenNetworkDeviceLinkMetroLinks(d.Get(networkDeviceLinkSchemaNames["Devices"]).(*schema.Set), link.MetroLinks)); err != nil { |
There was a problem hiding this comment.
updateNetworkDeviceLinkResource passes the device set into flattenNetworkDeviceLinkMetroLinks(...) as the currentConnections argument. This prevents matching existing metro_link entries (and therefore preserving account_number, which appears to be write-only/not returned), causing persistent diffs and potentially invalid state. Pass the current metro_link set instead (e.g., d.Get(networkDeviceLinkSchemaNames["MetroLinks"]).(*schema.Set)).
| if err := d.Set(networkDeviceLinkSchemaNames["MetroLinks"], flattenNetworkDeviceLinkMetroLinks(d.Get(networkDeviceLinkSchemaNames["Devices"]).(*schema.Set), link.MetroLinks)); err != nil { | |
| if err := d.Set(networkDeviceLinkSchemaNames["MetroLinks"], flattenNetworkDeviceLinkMetroLinks(d.Get(networkDeviceLinkSchemaNames["MetroLinks"]).(*schema.Set), link.MetroLinks)); err != nil { |
|
Ideally this is merged in the same release as #1006 |
|
@rling-equinix these Copilot recommendations were unexpected but seem like they could address long standing bugs (if accurate). You are more familiar with the helpers in use so I defer to your judgement. |
Remove deprecated attributes from
equinix_network_acl_templateandequinix_network_device_linkresources ahead of the next major release.equinix_network_acl_template:metro_codeattribute (was: Metro Code is no longer required)device_id computedattribute (replaced bydevice_details)inbound_rule.source_typecomputed attribute (was not returned)inbound_rule.subnetsattribute (replaced byinbound_rule.subnet)flattenACLTemplateInboundRulesto drop the now-unusedexistingRulesargument andcheckExistingSubnetshelperImportStatePassthrough->ImportStatePassthroughContextequinix_network_device_link:link block(replaced bymetro_link)link.src_zone_codeattribute (was not required)link.dst_zone_codeattribute (was not required)associatedexpand/flatten/hash functions and schema helpersUpdate
example_1.tfforequinix_network_device_linkto usemetro_linkRegenerate docs via
make docs.Co-authored-by: Copilot [email protected]