I use Google App Engine standard environemment with Flask Python3 for a current project.
This project use as cache the App Engine Memcache (google.appengine.api.memcache).
Currently the cache doesn’t work and I think that it’s probably because of the dependency on App Engine APIs that need to be enable because when I try to deploy my app (gcloud app deploy) I have this warning: WARNING: There is a dependency on App Engine APIs, but they are not enabled in your app.yaml. Set the app_engine_apis property.
My issue is that when I try to set the dependancy in my app.yaml and deploy, I have then this error: Unexpected attribute 'app_engine_apis' for object of type AppInfoExternal.
I also tried with the exact same yaml file than the Google example: https://github.com/googlecodelabs/migrate-python2-appengine/blob/master/mod12b-memcache/app.yaml, it doesn’t work.
Here the current app.yaml that I’m trying to use:
runtime: python39
env: standard
app_engine_apis: true
resources:
cpu: 2
memory_gb: 4
disk_size_gb: 15
manual_scaling:
instances: 2
This issue is almost the same as this question but I couldn’t use it to solve my problem: How to deal with `app_engine_apis` warning when updating app.yaml from go114 to go115
Thank you for your help.
2
Answers
Your version of gcloud probably means the app_engine_apis are in the beta version and so you have to do
gcloud beta app deploy
Your Google Cloud SDK is outdated. Per the comments in @NoCommandLine‘s answer, your SDK being version 300 is from Jul 2020 whereas the bundled services for 2nd-gen runtimes like Python 3 didn’t go into private preview until Jun 2021. They became generally available in Sep 2021. If you run
gcloud components update
to get the latest SDK (at the time of this post, it’s 410), you should be able to rungcloud app deploy
to deploy a Python 3 App Engine app that can access the Memcache bundled service. TL;DR To use bundled services in Python 3:app_engine_apis: true
toapp.yaml
appengine-python-standard
torequirements.txt
from google.appengine.api import wrap_wsgi_app
app = Flask(__name__); app.wsgi_app = wrap_wsgi_app(app.wsgi_app)
gcloud components update
I recently published a video & codelab (hands-on tutorial) on how to access the bundled services from "Gen2" but realize now I should’ve mentioned updating your SDK, meaning it covers almost all of the instructions above.
:P
For those interested in eventually migrating off Memcache to something more powerful like Redis, I also published content on migrating from Memcache to Cloud Memorystore for Redis, relatively recently as well.