Migrate your templates to Python 3

Starting on January 1, 2020, the Python community will no longer update, fix bugs, or patch security issues for Python 2.7. We recommend that you make sure that your Deployment Manager templates are compatible with Python 3 as soon as possible.

For an overview of the products affected by this change, including information about using the Google Cloud Python client libraries, see Python support on Google Cloud.

Migrating your Deployment Manager templates

The syntax for Deployment Manager does not use any features specific to Python 3. In most cases, your templates should work with Python 3 without requiring code changes.

If you use template modules such as helper scripts, you must make sure that the scripts are compatible with Python 3.

For information on porting Python 2 code to Python 3, see the Python.org porting guide. If you want to test whether your template is compatible with Python 3, try a test deployment with the template. If the deployment succeeds without any warnings, your template is compatible, and doesn't need changes.

If your templates have features that are incompatible with Python 3, your deployments will continue to work until June 2020. You might see one of these warnings:

  • The template is incompatible with Python 3: The template runs using Python 2, but fails with Python 3. The warning shows the Python 3 error message, so that you can debug your code.

  • The template produced different results with Python 3 and Python 2: This could be because your deployment is non-deterministic (for example, it relies on the current time or random numbers), or a template might be using a feature incompatible with Python 3. If your template is non-deterministic by design, you don't need to change it.

    If your template uses a feature that is incompatible with Python 3, use the guidelines in the Python 3 porting guide to update the template.