Skip to content

Schedules automated drift detection for CloudFormation StackSets and sends alerts when drift is identified

License

Notifications You must be signed in to change notification settings

imduchy/stackset-drift-detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Automated CloudFormation StackSet drift detection

License: MIT

Provides a CDK example for automated CloudFormation StackSet drift detection. This event-driven solution allows teams to proactively identify configuration drift across AWS accounts and receive alerts when a StackSet instance(s) drifted from the desired state.

Getting started

Bellow is an example for how to use the StacksetDriftDetectionStack stack.

app = aws_cdk.App()

StacksetDriftDetectionStack(
    app,
    "StacksetDriftDetectionStack",
    env=Environment(
        account=os.environ["CDK_DEFAULT_ACCOUNT"],
        region=os.environ["CDK_DEFAULT_REGION"],
    ),
    props=StacksetDriftDetectionStackProps(
        stackset_names=["ExampleStackSetName"],
        schedule_expression="cron(0 5 ? * 2 *)",
        notification_email_endpoints=["[email protected]"],
        notification_https_endpoints=["security.webhook.examplecorp.com"],
    ),
)

How it works

Diagram

  1. EventBridge schedule triggers CloudFormation StackSet drift detection based on the provided schedule expression. EventBridge Schedulers support cron and rate expressions.

  2. CloudFormation publishes "StackSet Operation Status Change" events to the default EventBridge bus.

  3. A custom EventBridge rule captures the relevant event and forwards it to the Lambda function.

  4. The Lambda function fetches the StackSet operation details from CloudFormation and evaluates the its status.

  5. If the StackSet operation discovered a DRIFT in one or more of StackSet instances, it will send an alert through the SNS topic.

About

Schedules automated drift detection for CloudFormation StackSets and sends alerts when drift is identified

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published