Skip to content

Commit 6c4ae8c

Browse files
Add flexibleRuntimeSettings to app engine flexible (#10795) (#18325)
[upstream:f90b372db39c6098e573f57f83b1be91fcfe9c61] Signed-off-by: Modular Magician <magic-modules@google.com>
1 parent 588cfca commit 6c4ae8c

File tree

4 files changed

+123
-1
lines changed

4 files changed

+123
-1
lines changed

google/services/appengine/resource_app_engine_flexible_app_version.go

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,26 @@ the configuration ID. In this case, configId must be omitted.`,
546546
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.`,
547547
Elem: &schema.Schema{Type: schema.TypeString},
548548
},
549+
"flexible_runtime_settings": {
550+
Type: schema.TypeList,
551+
Optional: true,
552+
Description: `Runtime settings for App Engine flexible environment.`,
553+
MaxItems: 1,
554+
Elem: &schema.Resource{
555+
Schema: map[string]*schema.Schema{
556+
"operating_system": {
557+
Type: schema.TypeString,
558+
Optional: true,
559+
Description: `Operating System of the application runtime.`,
560+
},
561+
"runtime_version": {
562+
Type: schema.TypeString,
563+
Optional: true,
564+
Description: `The runtime version of an App Engine flexible application.`,
565+
},
566+
},
567+
},
568+
},
549569
"handlers": {
550570
Type: schema.TypeList,
551571
Computed: true,
@@ -928,6 +948,12 @@ func resourceAppEngineFlexibleAppVersionCreate(d *schema.ResourceData, meta inte
928948
} else if v, ok := d.GetOkExists("runtime_channel"); !tpgresource.IsEmptyValue(reflect.ValueOf(runtimeChannelProp)) && (ok || !reflect.DeepEqual(v, runtimeChannelProp)) {
929949
obj["runtimeChannel"] = runtimeChannelProp
930950
}
951+
flexibleRuntimeSettingsProp, err := expandAppEngineFlexibleAppVersionFlexibleRuntimeSettings(d.Get("flexible_runtime_settings"), d, config)
952+
if err != nil {
953+
return err
954+
} else if v, ok := d.GetOkExists("flexible_runtime_settings"); !tpgresource.IsEmptyValue(reflect.ValueOf(flexibleRuntimeSettingsProp)) && (ok || !reflect.DeepEqual(v, flexibleRuntimeSettingsProp)) {
955+
obj["flexibleRuntimeSettings"] = flexibleRuntimeSettingsProp
956+
}
931957
betaSettingsProp, err := expandAppEngineFlexibleAppVersionBetaSettings(d.Get("beta_settings"), d, config)
932958
if err != nil {
933959
return err
@@ -1184,6 +1210,9 @@ func resourceAppEngineFlexibleAppVersionRead(d *schema.ResourceData, meta interf
11841210
if err := d.Set("runtime_channel", flattenAppEngineFlexibleAppVersionRuntimeChannel(res["runtimeChannel"], d, config)); err != nil {
11851211
return fmt.Errorf("Error reading FlexibleAppVersion: %s", err)
11861212
}
1213+
if err := d.Set("flexible_runtime_settings", flattenAppEngineFlexibleAppVersionFlexibleRuntimeSettings(res["flexibleRuntimeSettings"], d, config)); err != nil {
1214+
return fmt.Errorf("Error reading FlexibleAppVersion: %s", err)
1215+
}
11871216
if err := d.Set("serving_status", flattenAppEngineFlexibleAppVersionServingStatus(res["servingStatus"], d, config)); err != nil {
11881217
return fmt.Errorf("Error reading FlexibleAppVersion: %s", err)
11891218
}
@@ -1288,6 +1317,12 @@ func resourceAppEngineFlexibleAppVersionUpdate(d *schema.ResourceData, meta inte
12881317
} else if v, ok := d.GetOkExists("runtime_channel"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, runtimeChannelProp)) {
12891318
obj["runtimeChannel"] = runtimeChannelProp
12901319
}
1320+
flexibleRuntimeSettingsProp, err := expandAppEngineFlexibleAppVersionFlexibleRuntimeSettings(d.Get("flexible_runtime_settings"), d, config)
1321+
if err != nil {
1322+
return err
1323+
} else if v, ok := d.GetOkExists("flexible_runtime_settings"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, flexibleRuntimeSettingsProp)) {
1324+
obj["flexibleRuntimeSettings"] = flexibleRuntimeSettingsProp
1325+
}
12911326
betaSettingsProp, err := expandAppEngineFlexibleAppVersionBetaSettings(d.Get("beta_settings"), d, config)
12921327
if err != nil {
12931328
return err
@@ -1735,6 +1770,29 @@ func flattenAppEngineFlexibleAppVersionRuntimeChannel(v interface{}, d *schema.R
17351770
return v
17361771
}
17371772

1773+
func flattenAppEngineFlexibleAppVersionFlexibleRuntimeSettings(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1774+
if v == nil {
1775+
return nil
1776+
}
1777+
original := v.(map[string]interface{})
1778+
if len(original) == 0 {
1779+
return nil
1780+
}
1781+
transformed := make(map[string]interface{})
1782+
transformed["operating_system"] =
1783+
flattenAppEngineFlexibleAppVersionFlexibleRuntimeSettingsOperatingSystem(original["operatingSystem"], d, config)
1784+
transformed["runtime_version"] =
1785+
flattenAppEngineFlexibleAppVersionFlexibleRuntimeSettingsRuntimeVersion(original["runtimeVersion"], d, config)
1786+
return []interface{}{transformed}
1787+
}
1788+
func flattenAppEngineFlexibleAppVersionFlexibleRuntimeSettingsOperatingSystem(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1789+
return v
1790+
}
1791+
1792+
func flattenAppEngineFlexibleAppVersionFlexibleRuntimeSettingsRuntimeVersion(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1793+
return v
1794+
}
1795+
17381796
func flattenAppEngineFlexibleAppVersionServingStatus(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
17391797
return v
17401798
}
@@ -2642,6 +2700,40 @@ func expandAppEngineFlexibleAppVersionRuntimeChannel(v interface{}, d tpgresourc
26422700
return v, nil
26432701
}
26442702

2703+
func expandAppEngineFlexibleAppVersionFlexibleRuntimeSettings(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
2704+
l := v.([]interface{})
2705+
if len(l) == 0 || l[0] == nil {
2706+
return nil, nil
2707+
}
2708+
raw := l[0]
2709+
original := raw.(map[string]interface{})
2710+
transformed := make(map[string]interface{})
2711+
2712+
transformedOperatingSystem, err := expandAppEngineFlexibleAppVersionFlexibleRuntimeSettingsOperatingSystem(original["operating_system"], d, config)
2713+
if err != nil {
2714+
return nil, err
2715+
} else if val := reflect.ValueOf(transformedOperatingSystem); val.IsValid() && !tpgresource.IsEmptyValue(val) {
2716+
transformed["operatingSystem"] = transformedOperatingSystem
2717+
}
2718+
2719+
transformedRuntimeVersion, err := expandAppEngineFlexibleAppVersionFlexibleRuntimeSettingsRuntimeVersion(original["runtime_version"], d, config)
2720+
if err != nil {
2721+
return nil, err
2722+
} else if val := reflect.ValueOf(transformedRuntimeVersion); val.IsValid() && !tpgresource.IsEmptyValue(val) {
2723+
transformed["runtimeVersion"] = transformedRuntimeVersion
2724+
}
2725+
2726+
return transformed, nil
2727+
}
2728+
2729+
func expandAppEngineFlexibleAppVersionFlexibleRuntimeSettingsOperatingSystem(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
2730+
return v, nil
2731+
}
2732+
2733+
func expandAppEngineFlexibleAppVersionFlexibleRuntimeSettingsRuntimeVersion(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
2734+
return v, nil
2735+
}
2736+
26452737
func expandAppEngineFlexibleAppVersionBetaSettings(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) {
26462738
if v == nil {
26472739
return map[string]string{}, nil

google/services/appengine/resource_app_engine_flexible_app_version_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ resource "google_project_service" "appengineflex" {
6767
service = "appengineflex.googleapis.com"
6868
6969
disable_dependent_services = false
70+
depends_on = [google_project_service.compute]
7071
}
7172
7273
resource "google_compute_network" "network" {
@@ -142,6 +143,11 @@ resource "google_app_engine_flexible_app_version" "foo" {
142143
shell = "gunicorn -b :$PORT main:app"
143144
}
144145
146+
flexible_runtime_settings {
147+
operating_system = "ubuntu22"
148+
runtime_version = "3.11"
149+
}
150+
145151
deployment {
146152
files {
147153
name = "main.py"
@@ -234,6 +240,7 @@ resource "google_project_service" "appengineflex" {
234240
service = "appengineflex.googleapis.com"
235241
236242
disable_dependent_services = false
243+
depends_on = [google_project_service.compute]
237244
}
238245
239246
resource "google_compute_network" "network" {
@@ -309,6 +316,11 @@ resource "google_app_engine_flexible_app_version" "foo" {
309316
shell = "gunicorn -b :$PORT main:app"
310317
}
311318
319+
flexible_runtime_settings {
320+
operating_system = "ubuntu22"
321+
runtime_version = "3.11"
322+
}
323+
312324
deployment {
313325
files {
314326
name = "main.py"
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
Flask==1.1.1
1+
Flask==3.0.3; python_version > '3.6'
2+
Flask==2.0.1; python_version < '3.7'
3+
Werkzeug==3.0.3; python_version > '3.6'
4+
Werkzeug==2.0.3; python_version < '3.7'
25
gunicorn==20.0.4

website/docs/r/app_engine_flexible_app_version.html.markdown

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,11 @@ The following arguments are supported:
264264
(Optional)
265265
The channel of the runtime to use. Only available for some runtimes.
266266

267+
* `flexible_runtime_settings` -
268+
(Optional)
269+
Runtime settings for App Engine flexible environment.
270+
Structure is [documented below](#nested_flexible_runtime_settings).
271+
267272
* `beta_settings` -
268273
(Optional)
269274
Metadata settings that are supplied to this version to enable beta runtime features.
@@ -416,6 +421,16 @@ The following arguments are supported:
416421
(Required)
417422
Volume size in gigabytes.
418423

424+
<a name="nested_flexible_runtime_settings"></a>The `flexible_runtime_settings` block supports:
425+
426+
* `operating_system` -
427+
(Optional)
428+
Operating System of the application runtime.
429+
430+
* `runtime_version` -
431+
(Optional)
432+
The runtime version of an App Engine flexible application.
433+
419434
<a name="nested_handlers"></a>The `handlers` block supports:
420435

421436
* `url_regex` -

0 commit comments

Comments
 (0)