HealthCheck L2 construct
Amazon Route 53 health checks monitor the health and performance of your web applications, web servers, and other resources.
Each health check that you create can monitor one of the following:
- The health of a resource, such as a web server,
- The status of other health checks, and
- The CloudWatch alarm that you specify,
- The status of an Amazon Route 53 routing control.
Example
declare const myZone: route53.HostedZone;
const healthCheck = new route53.HealthCheck(this, 'HealthCheck', {
type: route53.HealthCheckType.HTTP,
fqdn: 'example.com',
port: 80,
resourcePath: '/health',
failureThreshold: 3,
requestInterval: Duration.seconds(30),
});
new route53.ARecord(this, 'ARecordFailoverPrimary', {
zone: myZone,
target: route53.RecordTarget.fromIpAddresses('1.2.3.4'),
failover: route53.Failover.PRIMARY,
healthCheck,
setIdentifier: 'failover-primary',
});
new route53.ARecord(this, 'ARecordFailoverSecondary', {
zone: myZone,
target: route53.RecordTarget.fromIpAddresses('5.6.7.8'),
failover: route53.Failover.SECONDARY,
setIdentifier: 'failover-secondary',
});
# my_zone: route53.HostedZone
health_check = route53.HealthCheck(self, "HealthCheck",
type=route53.HealthCheckType.HTTP,
fqdn="example.com",
port=80,
resource_path="/health",
failure_threshold=3,
request_interval=Duration.seconds(30)
)
route53.ARecord(self, "ARecordFailoverPrimary",
zone=my_zone,
target=route53.RecordTarget.from_ip_addresses("1.2.3.4"),
failover=route53.Failover.PRIMARY,
health_check=health_check,
set_identifier="failover-primary"
)
route53.ARecord(self, "ARecordFailoverSecondary",
zone=my_zone,
target=route53.RecordTarget.from_ip_addresses("5.6.7.8"),
failover=route53.Failover.SECONDARY,
set_identifier="failover-secondary"
)
HostedZone myZone;
HealthCheck healthCheck = HealthCheck.Builder.create(this, "HealthCheck")
.type(HealthCheckType.HTTP)
.fqdn("example.com")
.port(80)
.resourcePath("/health")
.failureThreshold(3)
.requestInterval(Duration.seconds(30))
.build();
ARecord.Builder.create(this, "ARecordFailoverPrimary")
.zone(myZone)
.target(RecordTarget.fromIpAddresses("1.2.3.4"))
.failover(Failover.PRIMARY)
.healthCheck(healthCheck)
.setIdentifier("failover-primary")
.build();
ARecord.Builder.create(this, "ARecordFailoverSecondary")
.zone(myZone)
.target(RecordTarget.fromIpAddresses("5.6.7.8"))
.failover(Failover.SECONDARY)
.setIdentifier("failover-secondary")
.build();
// Install: dotnet add package Amazon.CDK.Lib
HostedZone myZone;
var healthCheck = new HealthCheck(this, "HealthCheck", new HealthCheckProps {
Type = HealthCheckType.HTTP,
Fqdn = "example.com",
Port = 80,
ResourcePath = "/health",
FailureThreshold = 3,
RequestInterval = Duration.Seconds(30)
});
new ARecord(this, "ARecordFailoverPrimary", new ARecordProps {
Zone = myZone,
Target = RecordTarget.FromIpAddresses("1.2.3.4"),
Failover = Failover.PRIMARY,
HealthCheck = healthCheck,
SetIdentifier = "failover-primary"
});
new ARecord(this, "ARecordFailoverSecondary", new ARecordProps {
Zone = myZone,
Target = RecordTarget.FromIpAddresses("5.6.7.8"),
Failover = Failover.SECONDARY,
SetIdentifier = "failover-secondary"
});
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var myZone HostedZone
healthCheck := route53.NewHealthCheck(this, jsii.String("HealthCheck"), &HealthCheckProps{
Type: route53.HealthCheckType_HTTP,
Fqdn: jsii.String("example.com"),
Port: jsii.Number(80),
ResourcePath: jsii.String("/health"),
FailureThreshold: jsii.Number(3),
RequestInterval: awscdk.Duration_Seconds(jsii.Number(30)),
})
route53.NewARecord(this, jsii.String("ARecordFailoverPrimary"), &ARecordProps{
Zone: myZone,
Target: route53.RecordTarget_FromIpAddresses(jsii.String("1.2.3.4")),
Failover: route53.Failover_PRIMARY,
HealthCheck: HealthCheck,
SetIdentifier: jsii.String("failover-primary"),
})
route53.NewARecord(this, jsii.String("ARecordFailoverSecondary"), &ARecordProps{
Zone: myZone,
Target: route53.RecordTarget_*FromIpAddresses(jsii.String("5.6.7.8")),
Failover: route53.Failover_SECONDARY,
SetIdentifier: jsii.String("failover-secondary"),
})
Initializer
new HealthCheck(scope: Construct, id: string, props: HealthCheckProps)
HealthCheck(scope: Construct, id: str, props: HealthCheckProps)
new HealthCheck(Construct scope, String id, HealthCheckProps props)
new HealthCheck(Construct scope, string id, HealthCheckProps props)
NewHealthCheck(Scope Construct, Id *string, Props HealthCheckProps)
Construct Props
alarmIdentifierAlarmIdentifieralarm_identifierAlarmIdentifieralarmIdentifierAlarmIdentifierAlarmIdentifierAlarmIdentifierAlarmIdentifierAlarmIdentifier= if the type is CLOUDWATCH_METRIC…#default
Default: if the type is CLOUDWATCH_METRIC, this property is required. Otherwise, it is not configured.
childHealthChecksIHealthCheck[]child_health_checkstyping.List[IHealthCheck]childHealthChecksList<IHealthCheck>ChildHealthChecksIHealthCheck[]ChildHealthChecks*[]IHealthCheck= if the type is CALCULATED, this …#default
Default: if the type is CALCULATED, this property is required. Otherwise, it is not configured.
enableSNIbooleanenable_sniboolenableSNIBooleanEnableSNIboolEnableSNI*bool= if the type is HTTPS or HTTPS_ST…#This allows the endpoint to respond to HTTPS health check requests with the applicable SSL/TLS certificate.
default
Default: if the type is HTTPS or HTTPS_STR_MATCH, this property default value is true. Otherwise, it is not configured.
failureThresholdnumberfailure_thresholdint | floatfailureThresholdNumberFailureThresholddoubleFailureThreshold*float64= if the type is CALCULATED it's n…#default
Default: if the type is CALCULATED it's not configured - if the type is CLOUDWATCH_METRIC it's not configured - otherwise, the default value is 3.
notes
Amazon Route 53 behavior depends on whether you specify a value for IPAddress.
If you specify a value for IPAddress:
Amazon Route 53 sends health check requests to the specified IPv4 or IPv6 address and passes the value of FullyQualifiedDomainName in the Host header for all health checks except TCP health checks. This is typically the fully qualified DNS name of the endpoint on which you want Route 53 to perform health checks. Note: If you specify a value for Port property other than 80 or 443, Route 53 will construct the value for Host header as FullyQualifiedDomainName:Port.
If you don't specify a value for IPAddress:
Route 53 sends a DNS request to the domain that you specify for FullyQualifiedDomainName at the interval that you specify for RequestInterval. Using an IPv4 address that DNS returns, Route 53 then checks the health of the endpoint.
Additionally, if the type of the health check is HTTP, HTTPS, HTTP_STR_MATCH, or HTTPS_STR_MATCH, Route 53 passes the value of FullyQualifiedDomainName in the Host header, as it does when you specify value for IPAddress. If the type is TCP, Route 53 doesn't pass a Host header.
healthThresholdnumberhealth_thresholdint | floathealthThresholdNumberHealthThresholddoubleHealthThreshold*float64= if the type is CALCULATED, the d…#default
Default: if the type is CALCULATED, the default value is number of child health checks. Otherwise, it is not configured.
insufficientDataHealthStatusInsufficientDataHealthStatusEnuminsufficient_data_health_statusInsufficientDataHealthStatusEnuminsufficientDataHealthStatusInsufficientDataHealthStatusEnumInsufficientDataHealthStatusInsufficientDataHealthStatusEnumInsufficientDataHealthStatusInsufficientDataHealthStatusEnum= if the type is CLOUDWATCH_METRIC…#default
Default: if the type is CLOUDWATCH_METRIC, the default value is InsufficientDataHealthStatus.LAST_KNOWN_STATUS. Otherwise, it is not configured.
notes
If you don't specify a value for IPAddress, Route 53 sends a DNS request to resolve the domain name that you specify in FullyQualifiedDomainName at the interval that you specify in RequestInterval. Using an IPv4 address that DNS returns, Route 53 then checks the health of the endpoint.
measureLatencybooleanmeasure_latencyboolmeasureLatencyBooleanMeasureLatencyboolMeasureLatency*bool= if the type is CALCULATED it's n…#default
Default: if the type is CALCULATED it's not configured - if the type is CLOUDWATCH_METRIC it's not configured - otherwise, the default value is false.
default
Default: if the type is HTTP or HTTP_STR_MATCH, the default value is 80. - if the type is HTTPS or HTTPS_STR_MATCH, the default value is 443. - otherwise, it is not configured.
regionsstring[]regionstyping.List[str]regionsList<String>Regionsstring[]Regions*[]*string= if the type is CALCULATED, CLOUD…#Please refer to the CloudFormation documentation for the most up-to-date list of regions.
default
Default: if the type is CALCULATED, CLOUDWATCH_METRIC, or RECOVERY_CONTROL, this property is not configured. - otherwise, the default value will be set by CloudFormation itself and will include all valid regions. Please refer to the CloudFormation documentation for the most up-to-date list of regions.
requestIntervalDurationrequest_intervalDurationrequestIntervalDurationRequestIntervalDurationRequestIntervalDuration= if the type is CALCULATED it's n…#Each Route 53 health checker makes requests at this interval.
default
Default: if the type is CALCULATED it's not configured - if the type is CLOUDWATCH_METRIC it's not configured - otherwise, the default value is 30 seconds.
resourcePathstringresource_pathstrresourcePathStringResourcePathstringResourcePath*string= if the type is HTTP, HTTPS, HTTP…#notes · default
The path can be any value for which your endpoint will return an HTTP status code of 2xx or 3xx when the endpoint is healthy, for example the file /docs/route53-health-check.html. Route 53 automatically adds the DNS name for the service and a leading forward slash (/) character.
Default: if the type is HTTP, HTTPS, HTTP_STR_MATCH, or HTTPS_STR_MATCH, the default value is empty string. - otherwise, it is not configured.
routingControlstringrouting_controlstrroutingControlStringRoutingControlstringRoutingControl*string= if the type is RECOVERY_CONTROL,…#default
Default: if the type is RECOVERY_CONTROL, this property is required. Otherwise, it is not configured.
searchStringstringsearch_stringstrsearchStringStringSearchStringstringSearchString*string= if the type is HTTP_STR_MATCH or…#If the string appears in the response body, Route 53 considers the resource healthy.
Route 53 considers case when searching for SearchString in the response body.
default
Default: if the type is HTTP_STR_MATCH or HTTPS_STR_MATCH, this property is required. Otherwise, it is not configured.
typeHealthCheckTypetypeHealthCheckTypetypeHealthCheckTypeTypeHealthCheckTypeTypeHealthCheckTyperequired#Properties
envResourceEnvironmentenvResourceEnvironmentenvResourceEnvironmentEnvResourceEnvironmentEnvResourceEnvironmentrequired#notes
For resources that are created and managed in a Stack (those created by creating new class instances like new Role(), new Bucket(), etc.), this is always the same as the environment of the stack they belong to.
For referenced resources (those obtained from referencing methods like Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be different than the stack they were imported into.
healthCheckIdstringhealth_check_idstrhealthCheckIdStringHealthCheckIdstringHealthCheckId*stringrequired#healthCheckRefHealthCheckReferencehealth_check_refHealthCheckReferencehealthCheckRefHealthCheckReferenceHealthCheckRefHealthCheckReferenceHealthCheckRefHealthCheckReferencerequired#PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringrequiredstatic#Methods
applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength)#notes · 1 parameter
When set, any cross-stack reference to this resource will use the specified mechanism instead of the global default determined by the @aws-cdk/core:defaultCrossStackReferences context key. This is useful for selectively weakening specific references to avoid the "deadly embrace" problem without changing the app-wide default.
Parameters
strengthstrengthstrengthstrengthStrength— - The reference strength to use for this resource.
applyRemovalPolicy(policy: RemovalPolicy): voiddef apply_removal_policy(self, policy: RemovalPolicy) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy)public void ApplyRemovalPolicy(RemovalPolicy policy)func ApplyRemovalPolicy(Policy RemovalPolicy)#notes
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).
fromHealthCheckId(scope: Construct, id: string, healthCheckId: string): IHealthCheck@staticmethod def from_health_check_id(scope: Construct, id: str, health_check_id: str) -> IHealthCheckpublic static IHealthCheck fromHealthCheckId(Construct scope, String id, String healthCheckId)public static IHealthCheck FromHealthCheckId(Construct scope, string id, string healthCheckId)func FromHealthCheckId(Scope Construct, Id *string, HealthCheckId *string) IHealthCheckstatic#3 parameters · returns
Parameters
scopescopescopescopeScope— The parent creating construct (usuallythis).ididididId— The construct's name.healthCheckIdhealth_check_idhealthCheckIdhealthCheckIdHealthCheckId— ID of the health check.
Returns: a reference to the existing health check.
isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#notes · 1 parameter · returns
Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.
Parameters
xxxxX— Any object.
Returns: true if x is an object created from a class which extends Construct.
isOwnedResource(construct: IConstruct): boolean@staticmethod def is_owned_resource(construct: IConstruct) -> boolpublic static Boolean isOwnedResource(IConstruct construct)public static bool IsOwnedResource(IConstruct construct)func IsOwnedResource(Construct IConstruct) *boolstatic#isResource(construct: IConstruct): boolean@staticmethod def is_resource(construct: IConstruct) -> boolpublic static Boolean isResource(IConstruct construct)public static bool IsResource(IConstruct construct)func IsResource(Construct IConstruct) *boolstatic#toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.