0
0
GCPcloud~5 mins

Revision management in GCP - Commands & Configuration

Choose your learning style9 modes available
Introduction
Revision management helps you keep track of changes in your cloud resources or applications. It lets you save versions so you can go back if something breaks or compare what changed over time.
When you deploy a new version of your app and want to keep the old one safe in case you need to revert.
When you update infrastructure settings and want to track what changed between deployments.
When multiple team members work on the same cloud project and need to see who changed what and when.
When you want to audit changes for security or compliance reasons.
When you want to test new features without affecting the current live version.
Commands
This command lists all deployed versions of your Google App Engine app so you can see the current and past revisions.
Terminal
gcloud app versions list
Expected OutputExpected
SERVICE VERSION TRAFFIC_SPLIT LAST_DEPLOYED SERVING_STATUS default v1 0.00 2024-06-01T12:00:00Z SERVING default v2 1.00 2024-06-02T15:30:00Z SERVING
This command switches traffic back to version v1, effectively rolling back to a previous revision of your app.
Terminal
gcloud app versions migrate v1
Expected OutputExpected
Migrating all traffic to version [v1]...done. You can now access your app at https://PROJECT_ID.REGION_ID.r.appspot.com
This command deletes version v2 of your app to clean up old revisions you no longer need.
Terminal
gcloud app versions delete v2 --quiet
Expected OutputExpected
Deleting version [v2]...done.
--quiet - Skip confirmation prompt to delete version
Key Concept

If you remember nothing else from this pattern, remember: managing app versions lets you safely update, test, and roll back your cloud app.

Common Mistakes
Deleting a version without migrating traffic away from it first
This can cause downtime because the app might still be serving traffic from the deleted version.
Always migrate traffic to a stable version before deleting an old one.
Not listing versions before migrating or deleting
You might try to migrate or delete a version that does not exist or is misspelled.
Run 'gcloud app versions list' first to confirm available versions.
Summary
Use 'gcloud app versions list' to see all deployed app revisions.
Use 'gcloud app versions migrate VERSION' to switch traffic to a specific version.
Use 'gcloud app versions delete VERSION' to remove old versions after migrating traffic.