# atmos aws cloudformation drift detect

Trigger a fresh CloudFormation drift detection (`DetectStackDrift`) against
the deployed stack and poll until it completes, then render the overall
drift status and drifted-resource count. Use
[`drift describe`](/cli/commands/aws/cloudformation/drift/describe)
afterward to see per-resource results.

> ⚠️ Experimental

## Usage

```shell
atmos aws cloudformation drift detect <component> --stack <stack> [options]
```

```shell
atmos aws cloudformation drift detect vpc -s plat-ue2-dev
```

Fail the command (non-zero exit) when drift is found, for CI:

```shell
atmos aws cloudformation drift detect vpc -s plat-ue2-dev --fail-on-drift
```

Run drift detection for all or affected components in dependency order:

```shell
atmos aws cloudformation drift detect --all -s plat-ue2-dev --fail-on-drift
atmos aws cloudformation drift detect --affected --base origin/main --fail-on-drift
```

## Flags

- **`--stack`, `-s` (required for a single component)**
  Atmos stack. Required when operating on a single component; optional (and used only to narrow the selected set) with 
  `--all`
  /
  `--affected`
  .
- **`--fail-on-drift` (optional)**
  Exit non-zero if drift is detected. Useful for CI drift-detection jobs.

## Behavior

`drift detect` polls CloudFormation every 3 seconds until the detection
operation completes, and gives up after 15 minutes if it hasn't. A detection
that itself fails (`DETECTION_FAILED`) is always an error, independent of
`--fail-on-drift`.

:::note
`drift detect` fires `before.aws/cloudformation.drift-detect` and
`after.aws/cloudformation.drift-detect` hooks. The command-name hyphen is part of each event.
:::
