How to deploy flexible app-engine with python version >3.8 in terraform

I dont see constructs in terraform resource "google_app_engine_flexible_app_version" to specify the below config as suggested in https://cloud.google.com/appengine/docs/flexible/python/runtime. Please help me to deploy flexible appengine using terraform with python version 3.8 and above.

runtime_config:
  operating_system: "ubuntu22"
  runtime_version: "3.12"

0 7 829
7 REPLIES 7

Hi @shaakaud,

Welcome to Google Cloud Community!

Currently, Python 3.12 is still in preview/infancy and may not work as intended based on this release notes. Supported versions are Python 3.8-3.10 based on this documentation.

You may also check this documentation on Python runtime for more information.

Hope this helps.

Hi,

I am ok with python 3.8 as well. There is no constructs in google provider of terraform to deploy flexible appengine with python runtime 3.8. I am able to deploy the same using the gcloud command using the constructs that i mentioned in the description of this case.  Please check the google provider terraform documentation (https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/app_engine_flexible_a...) and let me know how to deploy flexible appengine with runtime python3.8 (NOTE: runtime as "python3.8" fails with the below error:


│ Error: Error creating FlexibleAppVersion: googleapi: Error 400: Error(s) encountered validating runtime. Unknown runtime "python38".

│   with module.rns.module.rns.google_app_engine_flexible_app_version.rns,
│   on ../services/rns/terraform/modules/rns_gae/rns_gae.tf line 26, in resource "google_app_engine_flexible_app_version" "rns":
│   26: resource "google_app_engine_flexible_app_version" "rns" {

Hi @shaakaud,

Please make sure that the indentations are correct in your app.yaml file. It should look like this:

runtime: python
env
: flex
entrypoint
: gunicorn -b :$PORT main:app

runtime_config
:
    operating_system
: "ubuntu22"
    runtime_version
: "3.12"

I would also suggest to file this as a bug through this link so that our engineers could take a look at this. We don't have a specific ETA for this however you can keep track of its progress once the ticket has been created.

Hope this helps.

Hi @robert 

I dont see any issues with app.yaml approach. I am able to bringup flex-appengine on top of 3.11. 

Google provider in terrform has issues. I get error - Error: Error creating FlexibleAppVersion: googleapi: Error 400: Error(s) encountered validating runtime. Unknown runtime "python38". - for the below terraform configuration. If i use runtime=python, it uses python3.7.

resource "google_app_engine_flexible_app_version" "app1" {
version_id = "v1"
project = "gcpproject1"
service = "service1"
runtime = "python38"
....

}

NOTE: This is TERRAFORM google provider issue. app.yaml way does NOT have any issues. There is no equivalent terrform config for "runtime_config" as we do in app.yaml manifest files.

@robertcarlos 

 I'm having this same issue...
The information in the documentation does not work..
If I deploy with the 

runtime_config:
    operating_system: "ubuntu22"
    runtime_version: "3.12"

 

It ignores the values and defaults to Python 2.7

 

 

Step #1: DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at....

@nodata  I've seen this issues before, you probably have a old SDK,  try:

gcloud components update

 

karln

With this app.yaml changes, i was able to bring up flex appegine in 3.11 python. But i am not able to bring up the same using terraform. Are you aware if the terraform constructs are available to bring up flex app-engine with python 3.11 ?