diff --git a/.changelog/3537.txt b/.changelog/3537.txt new file mode 100644 index 0000000000..f50780546e --- /dev/null +++ b/.changelog/3537.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +appengine: add `inbound_services` to `StandardAppVersion` resource +``` diff --git a/google-beta/resource_app_engine_flexible_app_version.go b/google-beta/resource_app_engine_flexible_app_version.go index 5a481aaea2..c052491fe9 100644 --- a/google-beta/resource_app_engine_flexible_app_version.go +++ b/google-beta/resource_app_engine_flexible_app_version.go @@ -641,12 +641,13 @@ All URLs that begin with this prefix are handled by this handler, using the port }, }, "inbound_services": { - Type: schema.TypeList, + Type: schema.TypeSet, Optional: true, Description: `Before an application can receive email or XMPP messages, the application must be configured to enable the service.`, Elem: &schema.Schema{ Type: schema.TypeString, }, + Set: schema.HashString, }, "instance_class": { Type: schema.TypeString, @@ -1432,7 +1433,10 @@ func flattenAppEngineFlexibleAppVersionVersionId(v interface{}, d *schema.Resour } func flattenAppEngineFlexibleAppVersionInboundServices(v interface{}, d *schema.ResourceData, config *Config) interface{} { - return v + if v == nil { + return v + } + return schema.NewSet(schema.HashString, v.([]interface{})) } func flattenAppEngineFlexibleAppVersionInstanceClass(v interface{}, d *schema.ResourceData, config *Config) interface{} { @@ -2310,6 +2314,7 @@ func expandAppEngineFlexibleAppVersionVersionId(v interface{}, d TerraformResour } func expandAppEngineFlexibleAppVersionInboundServices(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + v = v.(*schema.Set).List() return v, nil } diff --git a/google-beta/resource_app_engine_standard_app_version.go b/google-beta/resource_app_engine_standard_app_version.go index dcbea668e6..cf810ec1d0 100644 --- a/google-beta/resource_app_engine_standard_app_version.go +++ b/google-beta/resource_app_engine_standard_app_version.go @@ -326,6 +326,15 @@ All URLs that begin with this prefix are handled by this handler, using the port }, }, }, + "inbound_services": { + Type: schema.TypeSet, + Optional: true, + Description: `Before an application can receive email or XMPP messages, the application must be configured to enable the service.`, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Set: schema.HashString, + }, "instance_class": { Type: schema.TypeString, Computed: true, @@ -479,6 +488,12 @@ func resourceAppEngineStandardAppVersionCreate(d *schema.ResourceData, meta inte } else if v, ok := d.GetOkExists("entrypoint"); !isEmptyValue(reflect.ValueOf(entrypointProp)) && (ok || !reflect.DeepEqual(v, entrypointProp)) { obj["entrypoint"] = entrypointProp } + inboundServicesProp, err := expandAppEngineStandardAppVersionInboundServices(d.Get("inbound_services"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("inbound_services"); !isEmptyValue(reflect.ValueOf(inboundServicesProp)) && (ok || !reflect.DeepEqual(v, inboundServicesProp)) { + obj["inboundServices"] = inboundServicesProp + } instanceClassProp, err := expandAppEngineStandardAppVersionInstanceClass(d.Get("instance_class"), d, config) if err != nil { return err @@ -594,6 +609,9 @@ func resourceAppEngineStandardAppVersionRead(d *schema.ResourceData, meta interf if err := d.Set("libraries", flattenAppEngineStandardAppVersionLibraries(res["libraries"], d, config)); err != nil { return fmt.Errorf("Error reading StandardAppVersion: %s", err) } + if err := d.Set("inbound_services", flattenAppEngineStandardAppVersionInboundServices(res["inboundServices"], d, config)); err != nil { + return fmt.Errorf("Error reading StandardAppVersion: %s", err) + } if err := d.Set("instance_class", flattenAppEngineStandardAppVersionInstanceClass(res["instanceClass"], d, config)); err != nil { return fmt.Errorf("Error reading StandardAppVersion: %s", err) } @@ -673,6 +691,12 @@ func resourceAppEngineStandardAppVersionUpdate(d *schema.ResourceData, meta inte } else if v, ok := d.GetOkExists("entrypoint"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, entrypointProp)) { obj["entrypoint"] = entrypointProp } + inboundServicesProp, err := expandAppEngineStandardAppVersionInboundServices(d.Get("inbound_services"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("inbound_services"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, inboundServicesProp)) { + obj["inboundServices"] = inboundServicesProp + } instanceClassProp, err := expandAppEngineStandardAppVersionInstanceClass(d.Get("instance_class"), d, config) if err != nil { return err @@ -973,6 +997,13 @@ func flattenAppEngineStandardAppVersionLibrariesVersion(v interface{}, d *schema return v } +func flattenAppEngineStandardAppVersionInboundServices(v interface{}, d *schema.ResourceData, config *Config) interface{} { + if v == nil { + return v + } + return schema.NewSet(schema.HashString, v.([]interface{})) +} + func flattenAppEngineStandardAppVersionInstanceClass(v interface{}, d *schema.ResourceData, config *Config) interface{} { return v } @@ -1573,6 +1604,11 @@ func expandAppEngineStandardAppVersionEntrypointShell(v interface{}, d Terraform return v, nil } +func expandAppEngineStandardAppVersionInboundServices(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + v = v.(*schema.Set).List() + return v, nil +} + func expandAppEngineStandardAppVersionInstanceClass(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { return v, nil } diff --git a/google-beta/resource_app_engine_standard_app_version_test.go b/google-beta/resource_app_engine_standard_app_version_test.go index fadb4523ce..5f6c099830 100644 --- a/google-beta/resource_app_engine_standard_app_version_test.go +++ b/google-beta/resource_app_engine_standard_app_version_test.go @@ -84,6 +84,8 @@ resource "google_app_engine_standard_app_version" "foo" { } } + inbound_services = ["INBOUND_SERVICE_WARMUP", "INBOUND_SERVICE_MAIL"] + env_variables = { port = "8000" } @@ -168,6 +170,8 @@ resource "google_app_engine_standard_app_version" "foo" { } } + inbound_services = [] + env_variables = { port = "8000" } diff --git a/website/docs/r/app_engine_standard_app_version.html.markdown b/website/docs/r/app_engine_standard_app_version.html.markdown index 9fd0bf97a5..01cbc768df 100644 --- a/website/docs/r/app_engine_standard_app_version.html.markdown +++ b/website/docs/r/app_engine_standard_app_version.html.markdown @@ -197,6 +197,10 @@ The `files` block supports: (Optional) The entrypoint for the application. Structure is documented below. +* `inbound_services` - + (Optional) + Before an application can receive email or XMPP messages, the application must be configured to enable the service. + * `instance_class` - (Optional) Instance class that is used to run this version. Valid values are