Stack drift correction helps ensure consistency between resource configurations and their template definitions. Changes can be synchronized between stack configurations and template definitions.

Background information

You can use one of the following methods to correct drift on a stack:
  • You can update stacks to synchronize resource configurations with their template definitions. For more information, see Update a stack.
  • You can correct templates to synchronize template definitions with the current resource configurations. This topic describes how to correct templates.

Correct templates in the ROS console

  1. Log on to the ROS console.
  2. In the left-side navigation pane, click Stacks.
  3. On the Stacks page, click the ID under the stack name.
  4. Click the Drifts tab.
  5. On the Drifts tab, click Detect Stack Drift.
  6. In the Stack Drift Status section, click Correct.未纠正
    Note The Correct button is displayed only for stacks that have drifted.
  7. In the Drift Correction dialog box, select the resources to be corrected.点击纠正
  8. In the Drift Correction dialog box, click Preview to compare the template content before and after correction.
    The template content before correction is displayed on the left side. The template content after correction is displayed on the right side.Preview
  9. Click OK.
    After the correction is completed, perform a drift detection operation again and view the detection results.After Correction

Correct templates through Alibaba Cloud CLI

You can use the aliyun ros UpdateStackTemplateByResources command through Alibaba Cloud Command Line Interface (Alibaba Cloud CLI) to correct templates. The parameters are the same as those of the UpdateStackTemplateByResources operation. For more information, see UpdateStackTemplateByResources.

$ aliyun ros UpdateStackTemplateByResources --StackId 4334b961-3bfd-419e-9a00-23a95e******
{
    "RequestId": "B288A0BE-D927-4888-B0F7-B35EF84B6E6F",
    "NewTemplateBody": "{\"ROSTemplateFormatVersion\": \"2015-09-01\", \"Resources\": {\"Vpc\": {\"Type\": \"ALIYUN::ECS::VPC\", \"Properties\": {\"VpcName\": \"test\", \"CidrBlock\": \"192.168.0.0/16\", \"Description\": \"test2\"}}}, \"Outputs\": {\"VpcId\": {\"Value\": {\"Fn::GetAtt\": [\"Vpc\", \"VpcId\"]}}}}",
    "OldTemplateBody": "{\"ROSTemplateFormatVersion\": \"2015-09-01\", \"Resources\": {\"Vpc\": {\"Type\": \"ALIYUN::ECS::VPC\", \"Properties\": {\"VpcName\": \"test\", \"CidrBlock\": \"192.168.0.0/16\", \"Description\": \"test1\"}}}, \"Outputs\": {\"VpcId\": {\"Value\": {\"Fn::GetAtt\": [\"Vpc\", \"VpcId\"]}}}}"
}