
Posted by Wesley Chun (@wescpy), Developer Advocate, Google Cloud
The best way to migrate the App Engine Customers to Cloud Identification Platform |
Understanding the general migration
General, Module 21 options main adjustments to the Module 20 pattern app, implementing a transfer from App Engine bundled companies (NDB & Customers) to standalone Cloud companies (Cloud Datastore & Identification Platform). Identification Platform would not know something about App Engine admins, in order that have to be constructed, requiring the usage of the Cloud Useful resource Supervisor API. Apps depending on Python 2 have extra required updates. Let’s talk about in a bit extra element.
Migration “elements”
The next adjustments to the pattern app are required:
Migrate from App Engine Customers (server-side) to Cloud Identification Platform (client-side)
- Migrate from App Engine NDB, the opposite bundled service utilized in Module 20, to Cloud NDB (requires use of the Cloud Datastore API)
- Use the Cloud Useful resource Supervisor* (by way of its API) to fetch the Cloud venture’s IAM enable coverage to collate the set of App Engine admin customers for the app.
- Use the Firebase Admin SDK to validate whether or not the consumer is an App Engine admin
- Migrate from Python 2 to three (and presumably again to Python 2 [more on this below])
*On the time of this writing, the Useful resource Supervisor documentation solely options setup directions for accessing the API from the lower-level Google APIs consumer library somewhat than the Useful resource Supervisor consumer library. To learn to arrange the latter, go to the Useful resource Supervisor consumer library documentation straight. The lower-level consumer library ought to solely be utilized in circumstances when a Cloud consumer library would not exist or would not have the options your app wants. One such use case is Python 2, and we’ll be protecting that shortly.
Transfer from App Engine bundled companies to standalone Cloud companies
The NDB to Cloud NDB migration is similar to the Module 2 migration content material, so it isn’t lined in-depth right here in Module 21. The first focus is on switching to Identification Platform to proceed supporting consumer logins in addition to implementing use of the Useful resource Supervisor and Firebase Admin SDK to construct a proxy for recognizing App Engine admin customers as offered by the Customers service. Under is pseudocode implementing the important thing adjustments to the primary utility the place new or up to date strains of code are bolded:
![]() |
Migrating from App Engine Customers to Cloud Identification Platform(click on to enlarge) |
The important thing variations to notice:
- The server-side Customers service code vanishes from the primary utility, shifting into the (client-side) internet template (not proven right here).
- Virtually all the new code within the Module 21 app above is for recognizing App Engine admin customers. There aren’t any adjustments to app operations or information fashions aside from Cloud NDB requiring use of Python context managers to wrap all Datastore code (utilizing Python with blocks).
Full variations of the app earlier than and after the updates will be discovered within the Module 20 (Python 2) and Module 21 (Python 3) repo folders, respectively. Along with the video, remember to try the Identification Platform documentation in addition to the Module 21 codelab which leads you step-by-step by way of the migrations mentioned.
Apart from the required coding adjustments in addition to shifting from server-side to client-side, notice that the Customers service utilization is roofed by App Engine’s pricing mannequin whereas Identification Platform is an impartial Cloud service billed by MAUs (month-to-month lively customers), so prices must be taken under consideration if migrating. Extra data will be discovered within the Identification Platform pricing documentation.
Python 2 concerns
With the sundown of Python 2, Java 8, PHP 5, and Go 1.11, by their respective communities, Google Cloud has assured customers by expressing continued long-term help of those legacy App Engine runtimes, together with sustaining the Python 2 runtime. So whereas there isn’t any present requirement for customers emigrate, builders themselves are expressing curiosity in updating their functions to the most recent language releases.
The first Module 21 migration routinely features a port from Python 2 to three as that is the place most builders are headed. For these with dependencies requiring remaining on Python 2, some extra effort is required:
The codelab covers this backport in-depth, so try the particular part for Python 2 customers if you happen to’re on this scenario. If you happen to do not need to give it some thought, simply head to the repo for a working Python 2 model of the Module 21 app.
Wrap-up
Module 21 options migrations of App Engine bundled companies to acceptable standalone Cloud companies. Whereas we advocate customers modernize their App Engine apps by shifting to the most recent choices from Google Cloud, these migrations will not be required. In Fall 2021, the App Engine staff prolonged help of lots of the bundled companies to 2nd era runtimes (which have a 1st era runtime), which means you do not have emigrate to standalone companies earlier than porting your app to Python 3. You possibly can proceed utilizing App Engine NDB and Customers in Python 3 as long as you retrofit your code to entry bundled companies from next-generation runtimes. Then do you have to choose emigrate, you are able to do so by yourself timeline.