Reverting a configuration
During a deployment, you can mitigate situations where malformed or incorrect configuration data causes errors in your application by using automatic rollbacks (if an alarm triggers during a deployment) or by reverting the configuration data to the previous version (if a deployment successfully completed).
For automatic rollbacks, you can use a combination of AWS AppConfig deployment
strategies and Amazon CloudWatch alarms. Once configured, if one or more CloudWatch alarms go into
the ALARM state during a deployment, AWS AppConfig automatically rolls back your
configuration data to the previous version, thereby preventing application outages or errors.
To get started, see Configure permissions for automatic rollback.
Note
You can also roll back a configuration by calling the StopDeployment API operation while a deployment is still in progress.
For deployments that successfully complete, AWS AppConfig also supports reverting configuration
data to a previous version by using the AllowRevert parameter with the StopDeployment API operation. For some customers, reverting to a previous
configuration after a successful deployment guarantees the data will be the same as it was
before the deployment. Reverting also ignores alarm monitors, which may prevent a roll forward
from progressing during an application emergency.
Important
If you call StopDeployment with the AllowRevert parameter
enabled, AWS AppConfig will revert the deployment only if the deployment succeeded within the last
72 hours. After 72 hours, the deployment can no longer be reverted. You must create a new
deployment.
Here's a breakdown of the StopDeployment functionality based on different
situations.
-
If
StopDeploymentis called on an in-progress deployment, the resulting deployment state will beROLLED_BACK. -
If
StopDeployment(withAllowRevert) is called on an in-progress deployment, the resulting deployment state will beROLLED_BACK. -
If
StopDeploymentis called on a completed deployment, aBadRequestExceptionwill be thrown. -
If
StopDeployment(withAllowRevert) is called on a completed deployment, the resulting deployment state will beREVERTED. -
If
StopDeployment(withAllowRevert) is called on a completed deployment after 72 hours, aBadRequestExceptionwill be thrown.
You can use the AWS CLI to call the StopDeploymentAllowRevert parameter. Here's an
example AWS CLI command that includes the AllowRevert parameter.
aws appconfig stop-deployment \ --application-id 339ohji \ --environment-id 54j1r29 \ --deployment-number 2 \ --allow-revert