# Detecting Drift

LLMS index: [llms.txt](https://docs.e.samsungsdscloud.com/en/userguide/management/llms.txt)

---

Users can use drift detection to verify that the deployed stack definition matches the actual state of the resources.

# Managing Stack Drift {#stack}

You can detect, review, and resolve drift in resources managed by the stack.

## Detecting Stack Drift {#detect}

You can detect whether the actual state of the resources managed by the stack differs from the template definition.
To detect stack drift, follow these steps.

1. Click the **All Services > Management > Infrastructure Builder** menu. Navigates to the **Service Home** page.
2. On the **Service Home** page, click the **Stacks > Stack List** menu. Navigates to the **Stack List** page.
3. On the **Stack List** page, click the stack to detect drift. Navigates to the **Stack Details** page.
4. On the **Stack Details** page, click the **Drift Detection** button. A confirmation popup is displayed.
    * You can also select **Drift Detection** from the stack's More (⋮) menu on the **Stack List** page.
5. Click the **Confirm** button in the popup. Drift detection begins, and you can check the results in the notification at the top right of the screen upon completion.
6. After detection is complete, check the results in the **Drift Status** area at the top of the **Stack Details** page.

| Category | Detailed Description |
|---------|--------|
| Drift state | Drift status of the entire stack <ul><li>**In Sync**: The state of the actual resource matches the template definition </li></ul><ul><li>**Drifted**: The state of the actual resource differs from the template definition </li></ul><ul><li>**Not Checked**: Not verified because drift detection has not been run </li></ul><ul><li>**Unknown**: Drift status cannot be determined </li></ul> |
| Drift duration | The time when drift detection was last executed. <ul><li>Not displayed in the Not Checked state. </li></ul><ul><li>Hover over the time to display a tooltip. </li></ul> |

_Table. Stack drift status items_


> **Reference**
>
> * Drift detection can be run when the stack state is Create Completed, Update Completed, Update Rollback Completed, Update Rollback Failed, or Delete Failed.
> * Drift status is determined based on the time when detection is executed. After making changes to resources, run drift detection again to check the latest state.

## View drift details {#detail}

You can check which resources have detected drift and which properties differ.
To view drift details, follow these steps.

1. Click the **All Services > Management > Infrastructure Builder** menu. Navigates to the **Service Home** page.
2. On the **Service Home** page, click the **Stacks > Stack List** menu. Navigates to the **Stack List** page.
3. Click a stack on the **Stack List** page. Navigates to the **Stack Details** page.
4. On the **Stack Details** page, click the **Drift** tab.
    * Only resources that currently support drift detection are available in the **Drift** tab. View all stack resources in the **Resources** tab.
5. Check the drift status for each resource.

| Category | Detailed Description |
|---------|--------|
| Logical ID | The name of the resource defined in the template |
| Physical ID | The unique ID of the resource that was actually created |
| Service | Service to which the resource belongs |
| Resource Type | Resource Types |
| Resource Drift Status | Drift status of the resource<ul><li>**Modified**: The expected and actual attribute values differ (drift details available)</li></ul><ul><li>**Deleted**: The resource itself has been deleted</li></ul><ul><li>**In Sync**: The expected and actual configurations match</li></ul><ul><li>**Not Checked**: Drift has not been checked</li></ul><ul><li>**Unknown**: The status cannot be determined</li></ul><ul><li>**Unsupported**: Drift detection is not supported for this resource</li></ul> |
| Drift check time | Time drift was detected |
| Drift Cause | Causes of drift |

_Table. Resource drift items_

    * You can search by logical ID and physical ID. You can specify conditions by logical ID, physical ID, service, resource type, resource drift status, drift check time, and drift reason in **Detailed Search**.
6. Select **Resource Drift Details** from the More (⋮) menu for the resource where drift was detected. The **Resource Drift Details** popup is displayed.
    * You can view detailed information only for resources whose resource drift status is Modified.
7. Check the differences in the popup.

| Category | Detailed Description |
|---------|--------|
| Property | Properties where the template definition differs from the actual state |
| Change | Change Type |
| Expected value | Values defined in the template |
| Current Value | The value configured on the actual resource |

_Table. Drift difference items_

    * Selecting a property in the difference list allows you to compare and verify the corresponding difference in the **Expected** and **Current** areas.

The change types are as follows.


| Change Type | Description | Display |
|---------|--------|--------|
| Add | When a value is added to an array or list-type property (for example, when an additional inbound rule is added to a security group) | Green |
| Remove | If the property is removed from the current resource configuration | Red |
| Not Equal | When a value exists but differs from the expected value (for example, when the instance type changes from s1v2m2 to s1v2m4) | Blue |

_Table. Drift change types_


## Detecting resource drift {#resource}

You can detect drift for specific resources rather than the entire stack.
To detect resource drift, follow these steps.

1. Click the **All Services > Management > Infrastructure Builder** menu. Navigates to the **Service Home** page.
2. On the **Service Home** page, click the **Stacks > Stack List** menu. Navigates to the **Stack List** page.
3. Click a stack on the **Stack List** page. Navigates to the **Stack Details** page.
4. On the **Stack Details** page, click the **Drift** tab.
5. Select **Resource Drift Detection** from the More options (⋮) menu of the resource to detect drift. A confirmation popup is displayed.
6. Click the **Confirm** button in the popup. Detection begins, and a success message is displayed upon completion.

## Resolving Drift {#resolve}

If drift is detected, you can align the definition with the actual state.

There are two ways to resolve drift: Select based on whether the direct changes are intentional.


| Category | Detailed Description |
|---------|--------|
| Align the actual state with the template | Redeploy the resources according to the template definition. <ul><li>Any direct changes are reverted to the template definition. </li></ul><ul><li>Generate and run a change set based on the existing template. </li></ul> |
| Align the template with the actual state | Modify the template to match the actual state of the resource<ul><li>Use this when the direct changes are intentional</li></ul><ul><li>After modifying the template, create and run a change set</li></ul><ul><li>Resources may be replaced depending on the modified properties, so verify whether the change set involves replacements before running it</li></ul> |

_Table. How to resolve drift_


To resolve drift, follow these steps.

1. Check which properties of which resources differ in the drift details.
2. After determining the resolution method, modify the template as needed.
3. Create a change set to review the changes.
    * For more information about creating change sets, see [Creating a Change Set](/en/userguide/management/infrastructure_builder/how_to_guides/change_set/#create).
4. After reviewing the change type and deployment verification results, run the change set.
5. Rerun drift detection and verify that the status changes to **In Sync**.

> **Warning**: To resolve drift, run the change set to revert the settings you directly modified to the template definition. Before running, review the change types to ensure that no unintended resources are modified or replaced.

# Managing Stack Set Drift {#stack-set}

You can detect drift in stack instances within a stack set and review the results.

## Detecting stack set drift {#stack-set-detect}

You can detect drift in stack instances within a stack set.
To detect drift in a stack set, follow these steps.

1. Click the **All Services > Management > Infrastructure Builder** menu. Navigates to the **Service Home** page.
2. On the **Service Home** page, click the **Stack Set > Stack Set List** menu. Go to the **Stack Set List** page.
3. On the **Stack Set List** page, click the stack set for which you want to detect drift. Navigates to the **Stack Set Details** page.
4. On the **Stack Set Details** page, click the **Drift Detection** button. A confirmation popup is displayed.
5. Click the **Confirm** button in the popup. Drift detection begins, and you can check the results in the notification at the top right of the screen upon completion.
6. After detection is complete, check the drift status of the entire stack set in the **Drift Status** area at the top of the **Stack Set Details** page.
7. Check the Account and region-specific drift status on the **Stack Instances** tab.

| Category | Detailed Description |
|---------|--------|
| Account ID | The account where the stack instance is deployed |
| Legion | The region where the stack instance is deployed |
| Stack ID | The ID of the stack instance |
| Deployment Status | Deployment status of the stack instance |
| Last request ID | The ID of the last operation request performed on the stack instance |
| Status Reason | Reason for deployment status |
| Drift state | Drift status of stack instances |
| Drift check time | Time drift was detected |

_Table. Stack instance drift items_


> **Reference**: To view the details of a stack instance, log in to the account where the stack instance is deployed, navigate to the corresponding region, and select the stack.

## Check the stack set drift results {#stack-set-result}

You can review the results of the drift detection task for the stack set and the drift details for each resource.
To review the drift results of a stack set, follow these steps.

1. Click the **All Services > Management > Infrastructure Builder** menu. Navigates to the **Service Home** page.
2. On the **Service Home** page, click the **Stack Set > Stack Set List** menu. Go to the **Stack Set List** page.
3. On the **Stack Set List** page, click the stack set. Navigates to the **Stack Set Details** page.
4. Click the **Work Requests** tab, then select **Stack Set Drift Information** from the More (⋮) menu for the Detect Drifted work request.
    * This option is available only when the job status is Detect Drifted.
5. Check the detection results in the **Stack Set Drift Information** popup.

| Category | Detailed Description |
|---------|--------|
| Work Request Status | Status of the drift detection job |
| Drift state | Drift status of the entire stack set |
| Drift check time | Time drift was detected |
| Confirmed instances and drift results | The number of total instances, in-progress instances, failed stack instances, instances being synchronized, and drifted instances |

_Table. Stack set drift information items_

6. To check for resource drift per stack instance, select **Stack Instance Operation Results** from the More (⋮) menu of the operation request.
7. Click the **View Resource Drift Results** button for the stack instance in the **Stack Instance Operation Results** popup.
    * This option is available only if drift is detected in the stack instance.
8. Check the drift status for each resource in the **Resource Drift Results** popup.
9. For resources in the Drifted state, click the **Resource Drift Details** button to review the differences by property.
    * For the difference items, refer to [Viewing Drift Details](/en/userguide/management/infrastructure_builder/how_to_guides/drift/#detail).
