Skip to content

Commit 5e68b00

Browse files
Add flexibleRuntimeSettings to app engine flexible (#10795) (#7462)
[upstream:f90b372db39c6098e573f57f83b1be91fcfe9c61] Signed-off-by: Modular Magician <[email protected]>
1 parent dea0d2c commit 5e68b00

File tree

4 files changed

+123
-1
lines changed

4 files changed

+123
-1
lines changed

google-beta/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,
@@ -934,6 +954,12 @@ func resourceAppEngineFlexibleAppVersionCreate(d *schema.ResourceData, meta inte
934954
} else if v, ok := d.GetOkExists("runtime_channel"); !tpgresource.IsEmptyValue(reflect.ValueOf(runtimeChannelProp)) && (ok || !reflect.DeepEqual(v, runtimeChannelProp)) {
935955
obj["runtimeChannel"] = runtimeChannelProp
936956
}
957+
flexibleRuntimeSettingsProp, err := expandAppEngineFlexibleAppVersionFlexibleRuntimeSettings(d.Get("flexible_runtime_settings"), d, config)
958+
if err != nil {
959+
return err
960+
} else if v, ok := d.GetOkExists("flexible_runtime_settings"); !tpgresource.IsEmptyValue(reflect.ValueOf(flexibleRuntimeSettingsProp)) && (ok || !reflect.DeepEqual(v, flexibleRuntimeSettingsProp)) {
961+
obj["flexibleRuntimeSettings"] = flexibleRuntimeSettingsProp
962+
}
937963
betaSettingsProp, err := expandAppEngineFlexibleAppVersionBetaSettings(d.Get("beta_settings"), d, config)
938964
if err != nil {
939965
return err
@@ -1190,6 +1216,9 @@ func resourceAppEngineFlexibleAppVersionRead(d *schema.ResourceData, meta interf
11901216
if err := d.Set("runtime_channel", flattenAppEngineFlexibleAppVersionRuntimeChannel(res["runtimeChannel"], d, config)); err != nil {
11911217
return fmt.Errorf("Error reading FlexibleAppVersion: %s", err)
11921218
}
1219+
if err := d.Set("flexible_runtime_settings", flattenAppEngineFlexibleAppVersionFlexibleRuntimeSettings(res["flexibleRuntimeSettings"], d, config)); err != nil {
1220+
return fmt.Errorf("Error reading FlexibleAppVersion: %s", err)
1221+
}
11931222
if err := d.Set("serving_status", flattenAppEngineFlexibleAppVersionServingStatus(res["servingStatus"], d, config)); err != nil {
11941223
return fmt.Errorf("Error reading FlexibleAppVersion: %s", err)
11951224
}
@@ -1294,6 +1323,12 @@ func resourceAppEngineFlexibleAppVersionUpdate(d *schema.ResourceData, meta inte
12941323
} else if v, ok := d.GetOkExists("runtime_channel"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, runtimeChannelProp)) {
12951324
obj["runtimeChannel"] = runtimeChannelProp
12961325
}
1326+
flexibleRuntimeSettingsProp, err := expandAppEngineFlexibleAppVersionFlexibleRuntimeSettings(d.Get("flexible_runtime_settings"), d, config)
1327+
if err != nil {
1328+
return err
1329+
} else if v, ok := d.GetOkExists("flexible_runtime_settings"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, flexibleRuntimeSettingsProp)) {
1330+
obj["flexibleRuntimeSettings"] = flexibleRuntimeSettingsProp
1331+
}
12971332
betaSettingsProp, err := expandAppEngineFlexibleAppVersionBetaSettings(d.Get("beta_settings"), d, config)
12981333
if err != nil {
12991334
return err
@@ -1747,6 +1782,29 @@ func flattenAppEngineFlexibleAppVersionRuntimeChannel(v interface{}, d *schema.R
17471782
return v
17481783
}
17491784

1785+
func flattenAppEngineFlexibleAppVersionFlexibleRuntimeSettings(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1786+
if v == nil {
1787+
return nil
1788+
}
1789+
original := v.(map[string]interface{})
1790+
if len(original) == 0 {
1791+
return nil
1792+
}
1793+
transformed := make(map[string]interface{})
1794+
transformed["operating_system"] =
1795+
flattenAppEngineFlexibleAppVersionFlexibleRuntimeSettingsOperatingSystem(original["operatingSystem"], d, config)
1796+
transformed["runtime_version"] =
1797+
flattenAppEngineFlexibleAppVersionFlexibleRuntimeSettingsRuntimeVersion(original["runtimeVersion"], d, config)
1798+
return []interface{}{transformed}
1799+
}
1800+
func flattenAppEngineFlexibleAppVersionFlexibleRuntimeSettingsOperatingSystem(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1801+
return v
1802+
}
1803+
1804+
func flattenAppEngineFlexibleAppVersionFlexibleRuntimeSettingsRuntimeVersion(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1805+
return v
1806+
}
1807+
17501808
func flattenAppEngineFlexibleAppVersionServingStatus(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
17511809
return v
17521810
}
@@ -2665,6 +2723,40 @@ func expandAppEngineFlexibleAppVersionRuntimeChannel(v interface{}, d tpgresourc
26652723
return v, nil
26662724
}
26672725

2726+
func expandAppEngineFlexibleAppVersionFlexibleRuntimeSettings(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
2727+
l := v.([]interface{})
2728+
if len(l) == 0 || l[0] == nil {
2729+
return nil, nil
2730+
}
2731+
raw := l[0]
2732+
original := raw.(map[string]interface{})
2733+
transformed := make(map[string]interface{})
2734+
2735+
transformedOperatingSystem, err := expandAppEngineFlexibleAppVersionFlexibleRuntimeSettingsOperatingSystem(original["operating_system"], d, config)
2736+
if err != nil {
2737+
return nil, err
2738+
} else if val := reflect.ValueOf(transformedOperatingSystem); val.IsValid() && !tpgresource.IsEmptyValue(val) {
2739+
transformed["operatingSystem"] = transformedOperatingSystem
2740+
}
2741+
2742+
transformedRuntimeVersion, err := expandAppEngineFlexibleAppVersionFlexibleRuntimeSettingsRuntimeVersion(original["runtime_version"], d, config)
2743+
if err != nil {
2744+
return nil, err
2745+
} else if val := reflect.ValueOf(transformedRuntimeVersion); val.IsValid() && !tpgresource.IsEmptyValue(val) {
2746+
transformed["runtimeVersion"] = transformedRuntimeVersion
2747+
}
2748+
2749+
return transformed, nil
2750+
}
2751+
2752+
func expandAppEngineFlexibleAppVersionFlexibleRuntimeSettingsOperatingSystem(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
2753+
return v, nil
2754+
}
2755+
2756+
func expandAppEngineFlexibleAppVersionFlexibleRuntimeSettingsRuntimeVersion(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
2757+
return v, nil
2758+
}
2759+
26682760
func expandAppEngineFlexibleAppVersionBetaSettings(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) {
26692761
if v == nil {
26702762
return map[string]string{}, nil

google-beta/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)