Vra_fabric_network Filtering Not Working As Expected

by ADMIN 53 views

Introduction

In this article, we will discuss an issue with the vra_fabric_network resource in Terraform, where the filtering functionality is not working as expected. This issue is specific to the vra_fabric_network resource and is related to the number of fabric networks visible in vRA.

Background

The vra_fabric_network resource is used to manage fabric networks in vRealize Automation (vRA). The resource allows users to create, read, update, and delete fabric networks. However, in this case, the filtering functionality of the vra_fabric_network resource is not working as expected.

Expected Behavior

The expected behavior of the vra_fabric_network resource is that it should return a single fabric network when the filter is applied. However, in this case, the filter is not returning the expected result.

Actual Behavior

The actual behavior of the vra_fabric_network resource is that it is sometimes returning an error message indicating that the filter did not match any fabric network. This error message is unexpected and is not consistent with the expected behavior of the resource.

Cause of the Issue

The cause of the issue is believed to be related to the number of fabric networks visible in vRA. When there are a large number of fabric networks, the filtering functionality of the vra_fabric_network resource is not working as expected. This is why the issue is only occurring on the PRD platform, which has a large number of fabric networks.

Steps to Reproduce

Unfortunately, it is difficult to provide steps to reproduce this issue, as it requires a large number of fabric networks in vRA. However, the issue is believed to be related to the number of fabric networks visible in vRA.

Important Factoids

This issue is related to filtering GCP networks coming from multiple GCP Cloud Accounts.

Community Note

Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.

Terraform Configuration Files

The following is an example of a Terraform configuration file that demonstrates the issue:

resource "vra_cloud_account_gcp" "slc_hpr" {
  name           = upper(var.slc_hpr_project_id)
  description    = "Cloud Account S3NS LC ${var.chapter} HPR"
  client_email   = var.slc_hpr_client_email
  private_key_id = var.slc_hpr_private_key_id
  private_key    = var.slc_hpr_private_key
  project_id     = var.slc_hpr_project_id
  regions        = [var.slc_region_name]

  tags {
    key   = "CLOUD"
    value = "SLC"
  }
}

data "vra_fabric_network" "hpr_slc_internal_network" {
  filter = "cloudAccountIds.item eq '${resource.vra_cloud_account_gcp.slc_hpr.id}' and name eq '${var.slc_hpr_internal_network_name}'"
}

vRA Version

The vRA version being used is 8.18.1.

Terraform Version

The Terraform version being used is 1.11.1.

vRA Terraform Provider Version

The vRA Terraform provider version being used is 0.12.0.

Affected Resource(s)

The affected resource is the vra_fabric_network resource.

Steps to Resolve the Issue

To resolve this issue, the following steps can be taken:

  1. Check the number of fabric networks visible in vRA and ensure that it is not too large.
  2. Verify that the filter is correctly applied to the vra_fabric_network resource.
  3. Check the Terraform configuration files for any errors or inconsistencies.
  4. Try to reproduce the issue on a DEV vRA instance with a smaller number of fabric networks.

Q: What is the issue with the vra_fabric_network resource?

A: The issue with the vra_fabric_network resource is that the filtering functionality is not working as expected. This means that when a filter is applied to the resource, it is not returning the expected result.

Q: What is the expected behavior of the vra_fabric_network resource?

A: The expected behavior of the vra_fabric_network resource is that it should return a single fabric network when the filter is applied.

Q: What is the actual behavior of the vra_fabric_network resource?

A: The actual behavior of the vra_fabric_network resource is that it is sometimes returning an error message indicating that the filter did not match any fabric network.

Q: What is the cause of the issue?

A: The cause of the issue is believed to be related to the number of fabric networks visible in vRA. When there are a large number of fabric networks, the filtering functionality of the vra_fabric_network resource is not working as expected.

Q: How can I reproduce the issue?

A: Unfortunately, it is difficult to provide steps to reproduce this issue, as it requires a large number of fabric networks in vRA.

Q: What is the relationship between the issue and GCP networks?

A: This issue is related to filtering GCP networks coming from multiple GCP Cloud Accounts.

Q: What can I do to resolve the issue?

A: To resolve this issue, you can try the following steps:

  1. Check the number of fabric networks visible in vRA and ensure that it is not too large.
  2. Verify that the filter is correctly applied to the vra_fabric_network resource.
  3. Check the Terraform configuration files for any errors or inconsistencies.
  4. Try to reproduce the issue on a DEV vRA instance with a smaller number of fabric networks.

Q: What is the Terraform configuration file that demonstrates the issue?

A: The following is an example of a Terraform configuration file that demonstrates the issue:

resource "vra_cloud_account_gcp" "slc_hpr" {
  name           = upper(var.slc_hpr_project_id)
  description    = "Cloud Account S3NS LC ${var.chapter} HPR"
  client_email   = var.slc_hpr_client_email
  private_key_id = var.slc_hpr_private_key_id
  private_key    = var.slc_hpr_private_key
  project_id     = var.slc_hpr_project_id
  regions        = [var.slc_region_name]

  tags {
    key   = "CLOUD"
    value = "SLC"
  }
}

data "vra_fabric_network" "hpr_slc_internal_network" {
  filter = "cloudAccountIds.item eq '${resource.vra_cloud_account_gcp.slc_hpr.id}' and name eq '${var.slc_hpr_internal_network_name}'"
}

Q: What are the vRA and Terraform versions being used?

A: The vRA version being used is 8.18.1, and the Terraform version being used is 1.11.1.

Q: What is the vRA Terraform provider version being used?

A: The vRA Terraform provider version being used is 0.12.0.

Q: What is the affected resource?

A: The affected resource is the vra_fabric_network resource.

Q: What are the steps to resolve the issue?

A: To resolve this issue, you can try the following steps:

  1. Check the number of fabric networks visible in vRA and ensure that it is not too large.
  2. Verify that the filter is correctly applied to the vra_fabric_network resource.
  3. Check the Terraform configuration files for any errors or inconsistencies.
  4. Try to reproduce the issue on a DEV vRA instance with a smaller number of fabric networks.