You can remediate drift on a stack to synchronize the actual configurations of stack resources with the template definitions. This helps ensure the configuration consistency of resources. This topic describes how to remediate drift on a stack in Resource Orchestration Service (ROS).
Scenario
If you detect that the actual configurations of a stack resource are different from the template configurations, you can remediate drift on the stack to ensure configuration consistency of the resource.
Prerequisites
Drift detection is performed on a stack and the stack has drift. For more information, see Detect drift on a stack.
Background information
You can use one of the following methods to remediate drift on a stack:
Method 1: You can update a stack to synchronize resource configurations with their template definitions. For more information, see Update a stack.
Method 2: You can remediate a template to synchronize resource configurations with their template definitions. In this example, Method 2 is used.
Methods to remediate a template
ROS console: You can remediate a template in the ROS console.
For more information, see Remediate a template in the ROS console.
ROS API operation: You can remediate a template by calling a specific ROS API operation.
For more information, see UpdateStackTemplateByResources.
Alibaba Cloud CLI: You can remediate a template by using Alibaba Cloud CLI.
For more information, see Remediate a template by using Alibaba Cloud CLI.
Remediate a template in the ROS console
Log on to the ROS console.
In the left-side navigation pane, click Stacks.
On the Stacks page, find the stack that you want to manage and click the stack ID.
Click the Drifts tab.
On the Drifts tab, click Detect Stack Drift to detect drift on the stack.
In the Stack Drift Status section, click Correct.
NoteCorrect appears only for stacks that have drifted.
In the Drift Correction dialog box, select the resource whose drift you want to remediate.
In the Drift Correction dialog box, click Preview to compare the template content before and after the remediation.
Click OK.
After you remediate the resource, detect drift on the stack again and view the detection results.
Remediate a template by using Alibaba Cloud CLI
You can run the aliyun ros UpdateStackTemplateByResources
command to remediate drift on the template of a stack. To run the command, you must configure parameters that are the same as the parameters of the UpdateStackTemplateByResources operation. For more information, see UpdateStackTemplateByResources.
$ aliyun ros UpdateStackTemplateByResources --StackId 4334b961-3bfd-419e-9a00-23a95e******