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 flexibleRuntimeSettings to app engine flexible #18325

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
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,26 @@ the configuration ID. In this case, configId must be omitted.`,
Description: `Environment variables available to the application. As these are not returned in the API request, Terraform will not detect any changes made outside of the Terraform config.`,
Elem: &schema.Schema{Type: schema.TypeString},
},
"flexible_runtime_settings": {
Type: schema.TypeList,
Optional: true,
Description: `Runtime settings for App Engine flexible environment.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"operating_system": {
Type: schema.TypeString,
Optional: true,
Description: `Operating System of the application runtime.`,
},
"runtime_version": {
Type: schema.TypeString,
Optional: true,
Description: `The runtime version of an App Engine flexible application.`,
},
},
},
},
"handlers": {
Type: schema.TypeList,
Computed: true,
Expand Down Expand Up @@ -928,6 +948,12 @@ func resourceAppEngineFlexibleAppVersionCreate(d *schema.ResourceData, meta inte
} else if v, ok := d.GetOkExists("runtime_channel"); !tpgresource.IsEmptyValue(reflect.ValueOf(runtimeChannelProp)) && (ok || !reflect.DeepEqual(v, runtimeChannelProp)) {
obj["runtimeChannel"] = runtimeChannelProp
}
flexibleRuntimeSettingsProp, err := expandAppEngineFlexibleAppVersionFlexibleRuntimeSettings(d.Get("flexible_runtime_settings"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("flexible_runtime_settings"); !tpgresource.IsEmptyValue(reflect.ValueOf(flexibleRuntimeSettingsProp)) && (ok || !reflect.DeepEqual(v, flexibleRuntimeSettingsProp)) {
obj["flexibleRuntimeSettings"] = flexibleRuntimeSettingsProp
}
betaSettingsProp, err := expandAppEngineFlexibleAppVersionBetaSettings(d.Get("beta_settings"), d, config)
if err != nil {
return err
Expand Down Expand Up @@ -1184,6 +1210,9 @@ func resourceAppEngineFlexibleAppVersionRead(d *schema.ResourceData, meta interf
if err := d.Set("runtime_channel", flattenAppEngineFlexibleAppVersionRuntimeChannel(res["runtimeChannel"], d, config)); err != nil {
return fmt.Errorf("Error reading FlexibleAppVersion: %s", err)
}
if err := d.Set("flexible_runtime_settings", flattenAppEngineFlexibleAppVersionFlexibleRuntimeSettings(res["flexibleRuntimeSettings"], d, config)); err != nil {
return fmt.Errorf("Error reading FlexibleAppVersion: %s", err)
}
if err := d.Set("serving_status", flattenAppEngineFlexibleAppVersionServingStatus(res["servingStatus"], d, config)); err != nil {
return fmt.Errorf("Error reading FlexibleAppVersion: %s", err)
}
Expand Down Expand Up @@ -1288,6 +1317,12 @@ func resourceAppEngineFlexibleAppVersionUpdate(d *schema.ResourceData, meta inte
} else if v, ok := d.GetOkExists("runtime_channel"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, runtimeChannelProp)) {
obj["runtimeChannel"] = runtimeChannelProp
}
flexibleRuntimeSettingsProp, err := expandAppEngineFlexibleAppVersionFlexibleRuntimeSettings(d.Get("flexible_runtime_settings"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("flexible_runtime_settings"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, flexibleRuntimeSettingsProp)) {
obj["flexibleRuntimeSettings"] = flexibleRuntimeSettingsProp
}
betaSettingsProp, err := expandAppEngineFlexibleAppVersionBetaSettings(d.Get("beta_settings"), d, config)
if err != nil {
return err
Expand Down Expand Up @@ -1735,6 +1770,29 @@ func flattenAppEngineFlexibleAppVersionRuntimeChannel(v interface{}, d *schema.R
return v
}

func flattenAppEngineFlexibleAppVersionFlexibleRuntimeSettings(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
if v == nil {
return nil
}
original := v.(map[string]interface{})
if len(original) == 0 {
return nil
}
transformed := make(map[string]interface{})
transformed["operating_system"] =
flattenAppEngineFlexibleAppVersionFlexibleRuntimeSettingsOperatingSystem(original["operatingSystem"], d, config)
transformed["runtime_version"] =
flattenAppEngineFlexibleAppVersionFlexibleRuntimeSettingsRuntimeVersion(original["runtimeVersion"], d, config)
return []interface{}{transformed}
}
func flattenAppEngineFlexibleAppVersionFlexibleRuntimeSettingsOperatingSystem(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}

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

func flattenAppEngineFlexibleAppVersionServingStatus(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
Expand Down Expand Up @@ -2642,6 +2700,40 @@ func expandAppEngineFlexibleAppVersionRuntimeChannel(v interface{}, d tpgresourc
return v, nil
}

func expandAppEngineFlexibleAppVersionFlexibleRuntimeSettings(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
l := v.([]interface{})
if len(l) == 0 || l[0] == nil {
return nil, nil
}
raw := l[0]
original := raw.(map[string]interface{})
transformed := make(map[string]interface{})

transformedOperatingSystem, err := expandAppEngineFlexibleAppVersionFlexibleRuntimeSettingsOperatingSystem(original["operating_system"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedOperatingSystem); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["operatingSystem"] = transformedOperatingSystem
}

transformedRuntimeVersion, err := expandAppEngineFlexibleAppVersionFlexibleRuntimeSettingsRuntimeVersion(original["runtime_version"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedRuntimeVersion); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["runtimeVersion"] = transformedRuntimeVersion
}

return transformed, nil
}

func expandAppEngineFlexibleAppVersionFlexibleRuntimeSettingsOperatingSystem(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}

func expandAppEngineFlexibleAppVersionFlexibleRuntimeSettingsRuntimeVersion(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}

func expandAppEngineFlexibleAppVersionBetaSettings(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) {
if v == nil {
return map[string]string{}, nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ resource "google_project_service" "appengineflex" {
service = "appengineflex.googleapis.com"

disable_dependent_services = false
depends_on = [google_project_service.compute]
}

resource "google_compute_network" "network" {
Expand Down Expand Up @@ -142,6 +143,11 @@ resource "google_app_engine_flexible_app_version" "foo" {
shell = "gunicorn -b :$PORT main:app"
}

flexible_runtime_settings {
operating_system = "ubuntu22"
runtime_version = "3.11"
}

deployment {
files {
name = "main.py"
Expand Down Expand Up @@ -234,6 +240,7 @@ resource "google_project_service" "appengineflex" {
service = "appengineflex.googleapis.com"

disable_dependent_services = false
depends_on = [google_project_service.compute]
}

resource "google_compute_network" "network" {
Expand Down Expand Up @@ -309,6 +316,11 @@ resource "google_app_engine_flexible_app_version" "foo" {
shell = "gunicorn -b :$PORT main:app"
}

flexible_runtime_settings {
operating_system = "ubuntu22"
runtime_version = "3.11"
}

deployment {
files {
name = "main.py"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
Flask==1.1.1
Flask==3.0.3; python_version > '3.6'
Flask==2.0.1; python_version < '3.7'
Werkzeug==3.0.3; python_version > '3.6'
Werkzeug==2.0.3; python_version < '3.7'
gunicorn==20.0.4
15 changes: 15 additions & 0 deletions website/docs/r/app_engine_flexible_app_version.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,11 @@ The following arguments are supported:
(Optional)
The channel of the runtime to use. Only available for some runtimes.

* `flexible_runtime_settings` -
(Optional)
Runtime settings for App Engine flexible environment.
Structure is [documented below](#nested_flexible_runtime_settings).

* `beta_settings` -
(Optional)
Metadata settings that are supplied to this version to enable beta runtime features.
Expand Down Expand Up @@ -416,6 +421,16 @@ The following arguments are supported:
(Required)
Volume size in gigabytes.

<a name="nested_flexible_runtime_settings"></a>The `flexible_runtime_settings` block supports:

* `operating_system` -
(Optional)
Operating System of the application runtime.

* `runtime_version` -
(Optional)
The runtime version of an App Engine flexible application.

<a name="nested_handlers"></a>The `handlers` block supports:

* `url_regex` -
Expand Down