aws-cdk icon indicating copy to clipboard operation
aws-cdk copied to clipboard

[route53] Support for health checks

Open justin8 opened this issue 5 years ago • 7 comments

Currently the only way to define a health check or even to enable health checks for alias targets appears to be using Cfn resources instead of the higher level constructs.

Use Case

Route53 health checks are commonly used for multi-region architectures, and not being able to create them is a little limiting

Proposed Solution

Other

  • [ ] :wave: I may be able to implement this feature request
  • [ ] :warning: This feature might incur a breaking change

This is a :rocket: Feature Request

justin8 avatar Aug 06 '20 07:08 justin8

@justin8 I agree this is a pretty important missing feature. marking it as a p1 to help us prioritize getting it implemented and added in.

shivlaks avatar Aug 07 '20 01:08 shivlaks

Trying to work around this open ticket... not sure this is right though. Deployment seems to get stuck.


import { determineFullyQualifiedDomainName } from '@aws-cdk/aws-route53/lib/util'

// ...

const alias = new route53_targets.ApiGatewayv2DomainProperties(
    domainName.regionalDomainName, domainName.regionalHostedZoneId
)
const target = route53.RecordTarget.fromAlias(alias)

// latency based routing with health check
const gwStack = core.Stack.of(gw)
const healthCheck = new route53.CfnHealthCheck(this, 'healthCheck', {
    healthCheckConfig: {
        fullyQualifiedDomainName:
            `${gw.apiId}.execute-api.${gwStack.region}.${gwStack.urlSuffix}`,
        type: 'HTTPS',
        measureLatency: true
    }
})

new route53.CfnRecordSet(this, 'aRecordSet', {
    aliasTarget: {
        dnsName: domainName.regionalDomainName,
        hostedZoneId: domainName.regionalHostedZoneId,
        evaluateTargetHealth: true
    },
    name: determineFullyQualifiedDomainName(siteName, hostedZone),
    hostedZoneId: hostedZone.hostedZoneId,
    resourceRecords: target.values,
    type: route53.RecordType.A,
    region: gwStack.region,
    setIdentifier: id,
    healthCheckId: healthCheck.attrHealthCheckId
})

I'll update if I work out something better, but wanted to put what I had so far down given this has been open a while now.

This seems to work on a fresh push of a stack... still not sure on the update path. Taking the long game this time and giving the updated stack as much time as it needs (e.g. hours if need be)

elhedran avatar Jun 25 '21 04:06 elhedran

Before this feature is available in the new release, do we have any way to associate a Cloudwatch Alarm with the Route53 Health Check in CDK?

Fitmavincent avatar Aug 18 '21 02:08 Fitmavincent

Any update on this?

OGoodness avatar Jun 07 '22 14:06 OGoodness

Here is a small custom construct that should work with the higher level RecordSet. Supports Endpoint, Alarm and Calculated health checks. Has method to retrieve metrics for CloudWatch Alarms and methods to configure failover.

cdk-route53-health-check diagram

pflorek avatar Oct 21 '22 09:10 pflorek

This issue has received a significant amount of attention so we are automatically upgrading its priority. A member of the community will see the re-prioritization and provide an update on the issue.

github-actions[bot] avatar Jun 16 '24 00:06 github-actions[bot]

for those who are waiting for this: I have already opened the PR for alias records health checks and now I'm also working on regular health checks expecting the PR to be ready in a few days 🤞

wladyslawczyzewski avatar Jun 27 '24 08:06 wladyslawczyzewski

two PRs are waiting for review & merge – first one for alias target health evaluation & second one for AWS::Route53::HealthCheck resources

wladyslawczyzewski avatar Jul 02 '24 21:07 wladyslawczyzewski

both PRs merged - health checks are now available in AWS CDK

wladyslawczyzewski avatar Dec 13 '24 09:12 wladyslawczyzewski