Skip to content

Commit

Permalink
enable google_dns_managed_zone to accept network id for two attributes (
Browse files Browse the repository at this point in the history
#3602) (#6533)

* enable google_dns_managed_zone to accept network id for two attributes

* updated doc to include supporting id along with fully qualified url

* enable google_dns_managed_zone to accept network id for two attributes

Co-authored-by: Edward Sun <sunedward@google.com>
Signed-off-by: Modular Magician <magic-modules@google.com>

Co-authored-by: Edward Sun <sunedward@google.com>
  • Loading branch information
modular-magician and Edward Sun authored Jun 4, 2020
1 parent 70ab548 commit 0c36aa3
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 20 deletions.
3 changes: 3 additions & 0 deletions .changelog/3602.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
enable google_dns_managed_zone to accept network id for two attributes
```
36 changes: 28 additions & 8 deletions google/resource_dns_managed_zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"log"
"reflect"
"strconv"
"strings"
"time"

"github.com/hashicorp/terraform-plugin-sdk/helper/hashcode"
Expand Down Expand Up @@ -190,10 +191,11 @@ zone. The value of this field contains the network to peer with.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"network_url": {
Type: schema.TypeString,
Required: true,
Description: `The fully qualified URL of the VPC network to forward queries to.
This should be formatted like
Type: schema.TypeString,
Required: true,
DiffSuppressFunc: compareSelfLinkOrResourceName,
Description: `The id or fully qualified URL of the VPC network to forward queries to.
This should be formatted like 'projects/{project}/global/networks/{network}' or
'https://www.googleapis.com/compute/v1/projects/{project}/global/networks/{network}'`,
},
},
Expand Down Expand Up @@ -271,8 +273,8 @@ func dnsManagedZonePrivateVisibilityConfigNetworksSchema() *schema.Resource {
Type: schema.TypeString,
Required: true,
DiffSuppressFunc: compareSelfLinkOrResourceName,
Description: `The fully qualified URL of the VPC network to bind to.
This should be formatted like
Description: `The id or fully qualified URL of the VPC network to bind to.
This should be formatted like 'projects/{project}/global/networks/{network}' or
'https://www.googleapis.com/compute/v1/projects/{project}/global/networks/{network}'`,
},
},
Expand Down Expand Up @@ -960,7 +962,16 @@ func expandDNSManagedZonePrivateVisibilityConfigNetworks(v interface{}, d Terraf
}

func expandDNSManagedZonePrivateVisibilityConfigNetworksNetworkUrl(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
if v == nil || v.(string) == "" {
return "", nil
} else if strings.HasPrefix(v.(string), "https://") {
return v, nil
}
url, err := replaceVars(d, config, "{{ComputeBasePath}}"+v.(string))
if err != nil {
return "", err
}
return ConvertSelfLinkToV1(url), nil
}

func expandDNSManagedZoneForwardingConfig(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
Expand Down Expand Up @@ -1059,5 +1070,14 @@ func expandDNSManagedZonePeeringConfigTargetNetwork(v interface{}, d TerraformRe
}

func expandDNSManagedZonePeeringConfigTargetNetworkNetworkUrl(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
if v == nil || v.(string) == "" {
return "", nil
} else if strings.HasPrefix(v.(string), "https://") {
return v, nil
}
url, err := replaceVars(d, config, "{{ComputeBasePath}}"+v.(string))
if err != nil {
return "", err
}
return ConvertSelfLinkToV1(url), nil
}
8 changes: 4 additions & 4 deletions google/resource_dns_managed_zone_generated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ resource "google_dns_managed_zone" "private-zone" {
private_visibility_config {
networks {
network_url = google_compute_network.network-1.self_link
network_url = google_compute_network.network-1.id
}
networks {
network_url = google_compute_network.network-2.self_link
network_url = google_compute_network.network-2.id
}
}
}
Expand Down Expand Up @@ -158,13 +158,13 @@ resource "google_dns_managed_zone" "peering-zone" {
private_visibility_config {
networks {
network_url = google_compute_network.network-source.self_link
network_url = google_compute_network.network-source.id
}
}
peering_config {
target_network {
network_url = google_compute_network.network-target.self_link
network_url = google_compute_network.network-target.id
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions website/docs/r/dns_managed_zone.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ resource "google_dns_managed_zone" "private-zone" {
private_visibility_config {
networks {
network_url = google_compute_network.network-1.self_link
network_url = google_compute_network.network-1.id
}
networks {
network_url = google_compute_network.network-2.self_link
network_url = google_compute_network.network-2.id
}
}
}
Expand Down Expand Up @@ -156,13 +156,13 @@ resource "google_dns_managed_zone" "peering-zone" {
private_visibility_config {
networks {
network_url = google_compute_network.network-source.self_link
network_url = google_compute_network.network-source.id
}
}
peering_config {
target_network {
network_url = google_compute_network.network-target.self_link
network_url = google_compute_network.network-target.id
}
}
}
Expand Down Expand Up @@ -358,8 +358,8 @@ The `networks` block supports:

* `network_url` -
(Required)
The fully qualified URL of the VPC network to bind to.
This should be formatted like
The id or fully qualified URL of the VPC network to bind to.
This should be formatted like `projects/{project}/global/networks/{network}` or
`https://www.googleapis.com/compute/v1/projects/{project}/global/networks/{network}`

The `forwarding_config` block supports:
Expand Down Expand Up @@ -398,8 +398,8 @@ The `target_network` block supports:

* `network_url` -
(Required)
The fully qualified URL of the VPC network to forward queries to.
This should be formatted like
The id or fully qualified URL of the VPC network to forward queries to.
This should be formatted like `projects/{project}/global/networks/{network}` or
`https://www.googleapis.com/compute/v1/projects/{project}/global/networks/{network}`

## Attributes Reference
Expand Down

0 comments on commit 0c36aa3

Please sign in to comment.