Correcting stack drift ensures configuration consistency by synchronizing your stack resources with their definitions in the stack template.
Scenarios
If a resource's actual configuration differs from the template, you can correct the drift to align the resource with the template's definition.
Prerequisites
Drift has been detected on the stack. For more information, see Detect stack drift.
Background information
You can correct stack drift by using one of the following methods:
-
Update the stack: This aligns the resources with the template. For more information, see Update a stack.
-
Correct the template: This updates the template to match the actual resource configurations.
Methods
-
ROS console: Allows you to correct the template in the ROS console.
For instructions, see Correct a template in the ROS console.
-
API: Allows you to correct the template by calling an API operation.
For more information, see UpdateStackTemplateByResources.
-
Alibaba Cloud CLI: Allows you to correct the template by running CLI commands.
For instructions, see Correct a template by using the Alibaba Cloud CLI.
Using the ROS console
-
Log in to the ROS console.
-
In the navigation pane on the left, click Stacks.
-
On the Stacks page, click the name of the target stack.
-
Click the Drift tab.
-
On the Drift page, click Detect Stack Drift.
-
In the Stack Drift Status section, click Correct.
NoteThe Correct button appears only for stacks that are in a drifted state.
-
In the Drift Correction dialog box, in the Resource List, select the drifted resources to correct.
-
In the Drift Correction dialog box, click Preview to review the changes to the template.
-
Click OK to apply the correction.
After the correction is complete, run drift detection again to view the results.
Using the Alibaba Cloud CLI
Run the aliyun ros UpdateStackTemplateByResources command to correct a drifted stack template. The command parameters are the same as the parameters for the UpdateStackTemplateByResources API operation. For more information, see UpdateStackTemplateByResources.
$ aliyun ros UpdateStackTemplateByResources --StackId 4334b961-3bfd-419e-9a00-23a95e******