Skip to content

CloudFormation drift detection #290

Closed

Description

@scttfrdmn

Summary

Add drift detection: DetectStackDrift, DescribeStackDriftDetectionStatus, DescribeStackResourceDrifts.

Proposed implementation

Drift detection flow

  1. DetectStackDrift — for each resource in the stack, compare the current state (from the plugin's state manager) against the expected state (from the template + last applied parameters). Record any differences as drift.
  2. DescribeStackDriftDetectionStatus — return the status of a drift detection operation (IN_PROGRESS → DETECTION_COMPLETE)
  3. DescribeStackResourceDrifts — return per-resource drift details: IN_SYNC, MODIFIED, DELETED, NOT_CHECKED

Drift is observable

Since substrate controls all state mutations, drift can only occur when:

  • A resource is modified directly via API (e.g., UpdateTable after stack creation)
  • A resource is deleted directly via API
  • The stack template has parameter defaults that differ from applied values

This makes drift detection deterministic and testable — a key advantage over real AWS where drift is hard to reproduce.

Acceptance criteria

  • DetectStackDrift compares actual vs. expected resource state
  • DescribeStackResourceDrifts returns per-resource drift status
  • Direct API modifications to stack-managed resources are detected as MODIFIED
  • Direct API deletions of stack-managed resources are detected as DELETED
  • Resources unchanged from template are reported as IN_SYNC
  • Tests: create stack → modify resource directly → detect drift → verify MODIFIED

Activity

  1. added this to the v0.61.0 milestone on Apr 10, 2026
  2. added
    type: feature
    area: cloudformation
    on Apr 10, 2026
  3. scttfrdmn commented on May 30, 2026

    @scttfrdmn
    OwnerAuthor

    Partially shipped in v0.61.0 — keeping open for the remaining acceptance criteria.

    Done (betty_cfn.go:654 DetectStackDrift):

    • Per-resource drift status returned (CFNResourceDrift)
    • Direct API deletions of stack-managed resources detected as DELETED
    • Unchanged resources reported as IN_SYNC
    • Aggregate IN_SYNC/DRIFTED stack status

    Still outstanding:

    • MODIFIED detection — drift currently only checks existence (DELETED) vs. presence (IN_SYNC); property-level comparison of actual vs. expected resource state is not implemented (no MODIFIED status emitted anywhere in betty_cfn.go)
    • DescribeStackResourceDrifts operation
    • DescribeStackDriftDetectionStatus operation (IN_PROGRESS → DETECTION_COMPLETE)
    • Test: create stack → modify resource directly → detect drift → verify MODIFIED

    The release commit title referenced #290 but the feature is incomplete, so this stays open.

  4. scttfrdmn commented on Jun 2, 2026

    @scttfrdmn
    OwnerAuthor

    Remaining acceptance criteria implemented in #301 (branch feat/issues-290-293).

    #290 — see the PR for the full breakdown. For #290 specifically: MODIFIED is implemented and tested end-to-end for S3 VersioningConfiguration; the other drift-checkable types stay existence-only because their deploy paths don't persist template-comparable properties (documented honestly in the PR + cfnDriftComparators doc comment). Will close on merge via the PR's Closes #290 keyword.

  5. added a commit that references this issue on Jun 2, 2026
  6. scttfrdmn commented on Jun 2, 2026

    @scttfrdmn
    OwnerAuthor

    Advanced in #301 — keeping open for the remaining acceptance criteria, consistent with the existing partial-ship tracking on this issue.

    Now done (PR #301):

    • MODIFIED detection — implemented + tested end-to-end for S3 VersioningConfiguration (deploy versioned bucket → change outside CFN → MODIFIED with PropertyDifferences), via the new cfnDriftComparators map
    • DescribeStackResourceDrifts (with status filter)
    • DescribeStackDriftDetectionStatus (+ StartStackDriftDetection; DETECTION_IN_PROGRESS → DETECTION_COMPLETE)
    • Test: create stack → modify resource directly → detect MODIFIED

    Still outstanding:

    • Property-level MODIFIED for the other drift-checkable types (DynamoDB/SQS/SNS/Lambda/IAM). These remain existence-only because their deploy paths don't persist template-comparable properties (SQS/SNS deploy name-only; DynamoDB/IAM/Lambda have property name/shape mismatches). Broadening requires a larger cross-plugin change to persist comparable properties in each plugin's state. The cfnDriftComparators map is structured so new comparators drop in once that data exists.

    PR #301 Closes #293 only; #290 is left open by design.

  7. added a commit that references this issue on Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: cloudformationtype: feature

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions