Thursday, February 9, 2023
HomeSoftware DevelopmentMigrating from App Engine Customers to Cloud Id Platform (Module 21)

Migrating from App Engine Customers to Cloud Id Platform (Module 21)



Posted by Wesley Chun (@wescpy), Developer Advocate, Google Cloud

The way to migrate the App Engine Customers to Cloud Id Platform

Understanding the general migration

General, Module 21 options main adjustments to the Module 20 pattern app, implementing a transfer from App Engine bundled providers (NDB & Customers) to standalone Cloud providers (Cloud Datastore & Id Platform). Id Platform would not know something about App Engine admins, in order that should 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 Id 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 challenge’s IAM permit coverage to collate the set of App Engine admin customers for the app.
  • Use the Firebase Admin SDK to validate whether or not the person 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 shopper library slightly than the Useful resource Supervisor shopper library. To learn to arrange the latter, go to the Useful resource Supervisor shopper library documentation instantly. The lower-level shopper library ought to solely be utilized in circumstances when a Cloud shopper 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 providers to standalone Cloud providers

The NDB to Cloud NDB migration is equivalent to the Module 2 migration content material, so it isn’t coated in-depth right here in Module 21. The first focus is on switching to Id Platform to proceed supporting person 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 supplied by the Customers service. Beneath is pseudocode implementing the important thing adjustments to the principle software the place new or up to date traces of code are bolded:

Table showing changes in code 'Before'(Module 20) and 'After'(Module 21)
Migrating from App Engine Customers to Cloud Id Platform(click on to enlarge)

The important thing variations to notice:

  1. The server-side Customers service code vanishes from the principle software, shifting into the (client-side) net template (not proven right here).
  2. Virtually the entire new code within the Module 21 app above is for recognizing App Engine admin customers. There are not any adjustments to app operations or knowledge 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 could be discovered within the Module 20 (Python 2) and Module 21 (Python 3) repo folders, respectively. Along with the video, make sure to take a look at the Id Platform documentation in addition to the Module 21 codelab which leads you step-by-step by means of the migrations mentioned.

Apart from the required coding adjustments in addition to shifting from server-side to client-side, word that the Customers service utilization is roofed by App Engine’s pricing mannequin whereas Id Platform is an impartial Cloud service billed by MAUs (month-to-month energetic customers), so prices must be taken into consideration if migrating. Extra info could be discovered within the Id 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 is no such thing as a present requirement for customers emigrate, builders themselves are expressing curiosity in updating their functions to the newest language releases.
The first Module 21 migration mechanically 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 take a look at the precise part for Python 2 customers in case you’re on this scenario. In the event you do not wish 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 providers to applicable standalone Cloud providers. Whereas we suggest customers modernize their App Engine apps by shifting to the newest choices from Google Cloud, these migrations will not be required. In Fall 2021, the App Engine crew prolonged help of most of the bundled providers to 2nd technology runtimes (which have a 1st technology runtime), which means you do not have emigrate to standalone providers earlier than porting your app to Python 3. You may proceed utilizing App Engine NDB and Customers in Python 3 as long as you retrofit your code to entry bundled providers from next-generation runtimes. Then must you choose emigrate, you are able to do so by yourself timeline.

In the event you’re utilizing different App Engine legacy providers make sure to take a look at the opposite Migration Modules on this collection. All Serverless Migration Station content material (codelabs, movies, supply code [when available]) could be accessed at its open supply repo. Whereas our content material initially focuses on Python customers, the Cloud crew is engaged on protecting different language runtimes, so keep tuned. For added video content material, take a look at our broader Serverless Expeditions collection.



RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments