Skip to content

Commit

Permalink
Add Proxy Bind to Target Proxies (hashicorp#4597) (hashicorp#3061)
Browse files Browse the repository at this point in the history
* mark field as updatable

Co-authored-by: upodroid <[email protected]>

* add proxy_bind

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Mar 16, 2021
1 parent 66e5ed1 commit d57945d
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/4597.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
compute: added `proxy_bind` to `google_compute_target_tcp_proxy`, `google_compute_target_http_proxy` and `google_compute_target_https_proxy`
```
1 change: 1 addition & 0 deletions google-beta/resource_compute_backend_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1512,6 +1512,7 @@ resource "google_compute_target_http_proxy" "default" {
name = "%s"
description = "a description"
url_map = google_compute_url_map.default.self_link
proxy_bind = true
}
resource "google_compute_backend_service" "backend_service" {
Expand Down
25 changes: 25 additions & 0 deletions google-beta/resource_compute_target_http_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ to the BackendService.`,
ForceNew: true,
Description: `An optional description of this resource.`,
},
"proxy_bind": {
Type: schema.TypeBool,
Computed: true,
Optional: true,
ForceNew: true,
Description: `This field only applies when the forwarding rule that references
this target proxy has a loadBalancingScheme set to INTERNAL_SELF_MANAGED.`,
},
"creation_timestamp": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -118,6 +126,12 @@ func resourceComputeTargetHttpProxyCreate(d *schema.ResourceData, meta interface
} else if v, ok := d.GetOkExists("url_map"); !isEmptyValue(reflect.ValueOf(urlMapProp)) && (ok || !reflect.DeepEqual(v, urlMapProp)) {
obj["urlMap"] = urlMapProp
}
proxyBindProp, err := expandComputeTargetHttpProxyProxyBind(d.Get("proxy_bind"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("proxy_bind"); !isEmptyValue(reflect.ValueOf(proxyBindProp)) && (ok || !reflect.DeepEqual(v, proxyBindProp)) {
obj["proxyBind"] = proxyBindProp
}

url, err := replaceVars(d, config, "{{ComputeBasePath}}projects/{{project}}/global/targetHttpProxies")
if err != nil {
Expand Down Expand Up @@ -214,6 +228,9 @@ func resourceComputeTargetHttpProxyRead(d *schema.ResourceData, meta interface{}
if err := d.Set("url_map", flattenComputeTargetHttpProxyUrlMap(res["urlMap"], d, config)); err != nil {
return fmt.Errorf("Error reading TargetHttpProxy: %s", err)
}
if err := d.Set("proxy_bind", flattenComputeTargetHttpProxyProxyBind(res["proxyBind"], d, config)); err != nil {
return fmt.Errorf("Error reading TargetHttpProxy: %s", err)
}
if err := d.Set("self_link", ConvertSelfLinkToV1(res["selfLink"].(string))); err != nil {
return fmt.Errorf("Error reading TargetHttpProxy: %s", err)
}
Expand Down Expand Up @@ -379,6 +396,10 @@ func flattenComputeTargetHttpProxyUrlMap(v interface{}, d *schema.ResourceData,
return ConvertSelfLinkToV1(v.(string))
}

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

func expandComputeTargetHttpProxyDescription(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}
Expand All @@ -394,3 +415,7 @@ func expandComputeTargetHttpProxyUrlMap(v interface{}, d TerraformResourceData,
}
return f.RelativeLink(), nil
}

func expandComputeTargetHttpProxyProxyBind(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}
25 changes: 25 additions & 0 deletions google-beta/resource_compute_target_https_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ to the BackendService.`,
ForceNew: true,
Description: `An optional description of this resource.`,
},
"proxy_bind": {
Type: schema.TypeBool,
Computed: true,
Optional: true,
ForceNew: true,
Description: `This field only applies when the forwarding rule that references
this target proxy has a loadBalancingScheme set to INTERNAL_SELF_MANAGED.`,
},
"quic_override": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -167,6 +175,12 @@ func resourceComputeTargetHttpsProxyCreate(d *schema.ResourceData, meta interfac
} else if v, ok := d.GetOkExists("url_map"); !isEmptyValue(reflect.ValueOf(urlMapProp)) && (ok || !reflect.DeepEqual(v, urlMapProp)) {
obj["urlMap"] = urlMapProp
}
proxyBindProp, err := expandComputeTargetHttpsProxyProxyBind(d.Get("proxy_bind"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("proxy_bind"); !isEmptyValue(reflect.ValueOf(proxyBindProp)) && (ok || !reflect.DeepEqual(v, proxyBindProp)) {
obj["proxyBind"] = proxyBindProp
}

url, err := replaceVars(d, config, "{{ComputeBasePath}}projects/{{project}}/global/targetHttpsProxies")
if err != nil {
Expand Down Expand Up @@ -272,6 +286,9 @@ func resourceComputeTargetHttpsProxyRead(d *schema.ResourceData, meta interface{
if err := d.Set("url_map", flattenComputeTargetHttpsProxyUrlMap(res["urlMap"], d, config)); err != nil {
return fmt.Errorf("Error reading TargetHttpsProxy: %s", err)
}
if err := d.Set("proxy_bind", flattenComputeTargetHttpsProxyProxyBind(res["proxyBind"], d, config)); err != nil {
return fmt.Errorf("Error reading TargetHttpsProxy: %s", err)
}
if err := d.Set("self_link", ConvertSelfLinkToV1(res["selfLink"].(string))); err != nil {
return fmt.Errorf("Error reading TargetHttpsProxy: %s", err)
}
Expand Down Expand Up @@ -561,6 +578,10 @@ func flattenComputeTargetHttpsProxyUrlMap(v interface{}, d *schema.ResourceData,
return ConvertSelfLinkToV1(v.(string))
}

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

func expandComputeTargetHttpsProxyDescription(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}
Expand Down Expand Up @@ -604,3 +625,7 @@ func expandComputeTargetHttpsProxyUrlMap(v interface{}, d TerraformResourceData,
}
return f.RelativeLink(), nil
}

func expandComputeTargetHttpsProxyProxyBind(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}
25 changes: 25 additions & 0 deletions google-beta/resource_compute_target_tcp_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ character, which cannot be a dash.`,
ForceNew: true,
Description: `An optional description of this resource.`,
},
"proxy_bind": {
Type: schema.TypeBool,
Computed: true,
Optional: true,
ForceNew: true,
Description: `This field only applies when the forwarding rule that references
this target proxy has a loadBalancingScheme set to INTERNAL_SELF_MANAGED.`,
},
"proxy_header": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -132,6 +140,12 @@ func resourceComputeTargetTcpProxyCreate(d *schema.ResourceData, meta interface{
} else if v, ok := d.GetOkExists("backend_service"); !isEmptyValue(reflect.ValueOf(serviceProp)) && (ok || !reflect.DeepEqual(v, serviceProp)) {
obj["service"] = serviceProp
}
proxyBindProp, err := expandComputeTargetTcpProxyProxyBind(d.Get("proxy_bind"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("proxy_bind"); !isEmptyValue(reflect.ValueOf(proxyBindProp)) && (ok || !reflect.DeepEqual(v, proxyBindProp)) {
obj["proxyBind"] = proxyBindProp
}

url, err := replaceVars(d, config, "{{ComputeBasePath}}projects/{{project}}/global/targetTcpProxies")
if err != nil {
Expand Down Expand Up @@ -231,6 +245,9 @@ func resourceComputeTargetTcpProxyRead(d *schema.ResourceData, meta interface{})
if err := d.Set("backend_service", flattenComputeTargetTcpProxyBackendService(res["service"], d, config)); err != nil {
return fmt.Errorf("Error reading TargetTcpProxy: %s", err)
}
if err := d.Set("proxy_bind", flattenComputeTargetTcpProxyProxyBind(res["proxyBind"], d, config)); err != nil {
return fmt.Errorf("Error reading TargetTcpProxy: %s", err)
}
if err := d.Set("self_link", ConvertSelfLinkToV1(res["selfLink"].(string))); err != nil {
return fmt.Errorf("Error reading TargetTcpProxy: %s", err)
}
Expand Down Expand Up @@ -434,6 +451,10 @@ func flattenComputeTargetTcpProxyBackendService(v interface{}, d *schema.Resourc
return ConvertSelfLinkToV1(v.(string))
}

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

func expandComputeTargetTcpProxyDescription(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}
Expand All @@ -453,3 +474,7 @@ func expandComputeTargetTcpProxyBackendService(v interface{}, d TerraformResourc
}
return f.RelativeLink(), nil
}

func expandComputeTargetTcpProxyProxyBind(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}
5 changes: 5 additions & 0 deletions website/docs/r/compute_target_http_proxy.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ The following arguments are supported:
(Optional)
An optional description of this resource.

* `proxy_bind` -
(Optional)
This field only applies when the forwarding rule that references
this target proxy has a loadBalancingScheme set to INTERNAL_SELF_MANAGED.

* `project` - (Optional) The ID of the project in which the resource belongs.
If it is not provided, the provider project is used.

Expand Down
5 changes: 5 additions & 0 deletions website/docs/r/compute_target_https_proxy.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ The following arguments are supported:
the TargetHttpsProxy resource. If not set, the TargetHttpsProxy
resource will not have any SSL policy configured.

* `proxy_bind` -
(Optional)
This field only applies when the forwarding rule that references
this target proxy has a loadBalancingScheme set to INTERNAL_SELF_MANAGED.

* `project` - (Optional) The ID of the project in which the resource belongs.
If it is not provided, the provider project is used.

Expand Down
5 changes: 5 additions & 0 deletions website/docs/r/compute_target_tcp_proxy.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ The following arguments are supported:
Default value is `NONE`.
Possible values are `NONE` and `PROXY_V1`.

* `proxy_bind` -
(Optional)
This field only applies when the forwarding rule that references
this target proxy has a loadBalancingScheme set to INTERNAL_SELF_MANAGED.

* `project` - (Optional) The ID of the project in which the resource belongs.
If it is not provided, the provider project is used.

Expand Down

0 comments on commit d57945d

Please sign in to comment.