Skip to content

Commit

Permalink
convert source_resource_ids to a set to prevent ordering issues (#27915)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephybun authored Dec 11, 2024
1 parent b1623ff commit 357ce22
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (r NetworkFunctionCollectorPolicyResource) Arguments() map[string]*pluginsd
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
"source_resource_ids": {
Type: pluginsdk.TypeList,
Type: pluginsdk.TypeSet,
Required: true,
ForceNew: true,
MinItems: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ import (
"os"
"testing"

"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/go-azure-sdk/resource-manager/networkfunction/2022-11-01/collectorpolicies"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/utils"
)

type NetworkFunctionCollectorPolicyResource struct{}
Expand Down Expand Up @@ -107,12 +106,9 @@ func (r NetworkFunctionCollectorPolicyResource) Exists(ctx context.Context, clie
client := clients.NetworkFunction.CollectorPoliciesClient
resp, err := client.Get(ctx, *id)
if err != nil {
if response.WasNotFound(resp.HttpResponse) {
return utils.Bool(false), nil
}
return nil, fmt.Errorf("retrieving %s: %+v", id, err)
}
return utils.Bool(resp.Model != nil), nil
return pointer.To(resp.Model != nil), nil
}

func (r NetworkFunctionCollectorPolicyResource) template(data acceptance.TestData) string {
Expand Down Expand Up @@ -218,17 +214,30 @@ func (r NetworkFunctionCollectorPolicyResource) complete(data acceptance.TestDat
return fmt.Sprintf(`
%s
resource "azurerm_express_route_circuit" "test2" {
name = "acctest-erc2-%[2]d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
express_route_port_id = azurerm_express_route_port.test.id
bandwidth_in_gbps = 1
sku {
tier = "Standard"
family = "MeteredData"
}
}
resource "azurerm_network_function_collector_policy" "test" {
name = "acctest-nfcp-%d"
location = "%s"
name = "acctest-nfcp-%[2]d"
location = "%[3]s"
traffic_collector_id = azurerm_network_function_azure_traffic_collector.test.id
ipfx_emission {
destination_types = ["AzureMonitor"]
}
ipfx_ingestion {
source_resource_ids = [azurerm_express_route_circuit.test.id]
source_resource_ids = [azurerm_express_route_circuit.test.id, azurerm_express_route_circuit.test2.id]
}
tags = {
Expand All @@ -243,17 +252,30 @@ func (r NetworkFunctionCollectorPolicyResource) update(data acceptance.TestData)
return fmt.Sprintf(`
%s
resource "azurerm_express_route_circuit" "test2" {
name = "acctest-erc2-%[2]d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
express_route_port_id = azurerm_express_route_port.test.id
bandwidth_in_gbps = 1
sku {
tier = "Standard"
family = "MeteredData"
}
}
resource "azurerm_network_function_collector_policy" "test" {
name = "acctest-nfcp-%d"
location = "%s"
name = "acctest-nfcp-%[2]d"
location = "%[3]s"
traffic_collector_id = azurerm_network_function_azure_traffic_collector.test.id
ipfx_emission {
destination_types = ["AzureMonitor"]
}
ipfx_ingestion {
source_resource_ids = [azurerm_express_route_circuit.test.id]
source_resource_ids = [azurerm_express_route_circuit.test.id, azurerm_express_route_circuit.test2.id]
}
tags = {
Expand Down

0 comments on commit 357ce22

Please sign in to comment.