diff --git a/examples/data-sources/spectrocloud_privatecloudgateway_dns_map/datasource.tf b/examples/data-sources/spectrocloud_privatecloudgateway_dns_map/datasource.tf index 67b600dd..baf9df63 100644 --- a/examples/data-sources/spectrocloud_privatecloudgateway_dns_map/datasource.tf +++ b/examples/data-sources/spectrocloud_privatecloudgateway_dns_map/datasource.tf @@ -3,9 +3,9 @@ data "spectrocloud_private_cloud_gateway" "gateway" { } data "spectrocloud_privatecloudgateway_dns_map" "gateway_dns_map" { - search_domain_name = "spectrocloud.dev" + search_domain_name = "spectrocloud.com" # Option to filter with network, if more than one dns map in same search_domain_name. - # network = "VM-NETWORK" + network = "VM-NETWORK2" private_cloud_gateway_id = data.spectrocloud_private_cloud_gateway.gateway.id } diff --git a/spectrocloud/data_source_pcg_dns_map.go b/spectrocloud/data_source_pcg_dns_map.go index b22bb344..4fe5d63b 100644 --- a/spectrocloud/data_source_pcg_dns_map.go +++ b/spectrocloud/data_source_pcg_dns_map.go @@ -57,11 +57,17 @@ func dataSourceDNSMapRead(_ context.Context, d *schema.ResourceData, m interface matchDNSMap := &models.V1VsphereDNSMappings{} for _, dnsMap := range DNSMappings.Items { if name == *dnsMap.Spec.DNSName { - matchDNSMap.Items = append(matchDNSMap.Items, dnsMap) + if network != "" { + if network == *dnsMap.Spec.Network { + matchDNSMap.Items = append(matchDNSMap.Items, dnsMap) + } + } else { + matchDNSMap.Items = append(matchDNSMap.Items, dnsMap) + } } } if len(matchDNSMap.Items) == 0 { - err := fmt.Errorf("error: No DNS Map identified for name `%s`. Kindly re-try with up valid `name`", name) + err := fmt.Errorf("error: No DNS Map identified for name `%s` and network `%s`. Kindly re-try with up valid `name` and `network`", name, network) return diag.FromErr(err) } else if len(matchDNSMap.Items) == 1 { err := setBackDNSMap(matchDNSMap.Items[0], d)