Search code examples
amazon-web-servicesaws-cloudformationamazon-cloudwatchamazon-cloudtrail

How can I create an "aws.cloudformation" CloudWatch event type for a specific CloudFormation stack?


I need to create an aws.cloudformation event type for a specific CloudFormation stack. For example when StackA receives the UpdateStack event, I need to be able to catch that event.

Through the console I was able to create the following event rule (which is an AWS API Call via CloudTrail type event):

{
    "source": [
        "aws.cloudformation"
    ],
    "detail-type": [
        "AWS API Call via CloudTrail"
    ],
    "detail": {
        "eventSource": [
            "cloudformation.amazonaws.com"
        ],
        "eventName": [
            "UpdateStack",
            "CreateStack"
        ]
    }
}

However, this event isn't for any specific CloudFormation stack, and I don't see any option for adding anything specific (such as whenever StackA gets an UpdateStack call.

The documentation for event types give examples of other event types and how we can add a specific resource that triggers the event. For example, with the aws.codepipeline event, you can specify a pipeline equal value to PipelineA, and then the event would get triggered whenever PipelineA gets to the state you specified in the State parameter.

How can I do something similar with an aws.cloudformation event type?


Solution

  • Unfortunately the only way (as far as I have found) to get a stack-specific events is the notification configuration inside the stack, which can be only provided on creation/update.

    https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-console-add-tags.html