AWS CDK Route53 HealthCheck
Create Route53 HealthChecks to monitor TCP, HTTP, HTTPS endpoints, to monitor CloudWatch Alarms and to monitor other Route53 HealthChecks.
Currently supported types of Route53 HealthChecks:
Easily create a CloudWatch Alarm based on the Route53 HealthCheck:
const healthCheck = new EndpointHealthCheck(scope, "HealthCheck", {
domainName: "pepperize.com",
});
const alarm = new cloudwatch.Alarm(scope, "Alarm", {
metric: healthCheck.metricHealthCheckStatus(),
comparisonOperator: cloudwatch.ComparisonOperator.LESS_THAN_THRESHOLD,
threshold: 1,
evaluationPeriods: 1,
});
See more options API Reference
Install
TypeScript
npm install @pepperize/cdk-route53-health-check
or
yarn add @pepperize/cdk-route53-health-check
Python
pip install pepperize.cdk-route53-health-check
C# / .Net
dotnet add package Pepperize.CDK.Route53HealthCheck
Java
<dependency>
<groupId>com.pepperize</groupId>
<artifactId>cdk-route53-health-check</artifactId>
<version>${cdkRoute53HealthCheck.version}</version>
</dependency>
Usage
npm install @pepperize/cdk-route53-health-check
See API.md.
HealthCheck for an endpoint
HTTPS health check
new EndpointHealthCheck(scope, "HealthCheck", {
domainName: "pepperize.com",
});
Generates
Resources:
Type: AWS::Route53::HealthCheck
Properties:
HealthCheckConfig:
FullyQualifiedDomainName: "pepperize.com"
Port: 443
Type: "HTTPS"
EnableSNI: true
Additional configuration options
new EndpointHealthCheck(scope, "HealthCheck", {
domainName: "pepperize.com",
enableSni: true,
failureThreshold: 3,
healthCheckName: "pepperize.com",
inverted: false,
ipAddress: "1.1.1.1",
latencyGraphs: true,
port: 443,
protocol: Protocol.HTTPS,
regions: [HealthCheckerRegions.EU_WEST_1, HealthCheckerRegions.US_EAST_1, HealthCheckerRegions.US_WEST_1],
requestInterval: 30,
resourcePath: "/health-check",
searchString: "OK",
});
See for more options API Reference - EndpointHealthCheckProps
HealthCheck to monitor other HealthChecks
const healthCheck1 = new EndpointHealthCheck(stack, "HealthCheck1", {
domainName: "pepperize.com",
});
const healthCheck2 = EndpointHealthCheck.fromHealthCheckId(
scope,
"HealthCheck2",
"9ebee2db-6292-4803-9838-327e6example"
);
new CalculatedHealthCheck(scope, "CalculatedHealthCheck", {
childHealthChecks: [healthCheck1, healthCheck2],
});
See for more options API Reference - CalculatedHealthCheckProps
HealthCheck to monitor CloudWatch Alarms
const alarm = cloudwatch.Alarm.fromAlarmArn(
scope,
"Alarm",
"arn:aws:cloudwatch:us-east-1:123456789012:alarm:any-alarm"
);
new AlarmHealthCheck(scope, "HealthCheck", {
alarm: alarm,
});
See for more options API Reference - AlarmHealthCheckProps
Configuring DNS Failover
An example active-passive DNS failover configuration
Primary
const recordSetPrimary = new route53.ARecord(scope, "RecordSetPrimary", {
recordName: "www.pepperize.com",
zone: hostedZone,
target: route53.RecordTarget.fromAlias(new targets.CloudFrontTarget(distribution)),
});
const healthCheckPrimary = new EndpointHealthCheck(scope, "HealthCheckPrimary", {
domainName: "www.pepperize.com",
});
healthCheckPrimary.failoverPrimary(recordSetPrimary);
Secondary
const recordSetSecondary = new route53.ARecord(scope, "RecordSetSecondary", {
recordName: "www-1.pepperize.com",
zone: hostedZone,
target: route53.RecordTarget.fromAlias(new targets.LoadBalancerTarget(alb)),
});
const healthCheckSecondary = new EndpointHealthCheck(scope, "HealthCheckSecondary", {
domainName: "www-1.pepperize.com",
});
healthCheckSecondary.failoverSecondary(recordSetSecondary, true);
See for more options API Reference - IHealthCheck
How health checks work in complex Amazon Route 53 configurations