You can perform drift detection on a single resource within a stack to determine whether the resource has drifted from the expected configurations in the template.
Prerequisites
Detect drift in the ROS console
- Log on to the ROS console.
- In the left-side navigation pane, click Stacks.
- On the Stacks page, click the ID of the stack that you want to manage.
- Click the Drifts tab.
- In the Resource Drift Status section, click Detect Resource Drift in the Actions column of the resource on which you want to detect drift.
- In the Resource Drift Status section, click View Drift Details in the Actions column of the resource. The physical ID, drift status, type, and last drift detection time of the resource are displayed.
Detect drift by using Alibaba Cloud CLI
You can use Alibaba Cloud CLI to call the DetectStackResourceDrift API operation to detect resource drift. You must specify the stack ID, resource name, and region ID of the stack.
Run the following command in Alibaba Cloud CLI:
aliyun ros DetectStackResourceDrift --StackId a4dffae5-d2a5-4188-b8b5-69dbe8a2**** --LogicalResourceId Vpc --RegionId cn-beijing
Expected output:
{
"LogicalResourceId": "Vpc",
"ResourceDriftStatus": "IN_SYNC",
"RequestId": "7D9AAA7E-F165-5EB8-AFFA-B95A572B9921",
"PhysicalResourceId": "vpc-2zevdu0ktm8tmzry9****",
"ExpectedProperties": "{\"CidrBlock\": \"192.168.0.0/16\", \"VpcName\": \"bff\"}",
"DriftDetectionTime": "2021-10-20T06:13:01",
"ResourceType": "ALIYUN::ECS::VPC",
"ActualProperties": "{\"CidrBlock\": \"192.168.0.0/16\", \"VpcName\": \"bff\"}",
"StackId": "a4dffae5-d2a5-4188-b8b5-69dbe8a2****"
}