Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for configuring forward proxy in Apigee Environment. #17902

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/10457.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
apigee: added `forward_proxy_uri` field to `google_apigee_environment`
```
32 changes: 32 additions & 0 deletions google/services/apigee/resource_apigee_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ Creating, updating, or deleting target servers. Possible values: ["DEPLOYMENT_TY
ForceNew: true,
Description: `Display name of the environment.`,
},
"forward_proxy_uri": {
Type: schema.TypeString,
Optional: true,
Description: `Optional. URI of the forward proxy to be applied to the runtime instances in this environment. Must be in the format of {scheme}://{hostname}:{port}. Note that the scheme must be one of "http" or "https", and the port must be supplied.`,
},
"node_config": {
Type: schema.TypeList,
Computed: true,
Expand Down Expand Up @@ -194,6 +199,12 @@ func resourceApigeeEnvironmentCreate(d *schema.ResourceData, meta interface{}) e
} else if v, ok := d.GetOkExists("type"); !tpgresource.IsEmptyValue(reflect.ValueOf(typeProp)) && (ok || !reflect.DeepEqual(v, typeProp)) {
obj["type"] = typeProp
}
forwardProxyUriProp, err := expandApigeeEnvironmentForwardProxyUri(d.Get("forward_proxy_uri"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("forward_proxy_uri"); !tpgresource.IsEmptyValue(reflect.ValueOf(forwardProxyUriProp)) && (ok || !reflect.DeepEqual(v, forwardProxyUriProp)) {
obj["forwardProxyUri"] = forwardProxyUriProp
}

url, err := tpgresource.ReplaceVars(d, config, "{{ApigeeBasePath}}{{org_id}}/environments")
if err != nil {
Expand Down Expand Up @@ -312,6 +323,9 @@ func resourceApigeeEnvironmentRead(d *schema.ResourceData, meta interface{}) err
if err := d.Set("type", flattenApigeeEnvironmentType(res["type"], d, config)); err != nil {
return fmt.Errorf("Error reading Environment: %s", err)
}
if err := d.Set("forward_proxy_uri", flattenApigeeEnvironmentForwardProxyUri(res["forwardProxyUri"], d, config)); err != nil {
return fmt.Errorf("Error reading Environment: %s", err)
}

return nil
}
Expand All @@ -338,6 +352,12 @@ func resourceApigeeEnvironmentUpdate(d *schema.ResourceData, meta interface{}) e
} else if v, ok := d.GetOkExists("type"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, typeProp)) {
obj["type"] = typeProp
}
forwardProxyUriProp, err := expandApigeeEnvironmentForwardProxyUri(d.Get("forward_proxy_uri"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("forward_proxy_uri"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, forwardProxyUriProp)) {
obj["forwardProxyUri"] = forwardProxyUriProp
}

url, err := tpgresource.ReplaceVars(d, config, "{{ApigeeBasePath}}{{org_id}}/environments/{{name}}")
if err != nil {
Expand All @@ -355,6 +375,10 @@ func resourceApigeeEnvironmentUpdate(d *schema.ResourceData, meta interface{}) e
if d.HasChange("type") {
updateMask = append(updateMask, "type")
}

if d.HasChange("forward_proxy_uri") {
updateMask = append(updateMask, "forwardProxyUri")
}
// updateMask is a URL parameter but not present in the schema, so ReplaceVars
// won't set it
url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")})
Expand Down Expand Up @@ -546,6 +570,10 @@ func flattenApigeeEnvironmentType(v interface{}, d *schema.ResourceData, config
return v
}

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

func expandApigeeEnvironmentName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
Expand Down Expand Up @@ -614,3 +642,7 @@ func expandApigeeEnvironmentNodeConfigCurrentAggregateNodeCount(v interface{}, d
func expandApigeeEnvironmentType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}

func expandApigeeEnvironmentForwardProxyUri(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
4 changes: 4 additions & 0 deletions website/docs/r/apigee_environment.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ The following arguments are supported:
An Apigee org can support heterogeneous Environments.
Possible values are: `ENVIRONMENT_TYPE_UNSPECIFIED`, `BASE`, `INTERMEDIATE`, `COMPREHENSIVE`.

* `forward_proxy_uri` -
(Optional)
Optional. URI of the forward proxy to be applied to the runtime instances in this environment. Must be in the format of {scheme}://{hostname}:{port}. Note that the scheme must be one of "http" or "https", and the port must be supplied.


<a name="nested_node_config"></a>The `node_config` block supports:

Expand Down