Skip to content

Commit

Permalink
Add support for all_ports to google_compute_forwarding_rule for ILB (#…
Browse files Browse the repository at this point in the history
…297)

<!-- This change is generated by MagicModules. -->
/cc @rileykarson
  • Loading branch information
modular-magician authored and rileykarson committed Jan 2, 2019
1 parent 115c62c commit 8684ac7
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
22 changes: 22 additions & 0 deletions google-beta/resource_compute_forwarding_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ func resourceComputeForwardingRule() *schema.Resource {
ValidateFunc: validation.StringInSlice([]string{"TCP", "UDP", "ESP", "AH", "SCTP", "ICMP", ""}, false),
DiffSuppressFunc: caseDiffSuppress,
},
"all_ports": {
Type: schema.TypeBool,
Optional: true,
ForceNew: true,
},
"backend_service": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -261,6 +266,12 @@ func resourceComputeForwardingRuleCreate(d *schema.ResourceData, meta interface{
} else if v, ok := d.GetOkExists("label_fingerprint"); !isEmptyValue(reflect.ValueOf(labelFingerprintProp)) && (ok || !reflect.DeepEqual(v, labelFingerprintProp)) {
obj["labelFingerprint"] = labelFingerprintProp
}
allPortsProp, err := expandComputeForwardingRuleAllPorts(d.Get("all_ports"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("all_ports"); !isEmptyValue(reflect.ValueOf(allPortsProp)) && (ok || !reflect.DeepEqual(v, allPortsProp)) {
obj["allPorts"] = allPortsProp
}
networkTierProp, err := expandComputeForwardingRuleNetworkTier(d.Get("network_tier"), d, config)
if err != nil {
return err
Expand Down Expand Up @@ -427,6 +438,9 @@ func resourceComputeForwardingRuleRead(d *schema.ResourceData, meta interface{})
if err := d.Set("label_fingerprint", flattenComputeForwardingRuleLabelFingerprint(res["labelFingerprint"], d)); err != nil {
return fmt.Errorf("Error reading ForwardingRule: %s", err)
}
if err := d.Set("all_ports", flattenComputeForwardingRuleAllPorts(res["allPorts"], d)); err != nil {
return fmt.Errorf("Error reading ForwardingRule: %s", err)
}
if err := d.Set("network_tier", flattenComputeForwardingRuleNetworkTier(res["networkTier"], d)); err != nil {
return fmt.Errorf("Error reading ForwardingRule: %s", err)
}
Expand Down Expand Up @@ -668,6 +682,10 @@ func flattenComputeForwardingRuleLabelFingerprint(v interface{}, d *schema.Resou
return v
}

func flattenComputeForwardingRuleAllPorts(v interface{}, d *schema.ResourceData) interface{} {
return v
}

func flattenComputeForwardingRuleNetworkTier(v interface{}, d *schema.ResourceData) interface{} {
return v
}
Expand Down Expand Up @@ -808,6 +826,10 @@ func expandComputeForwardingRuleLabelFingerprint(v interface{}, d *schema.Resour
return v, nil
}

func expandComputeForwardingRuleAllPorts(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v, nil
}

func expandComputeForwardingRuleNetworkTier(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
return v, nil
}
Expand Down
2 changes: 1 addition & 1 deletion google-beta/resource_compute_forwarding_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ resource "google_compute_forwarding_rule" "foobar" {
name = "%s"
load_balancing_scheme = "INTERNAL"
backend_service = "${google_compute_region_backend_service.foobar-bs.self_link}"
ports = ["80"]
all_ports = true
network = "${google_compute_network.foobar.name}"
subnetwork = "%s"
}
Expand Down
6 changes: 6 additions & 0 deletions website/docs/r/compute_forwarding_rule.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,12 @@ The following arguments are supported:
(Optional, [Beta](https://terraform.io/docs/providers/google/provider_versions.html))
Labels to apply to this forwarding rule. A list of key->value pairs.

* `all_ports` -
(Optional, [Beta](https://terraform.io/docs/providers/google/provider_versions.html))
When the load balancing scheme is INTERNAL and protocol is TCP/UDP, omit
`port`/`port_range` and specify this field as `true` to allow packets addressed
to any ports to be forwarded to the backends configured with this forwarding rule.

* `network_tier` -
(Optional)
The networking tier used for configuring this address. This field can
Expand Down

0 comments on commit 8684ac7

Please sign in to comment.