diff --git a/equinix/resource_metal_virtual_circuit_acc_test.go b/equinix/resource_metal_virtual_circuit_acc_test.go index f379b0fc2..94e9d015f 100644 --- a/equinix/resource_metal_virtual_circuit_acc_test.go +++ b/equinix/resource_metal_virtual_circuit_acc_test.go @@ -129,8 +129,9 @@ func TestAccMetalVirtualCircuit_dedicated(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ // Error: Error waiting for virtual circuit 863d4df5-b3ea-46ee-8497-858cb0cbfcb9 to be created: GET https://api.equinix.com/metal/v1/virtual-circuits/863d4df5-b3ea-46ee-8497-858cb0cbfcb9?include=project%2Cport%2Cvirtual_network%2Cvrf: 500 Oh snap, something went wrong! We've logged the error and will take a look - please reach out to us if you continue having trouble. PreCheck: func() { testAccPreCheck(t) }, ExternalProviders: testExternalProviders, - ProviderFactories: testAccProviderFactories, - CheckDestroy: testAccMetalVirtualCircuitCheckDestroyed, + //ProviderFactories: testAccProviderFactories, + ProtoV5ProviderFactories: testAccProtoV5ProviderFactories, + CheckDestroy: testAccMetalVirtualCircuitCheckDestroyed, Steps: []resource.TestStep{ { Config: testAccMetalConnectionConfig_vc(ri), diff --git a/internal/resources/metal/vlans/datasource_schema.go b/internal/resources/metal/vlans/datasource_schema.go index 86bfccc89..d66024307 100644 --- a/internal/resources/metal/vlans/datasource_schema.go +++ b/internal/resources/metal/vlans/datasource_schema.go @@ -54,8 +54,6 @@ func dataSourceSchema() schema.Schema { }...), }, Description: "Metro where the VLAN is deployed", - // TODO: @aayushrangwala to fix this - //StateFunc: converters.ToLowerIf, }, "vlan_id": schema.StringAttribute{ Optional: true, diff --git a/internal/resources/metal/vlans/models.go b/internal/resources/metal/vlans/models.go index 8b38aea2e..97e10b01a 100644 --- a/internal/resources/metal/vlans/models.go +++ b/internal/resources/metal/vlans/models.go @@ -4,9 +4,11 @@ import ( "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/packethost/packngo" + "strings" ) type DataSourceModel struct { + ID types.String `tfsdk:"id"` ProjectID types.String `tfsdk:"project_id"` VlanID types.String `tfsdk:"vlan_id"` Vxlan types.Int64 `tfsdk:"vxlan"` @@ -16,12 +18,19 @@ type DataSourceModel struct { } func (m *DataSourceModel) parse(vlan *packngo.VirtualNetwork) diag.Diagnostics { + m.ID = types.StringValue(vlan.ID) m.ProjectID = types.StringValue(vlan.Project.ID) m.VlanID = types.StringValue(vlan.ID) m.Facility = types.StringValue(vlan.FacilityCode) - m.Metro = types.StringValue(vlan.MetroCode) m.Description = types.StringValue(vlan.Description) m.Vxlan = types.Int64Value(int64(vlan.VXLAN)) + + // version of this resource. StateFunc doesn't exist in terraform and it requires implementation + // of bespoke logic before storing state. To ensure backward compatibility we ignore lower/upper + // case diff for now, but we may want to require input upper case + if !strings.EqualFold(m.Metro.ValueString(), vlan.MetroCode) { + m.Metro = types.StringValue(vlan.MetroCode) + } return nil } @@ -38,8 +47,14 @@ func (m *ResourceModel) parse(vlan *packngo.VirtualNetwork) diag.Diagnostics { m.ID = types.StringValue(vlan.ID) m.ProjectID = types.StringValue(vlan.Project.ID) m.Facility = types.StringValue(vlan.FacilityCode) - m.Metro = types.StringValue(vlan.MetroCode) m.Description = types.StringValue(vlan.Description) m.Vxlan = types.Int64Value(int64(vlan.VXLAN)) + + // version of this resource. StateFunc doesn't exist in terraform and it requires implementation + // of bespoke logic before storing state. To ensure backward compatibility we ignore lower/upper + // case diff for now, but we may want to require input upper case + if !strings.EqualFold(m.Metro.ValueString(), vlan.MetroCode) { + m.Metro = types.StringValue(vlan.MetroCode) + } return nil } diff --git a/internal/resources/metal/vlans/resource_schema.go b/internal/resources/metal/vlans/resource_schema.go index ee338bd9e..9fd7bbf27 100644 --- a/internal/resources/metal/vlans/resource_schema.go +++ b/internal/resources/metal/vlans/resource_schema.go @@ -15,6 +15,13 @@ import ( func resourceSchema(ctx context.Context) schema.Schema { return schema.Schema{ Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Description: "The unique identifier for this Metal Vlan", + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, "project_id": schema.StringAttribute{ Description: "ID of parent project", Required: true,