Skip to content

Commit

Permalink
This feature enables support for the L4 ILB Flex Ports feature curren…
Browse files Browse the repository at this point in the history
…tly available in alpha.
  • Loading branch information
craigdbarber authored and modular-magician committed Aug 16, 2018
1 parent 81420a2 commit 57e5940
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
22 changes: 22 additions & 0 deletions google/resource_compute_forwarding_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ func resourceComputeForwardingRule() *schema.Resource {
ForceNew: true,
ValidateFunc: validateGCPName,
},
"all_ports": {
Type: schema.TypeBool,
Optional: true,
ForceNew: true,
},
"region": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -267,6 +272,12 @@ func resourceComputeForwardingRuleCreate(d *schema.ResourceData, meta interface{
} else if v, ok := d.GetOkExists("service_label"); !isEmptyValue(reflect.ValueOf(serviceLabelProp)) && (ok || !reflect.DeepEqual(v, serviceLabelProp)) {
obj["serviceLabel"] = serviceLabelProp
}
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
}
regionProp, err := expandComputeForwardingRuleRegion(d.Get("region"), d, config)
if err != nil {
return err
Expand Down Expand Up @@ -422,6 +433,9 @@ func resourceComputeForwardingRuleRead(d *schema.ResourceData, meta interface{})
if err := d.Set("service_name", flattenComputeForwardingRuleServiceName(res["serviceName"])); err != nil {
return fmt.Errorf("Error reading ForwardingRule: %s", err)
}
if err := d.Set("all_ports", flattenComputeForwardingRuleAllPorts(res["allPorts"])); err != nil {
return fmt.Errorf("Error reading ForwardingRule: %s", err)
}
if err := d.Set("region", flattenComputeForwardingRuleRegion(res["region"])); err != nil {
return fmt.Errorf("Error reading ForwardingRule: %s", err)
}
Expand Down Expand Up @@ -667,6 +681,10 @@ func flattenComputeForwardingRuleServiceName(v interface{}) interface{} {
return v
}

func flattenComputeForwardingRuleAllPorts(v interface{}) interface{} {
return v
}

func flattenComputeForwardingRuleRegion(v interface{}) interface{} {
if v == nil {
return v
Expand Down Expand Up @@ -799,6 +817,10 @@ func expandComputeForwardingRuleServiceLabel(v interface{}, d *schema.ResourceDa
return v, nil
}

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

func expandComputeForwardingRuleRegion(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
f, err := parseGlobalFieldValue("regions", v.(string), "project", d, config, true)
if err != nil {
Expand Down
7 changes: 7 additions & 0 deletions website/docs/r/compute_forwarding_rule.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,13 @@ The following arguments are supported:
character, which cannot be a dash.
This field is only used for internal load balancing.

* `all_ports` -
(Optional)
When the load balancing scheme is INTERNAL, this can be used to indicate
that all ports should be supported on the ForwardingRule.
This cannot be used with the ports[] or portRange fields.
This cannot be used when the load balancing scheme is EXTERNAL.

* `region` -
(Optional)
A reference to the region where the regional forwarding rule resides.
Expand Down

0 comments on commit 57e5940

Please sign in to comment.