Gordon Childs
Gordon Childs

Reputation: 36084

How to correctly configure Route53 HealthCheck Alarm with CF (in Sydney)

I've configured a Route53 HealthCheck with an associated alarm with CloudFormation, but the resulting healthcheck shows as having No alarms configured, and the alarms in the CloudWatch console remain dead. If I manually create the alarm in HealthChecks, everything works.

Worse, if I switch from Sydney/ap-southeast-2 and create the same cloud formation stack in North Virginia/us-east-1, the alarm is correctly associated with the health check and everything works!

One more datapoint: when manually creating the alarm in Route53 HealthChecks, the alarm is created in us-east-1, despite Route53 being global and ap-southeast-1 being the default in all other consoles.

My simplified stack looks like this:

{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Description": "healthcheck alarm test",
  "Resources": {
    "StatusHealthCheck": {
      "Type": "AWS::Route53::HealthCheck",
      "Properties": {
        "HealthCheckConfig": {
          "Port": "80",
          "Type": "HTTP",
          "ResourcePath": "/status",
          "FullyQualifiedDomainName": "testdomain.com",
          "RequestInterval": "30",
          "FailureThreshold": "1"
        },
        "HealthCheckTags": [
          {
            "Key": "Name",
            "Value": "status reachability check"
          }
        ]
      }
    },
    "StatusHealthCheckFailedAlarm": {
      "Type": "AWS::CloudWatch::Alarm",
      "Properties": {
        "ActionsEnabled": "true",
        "AlarmDescription": "alarmed when status doesn't respond",
        "ComparisonOperator": "LessThanThreshold",
        "EvaluationPeriods": "1",
        "MetricName": "HealthCheckStatus",
        "Namespace": "AWS/Route53",
        "Period": "60",
        "Statistic": "Minimum",
        "Threshold": "1.0",
        "Dimensions": [
          {
            "Name": "HealthCheckId",
            "Value": {
              "Ref": "StatusHealthCheck"
            }
          }
        ]
      }
    }
  }
}

Is there any reason it should work in North Virginia but not in Sydney?

Upvotes: 3

Views: 5374

Answers (3)

Kamil Janowski
Kamil Janowski

Reputation: 2025

You can however look at other metrics. If the health check is an HTTP call to an API, then depending on whether you use a Load Balancer or an API Gateway, you have other metrics that go to their respective regions.

In my case I'm now using the 5XX response metric from API Gateway. This is essentially the same as using the metric generated by Route53

Upvotes: 0

Sebastian Viereck
Sebastian Viereck

Reputation: 5905

The task can only be achieved using a lamba function because:

  1. health check alarms can only be created in region: us-east-1 https://stackoverflow.com/a/32335539/1714171
  2. resources managed by a CloudFormation stack can only reside in the same region as the stack itself https://stackoverflow.com/a/46165480/1714171

That means, it is not possible using only pure CloudFormation syntax.

You can create an alarm with a lambda function like this: https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/cloudwatch-examples-creating-alarms.html#cloudwatch-examples-creating-alarms-putmetricalarm

Upvotes: 1

Fuzzyfelt
Fuzzyfelt

Reputation: 96

The CloudWatch metrics generated by the HealthCheck are only visible in the US-East region, as described at the bottom of this page http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/health-checks-monitor-view-status.html. This is why your stack works correctly when created in us-east-1.

Upvotes: 8

Related Questions