diff --git a/google/resource_compute_forwarding_rule.go b/google/resource_compute_forwarding_rule.go index 79c7abc8e7d..bf352d187b0 100644 --- a/google/resource_compute_forwarding_rule.go +++ b/google/resource_compute_forwarding_rule.go @@ -108,10 +108,11 @@ func resourceComputeForwardingRule() *schema.Resource { }, "subnetwork": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Computed: true, + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Computed: true, + DiffSuppressFunc: compareSelfLinkOrResourceName, }, }, } @@ -125,6 +126,11 @@ func resourceComputeForwardingRuleCreate(d *schema.ResourceData, meta interface{ return err } + subnetwork, err := ParseSubnetworkFieldValue(d.Get("subnetwork").(string), d, config) + if err != nil { + return err + } + region, err := getRegion(d, config) if err != nil { return err @@ -151,7 +157,7 @@ func resourceComputeForwardingRuleCreate(d *schema.ResourceData, meta interface{ Network: network.RelativeLink(), PortRange: d.Get("port_range").(string), Ports: ports, - Subnetwork: d.Get("subnetwork").(string), + Subnetwork: subnetwork.RelativeLink(), Target: d.Get("target").(string), } diff --git a/google/resource_compute_forwarding_rule_test.go b/google/resource_compute_forwarding_rule_test.go index 5ceba97e78c..f8065061bd6 100644 --- a/google/resource_compute_forwarding_rule_test.go +++ b/google/resource_compute_forwarding_rule_test.go @@ -242,6 +242,7 @@ resource "google_compute_forwarding_rule" "foobar" { backend_service = "${google_compute_region_backend_service.foobar-bs.self_link}" ports = ["80"] network = "${google_compute_network.foobar.name}" + subnetwork = "%s" } resource "google_compute_forwarding_rule" "foobar2" { description = "Resource created for Terraform acceptance testing" @@ -251,5 +252,5 @@ resource "google_compute_forwarding_rule" "foobar2" { ports = ["80"] network = "${google_compute_network.foobar.self_link}" } -`, serviceName, checkName, networkName, ruleName1, ruleName2) +`, serviceName, checkName, networkName, ruleName1, networkName, ruleName2) }