Promote a deployment
By default, when you create a deployment, the deployment is automatically set as the environment URL. You can turn off automatic promotion of your environment URL for the latest deployment, and then you’ll have to manually promote a deployment. You can also promote a previous deployment to perform an instant rollback of your app. Amplify retains the last 50 successful deployments per environment for instant rollback. Deployments beyond this limit are auto-expired, unless they are actively serving traffic. To see which deployments are serving traffic, see Determine which deployment is serving traffic.
When you manually promote a deployment, Amplify does not rebuild your app.
A promotion takes about 5 to 10 seconds to reach all viewers. Until then, some requests to the environment URL get the promoted deployment and others get the previous one.
If your app has a backend, promoting a deployment changes only which deployment serves the environment URL. It doesn’t undo migrations, so if you promote an older deployment, its code runs against the newest schema. A promoted deployment also keeps the publishable key that it was built with. If you revoked that key since, its backend requests get 401
invalid_credential until you deploy again.
To promote safely, keep each migration compatible with live code: add a column before code reads it, and drop one only after no deployed code uses it. Test schema changes in preview first. For more information, see Tables and migrations.
Promote a deployment in the console
-
Sign in to the Amplify console.
-
Choose an app.
-
In the left navigation pane, choose Deployments.
-
Choose a deployment you want to promote.
-
For Actions, choose Promote to environment URL.
-
Specify the environment, and choose Promote.
Promote a deployment using the CLI
The following CLI command promotes the deployment ID a1b2c3d4e5 to the production environment.
aws amplifygen3 deployment promote --id a1b2c3d4e5 --env production