How can I receive an email alert when my CloudFormation stack enters ROLLBACK_IN_PROGRESS status?

3 minute read
0

I want to receive an email alert when my AWS CloudFormation stack enters the ROLLBACK_IN_PROGRESS status during stack creation.

Resolution

Amazon EventBridge can send a notification to an Amazon Simple Notification Service (Amazon SNS) topic when your CloudFormation stack enters the ROLLBACK_IN_PROGRESS state. To create an EventBridge rule with an event pattern that matches this CloudFormation event, complete the following steps.

Note: To make sure that you can invoke the EventBridge rule, create the rule in the same AWS Region as the CloudFormation stack.

Create an SNS topic and subscription for email alerts

To create an SNS topic and subscription for email alerts, complete the following steps:

  1. Open the Amazon SNS console.
  2. In the navigation pane, choose Topics.
    Note: To use an existing topic, select that topic from the resource list, and then skip to step 7.
  3. Choose Create topic.
  4. For Name, enter a topic name.
  5. For Display name, enter a display name.
  6. Choose Create topic.
  7. Note your SNS topic's ARN for later use.
  8. Choose Create subscription.
  9. For Topic ARN, choose the SNS topic ARN that you noted in step 7.
  10. For Protocol, choose Email.
  11. For Endpoint, enter your email address.
  12. Choose Create subscription.
  13. Check your email inbox for a subscription confirmation email message from Amazon SNS. Then, choose Confirm subscription to see the subscription confirmation message in your browser.

Create an EventBridge Rule

To create an EventBridge rule, complete the following steps:

  1. Open the Amazon EventBridge console.

  2. In the navigation pane, choose Rules.

  3. Choose Create rule.

  4. Enter a Name and, optionally, a Description for the rule.

  5. For Event bus, choose AWS default event bus.

  6. For Rule type, choose Rule with an event pattern.

  7. Choose Next.

  8. For Creation method, choose Custom pattern (JSON editor).

  9. For Event Pattern, copy one of the example event patterns.

    The following example event pattern uses event detail data to match stack state change events when a CloudFormation stack state changes to ROLLBACK_IN_PROGRESS:

    {
      "source": [
        "aws.cloudformation"
      ],
      "detail-type": [
        "CloudFormation Stack Status Change"
      ],
      "detail": {
        "status-details": {
          "status": [
            "ROLLBACK_IN_PROGRESS"
          ]
        }
      }
    }
  10. Choose Next.

  11. For Target types, choose AWS service.

  12. For Select a target, choose SNS topic from the drop-down list.

  13. For Topic, select the Amazon SNS topic that you created for email alerts.

  14. Choose Next.

  15. Add any relevant tags to the rule, and then choose Next.

  16. Review the rule configuration, and then choose Create rule.

Related information

Managing AWS CloudFormation events using Amazon EventBridge

Creating Amazon EventBridge rules that react to events

AWS OFFICIAL
AWS OFFICIALUpdated 11 days ago