Create an instant rollback
An instant rollback moves an environment URL, with no rebuild, to the newest successful deployment that was created before the one it serves now. Use it when something is wrong and you need the fastest path back to the last known-good deployment. The change reaches all viewers in about 5 to 10 seconds. Until then, some requests still get the deployment that you rolled back from.
When you roll back, Amplify updates any custom domain that you mapped to the environment.
The deployment you roll back from stays in history, so you can re-promote it once you understand the issue. For instructions on re-promoting a deployment, see Promote a deployment in the console.
AWS CloudTrail records each rollback, including who made it and when. For more information about finding logs, see Which log should I look in? in Monitoring AWS Amplify.
An instant rollback skips any deployment created after the one it serves now, and you don’t specify a deployment ID. To return to a specific deployment, promote it, as described in the section on rolling back to a specific deployment later on this page.
If your app has a backend, a rollback changes only which deployment serves traffic. It doesn’t undo migrations, so your database keeps the schema from the newest deployment that ran them. Test each schema change in a preview environment first.
A deployment applies migrations before it builds the site, so a deployment whose build failed also leaves its schema changes in place. To undo a schema change, deploy a new migration that reverses it. A rollback also brings back the publishable key that the older deployment was built with. If you revoked that key since, your app’s backend requests get 401
invalid_credential until you deploy again. To recover production data as of an earlier time, see Backups and restore.
Create an instant rollback in the console
-
Sign in to the Amplify console at https://us-east-2.console.aws.amazon.com/amplifygen3/home
. -
Choose an app.
-
In the left navigation pane, choose Deployments.
-
Choose the active deployment.
-
For Actions, choose Rollback.
Traffic shifts back to the previous stable deployment in about 5 to 10 seconds.
Create an instant rollback using the CLI
The following CLI command reverts the production environment to its previous stable deployment. You do not need to specify a deployment ID.
aws amplifygen3 rollback --env production
If you omit --env, the command rolls back the preview environment. The command returns an error when there is no previous deployment to roll back to.
Roll back to a specific deployment
To revert to an older deployment rather than the immediately previous one, list the deployments for the environment, and then promote the one you want. When you promote a deployment, Amplify does not rebuild your app.
aws amplifygen3 deployment list --env production aws amplifygen3 deployment promote --id a1b2c3d4e5 --env production
For more information, see Promote a deployment.
Roll back during a gradual rollout
While a gradual rollout is in progress on the environment, aws amplifygen3 rollback fails with exit code 251. To stop the rollout and send all traffic back to the previous deployment, run aws amplifygen3 deployment abort --env <environment> instead. For more information about rollouts, see Gradual deployments.
Limits
Amplify retains the last 50 successful deployments for each environment. An expired deployment can’t be the target of an instant rollback. To restore the version of an expired deployment, create a new deployment. For more information, see Create a new deployment.
Confirm which deployment is serving traffic
After a rollback, you can check which deployment is active for your environment. For more information, see Determine which deployment is serving traffic.