惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

有赞技术团队
有赞技术团队
M
MIT News - Artificial intelligence
Hugging Face - Blog
Hugging Face - Blog
博客园 - 聂微东
量子位
S
SegmentFault 最新的问题
V
Visual Studio Blog
博客园 - 【当耐特】
Apple Machine Learning Research
Apple Machine Learning Research
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
小众软件
小众软件
Stack Overflow Blog
Stack Overflow Blog
Vercel News
Vercel News
D
Docker
J
Java Code Geeks
博客园 - 三生石上(FineUI控件)
博客园 - Franky
Recent Announcements
Recent Announcements
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
MongoDB | Blog
MongoDB | Blog
D
DataBreaches.Net
Y
Y Combinator Blog
云风的 BLOG
云风的 BLOG
V
V2EX

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Automatically Healing CloudFormation Drift with Durable F...
ほうき星 · 2026-05-17 · via DEV Community

This article is a machine translation of the contents of the following URL, which I wrote in Japanese:

Durable Functions を用いて CloudFormation のドリフトを自動修復する #AWS - Qiita

はじめに こんにちは、ほうき星 @H0ukiStar です。 皆さんは昨年(2025年)の11月に CloudFormation がアップデートされ、ドリフト状態の修正に利用可能なドリフト認識変更セットが追加されたことをご存じでしょうか? 本機能の登場以前は、ドリフ...

favicon qiita.com

Introduction

Hello, I’m @H0ukiStar.

Did you know that in November 2025, AWS introduced a new CloudFormation feature called drift-aware change sets?

https://aws.amazon.com/about-aws/whats-new/2025/11/configuration-drift-enhanced-cloudformation-sets/

Before this feature was introduced, repairing drift typically required making a temporary dummy change to the stack, updating the stack, and then reverting the change afterward.

Now, by specifying --deployment-mode REVERT_DRIFT when creating a change set, CloudFormation can recognize differences between the IaC definition and the actual infrastructure, and automatically generate a change set specifically for drift remediation.

In this article, I’ll show how I implemented a Configuration Healing mechanism using Durable Functions that:

  • Detects CloudFormation stack drift
  • Automatically creates a drift-aware change set
  • Repairs the drift automatically

Trying Drift-Aware Change Sets

Deploying a Sample Stack

First, let’s see how drift-aware change sets work.

I deployed the following CloudFormation template with the stack name test.

AWSTemplateFormatVersion: 2010-09-09
Description: Stack for testing drift-aware change sets

Resources:
  TestParameter:
    Type: AWS::SSM::Parameter
    Properties:
      Name: /drift-test/sample
      Type: String
      Value: initial-value
      Description: Parameter for drift testing

Enter fullscreen mode Exit fullscreen mode

Immediately after deployment, the stack is not drifted.

Drift status immediately after stack deployment

[!WARNING]
The stack was deployed using a dedicated CloudFormation execution role.

The IAM role template is omitted here for brevity.
Please refer to the following GitHub repository for the complete template definition.

sample-aws-cfn-configuration-healing

Introducing Drift

Next, I intentionally introduced drift by modifying the SSM parameter value with the following command.

aws ssm put-parameter \
  --name /drift-test/sample \
  --value updated-value \
  --overwrite

Enter fullscreen mode Exit fullscreen mode

You can confirm from the CloudFormation drift detection screen that the stack is now drifted.

Drift status after modifying the SSM parameter

Repairing Drift with a Drift-Aware Change Set

On the CloudFormation drift screen, CloudFormation displays guidance indicating that the drift can be repaired using a drift-aware change set.

Select Create change set.

Creating a change set

Make sure the change set type is set to Drift-aware change set, then follow the instructions to create it.

Creating a drift-aware change setn

If you review the generated change set, you can see that CloudFormation correctly detects the drifted resource and prepares the remediation changes automatically.

Reviewing the generated change set

After executing the change set, the drift is resolved.

Drift status after applying the change set

Configuration Healing with Durable Functions

CloudFormation drift detection and change set creation are asynchronous operations, which means polling is required until completion.

Implementing this behavior using only standard Lambda functions can quickly become complicated due to retry handling, wait control, and state management.

This time, I used Durable Functions to simplify these wait operations and state transitions.

Durable Functions are designed for long-running workflows, making them a great fit for asynchronous APIs like CloudFormation.

Especially for workflows like:

  • Start operation
  • Wait for completion
  • Check status
  • Proceed to the next step

Durable Functions make the orchestration logic much easier to implement and maintain.

Workflow

The implementation follows the workflow below to detect and repair CloudFormation stack drift.

Durable Functions make it straightforward to implement waiting logic for both drift detection and change set creation.

In addition, by passing CreateChangeSetOnly: true in the Lambda event payload, the workflow can stop after creating the change set without executing it automatically.

Workflow figure

Durable Functions Implementation Example

The Durable Functions implementation follows the workflow shown above.

The full source code, including the SAM template, is available in the following repository.

CloudFormation Configuration Healing with Durable Functions

Automatic detection and healing of CloudFormation stack drift using AWS Lambda with Durable Functions.

This sample demonstrates how to automatically detect configuration drift in CloudFormation stacks and heal them by creating and executing change sets using the AWS Durable Execution SDK for Python.

Features

  • Automatic Drift Detection: Detects configuration drift in CloudFormation stacks
  • Automatic Healing: Creates and executes change sets to restore the stack to its desired state
  • Durable Functions: Uses AWS Lambda Durable Execution SDK to handle long-running operations reliably
  • SNS Notifications: Sends notifications about drift detection and healing operations
  • Error Handling: Comprehensive error handling for drift detection and change set operations

Installation

Deploy using the AWS SAM CLI with the following commands:

cd configuration-healing
sam build
sam deploy --guided

Enter fullscreen mode Exit fullscreen mode

During the guided deployment, you will be prompted to provide:

  • SNS Topic ARN: The ARN of an…
# The complete implementation is available in the GitHub repository above.
# The code is omitted here for brevity.

Enter fullscreen mode Exit fullscreen mode

Verification

Next, I intentionally modified the value of the SSM Parameter created in the test stack to introduce drift, then executed the deployed Lambda function.

aws lambda invoke \
  --function-name arn:aws:lambda:<region>:<account-id>:function:cfn-drift-healing:Alias \
  --invocation-type Event \
  --cli-binary-format raw-in-base64-out \
  --payload '{"StackName": "test"}' \
  response.json

Enter fullscreen mode Exit fullscreen mode

From the logs, you can confirm that the automatic remediation proceeds as follows:

  1. Start drift detection
  2. Detect stack drift
  3. Create a drift-aware change set
  4. Execute the change set
  5. Resolve the drift

Lambda function execution logs

Durable execution result

You can also confirm the remediation completion through SNS notifications.

SNS notification after successful remediation

You can also stop the workflow after creating the change set by passing CreateChangeSetOnly: true in the event payload.

This allows a human operator to review and execute the change set manually.

aws lambda invoke \
  --function-name arn:aws:lambda:<region>:<account-id>:function:cfn-drift-healing:Alias \
  --invocation-type Event \
  --cli-binary-format raw-in-base64-out \
  --payload '{"StackName": "test", "CreateChangeSetOnly": true}' \
  response.json

Enter fullscreen mode Exit fullscreen mode

Lambda function logs when stopping after change set creation

SNS notification when stopping after change set creation

Conclusion

CloudFormation drift-aware change sets make it much safer and easier to repair configuration drift than before.

In this article, I implemented a Configuration Healing mechanism using Durable Functions that automatically detects and repairs CloudFormation drift.

Even when using IaC, long-running environments inevitably experience unintended configuration changes over time.

By combining this workflow with services like EventBridge Scheduler for periodic execution, you can continuously and automatically remediate drift caused by:

  • Unintended manual changes
  • Temporary fixes that were never reverted
  • Configuration updates forgotten over time

This helps maintain infrastructure consistency and improve long-term IaC governance.

If fully automated remediation feels too risky for production environments, you can instead stop after creating the change set and require human review before execution, as demonstrated earlier in this article.

I hope this article serves as a useful example of implementing Configuration Healing with CloudFormation.