-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Gateway DNS forwarder datasource
This solution adds a data source for Gateway DNS forwarder, to get DNS forwarders IP if it is created in a different project. Fixes #821. Signed-off-by: Qiyue Yao <[email protected]>
- Loading branch information
Showing
4 changed files
with
85 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* Copyright © 2023 VMware, Inc. All Rights Reserved. | ||
SPDX-License-Identifier: MPL-2.0 */ | ||
|
||
package nsxt | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
func dataSourceNsxtPolicyGatewayDNSForwarder() *schema.Resource { | ||
return &schema.Resource{ | ||
Read: dataSourceNsxtPolicyGatewayDNSForwarderRead, | ||
|
||
Schema: map[string]*schema.Schema{ | ||
"id": getDataSourceIDSchema(), | ||
"display_name": getDataSourceDisplayNameSchema(), | ||
"description": getDataSourceDescriptionSchema(), | ||
"path": getPathSchema(), | ||
"gateway_path": getPolicyPathSchema(false, false, "Gateway path"), | ||
"context": getContextSchema(), | ||
}, | ||
} | ||
} | ||
|
||
func dataSourceNsxtPolicyGatewayDNSForwarderRead(d *schema.ResourceData, m interface{}) error { | ||
connector := getPolicyConnector(m) | ||
|
||
gwPath := d.Get("gateway_path").(string) | ||
query := make(map[string]string) | ||
if len(gwPath) > 0 { | ||
query["parent_path"] = fmt.Sprintf("%s*", gwPath) | ||
} | ||
_, err := policyDataSourceResourceReadWithValidation(d, connector, getSessionContext(d, m), "PolicyDnsForwarder", query, false) | ||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
subcategory: "DNS" | ||
layout: "nsxt" | ||
page_title: "NSXT: policy_gateway_dns_forwarder" | ||
description: A policy gateway DNS forwarder data source. | ||
--- | ||
|
||
# nsxt_policy_gateway_dns_forwarder | ||
|
||
This data source provides information about policy gateways DNS forwarder. | ||
|
||
This data source is applicable to NSX Policy Manager, NSX Global Manager and VMC. | ||
|
||
## Example Usage | ||
|
||
```hcl | ||
data "nsxt_policy_gateway_dns_forwarder" "my_dns_forwarder" { | ||
display_name = "dns-forwarder1" | ||
gateway_path = data.nsxt_policy_tier1_gateway.path | ||
} | ||
``` | ||
|
||
## Argument Reference | ||
|
||
* `gateway_path` - (Required) Path for the gateway. | ||
* `id` - (Optional) The ID of gateway DNS forwarder to retrieve. | ||
* `display_name` - (Optional) The Display Name of the gateway DNS forwarder to retrieve. | ||
* `context` - (Optional) The context which the object belongs to | ||
* `project_id` - (Required) The ID of the project which the object belongs to | ||
|
||
## Attributes Reference | ||
|
||
In addition to arguments listed above, the following attributes are exported: | ||
|
||
* `description` - The description of the resource. | ||
* `path` - The NSX path of the policy resource. |