Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_network_function_collector_policy - convert source_resource_ids to a set to prevent ordering issues #27915

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading