HealthCheckConfig Struct
Settings for an optional Amazon Route 53 health check.
If you specify settings for a health check, AWS Cloud Map associates the health check with all the records that you specify in DnsConfig. Only valid with a PublicDnsNamespace.
| Source | aws-servicediscovery/lib/service.ts |
|---|
Example
ts
import * as cdk from '../../core';
import * as servicediscovery from '../lib';
const app = new cdk.App();
const stack = new cdk.Stack(app, 'aws-servicediscovery-integ');
const namespace = new servicediscovery.HttpNamespace(stack, 'MyNamespace', {
name: 'MyHTTPNamespace',
});
const service1 = namespace.createService('NonIpService', {
description: 'service registering non-ip instances',
});
service1.registerNonIpInstance('NonIpInstance', {
customAttributes: { arn: 'arn:aws:s3:::amzn-s3-demo-bucket' },
});
const service2 = namespace.createService('IpService', {
description: 'service registering ip instances',
healthCheck: {
type: servicediscovery.HealthCheckType.HTTP,
resourcePath: '/check',
},
});
service2.registerIpInstance('IpInstance', {
ipv4: '54.239.25.192',
});
app.synth();
python
import aws_cdk as cdk
import aws_cdk as servicediscovery
app = cdk.App()
stack = cdk.Stack(app, "aws-servicediscovery-integ")
namespace = servicediscovery.HttpNamespace(stack, "MyNamespace",
name="MyHTTPNamespace"
)
service1 = namespace.create_service("NonIpService",
description="service registering non-ip instances"
)
service1.register_non_ip_instance("NonIpInstance",
custom_attributes={"arn": "arn:aws:s3:::amzn-s3-demo-bucket"}
)
service2 = namespace.create_service("IpService",
description="service registering ip instances",
health_check=cdk.aws_servicediscovery.HealthCheckConfig(
type=servicediscovery.HealthCheckType.HTTP,
resource_path="/check"
)
)
service2.register_ip_instance("IpInstance",
ipv4="54.239.25.192"
)
app.synth()
java
import software.amazon.awscdk.*;
import software.amazon.awscdk.*;
App app = new App();
Stack stack = new Stack(app, "aws-servicediscovery-integ");
HttpNamespace namespace = HttpNamespace.Builder.create(stack, "MyNamespace")
.name("MyHTTPNamespace")
.build();
Service service1 = namespace.createService("NonIpService", BaseServiceProps.builder()
.description("service registering non-ip instances")
.build());
service1.registerNonIpInstance("NonIpInstance", NonIpInstanceBaseProps.builder()
.customAttributes(Map.of("arn", "arn:aws:s3:::amzn-s3-demo-bucket"))
.build());
Service service2 = namespace.createService("IpService", BaseServiceProps.builder()
.description("service registering ip instances")
.healthCheck(HealthCheckConfig.builder()
.type(HealthCheckType.HTTP)
.resourcePath("/check")
.build())
.build());
service2.registerIpInstance("IpInstance", IpInstanceBaseProps.builder()
.ipv4("54.239.25.192")
.build());
app.synth();
csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK;
using Amazon.CDK;
var app = new App();
var stack = new Stack(app, "aws-servicediscovery-integ");
var namespace = new HttpNamespace(stack, "MyNamespace", new HttpNamespaceProps {
Name = "MyHTTPNamespace"
});
var service1 = namespace.CreateService("NonIpService", new BaseServiceProps {
Description = "service registering non-ip instances"
});
service1.RegisterNonIpInstance("NonIpInstance", new NonIpInstanceBaseProps {
CustomAttributes = new Dictionary<string, string> { { "arn", "arn:aws:s3:::amzn-s3-demo-bucket" } }
});
var service2 = namespace.CreateService("IpService", new BaseServiceProps {
Description = "service registering ip instances",
HealthCheck = new HealthCheckConfig {
Type = HealthCheckType.HTTP,
ResourcePath = "/check"
}
});
service2.RegisterIpInstance("IpInstance", new IpInstanceBaseProps {
Ipv4 = "54.239.25.192"
});
app.Synth();
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
app := cdk.NewApp()
stack := cdk.NewStack(app, jsii.String("aws-servicediscovery-integ"))
namespace := servicediscovery.NewHttpNamespace(stack, jsii.String("MyNamespace"), &HttpNamespaceProps{
Name: jsii.String("MyHTTPNamespace"),
})
service1 := namespace.CreateService(jsii.String("NonIpService"), &BaseServiceProps{
Description: jsii.String("service registering non-ip instances"),
})
service1.RegisterNonIpInstance(jsii.String("NonIpInstance"), &NonIpInstanceBaseProps{
CustomAttributes: map[string]*string{
"arn": jsii.String("arn:aws:s3:::amzn-s3-demo-bucket"),
},
})
service2 := namespace.CreateService(jsii.String("IpService"), &BaseServiceProps{
Description: jsii.String("service registering ip instances"),
HealthCheck: &HealthCheckConfig{
Type: servicediscovery.HealthCheckType_HTTP,
ResourcePath: jsii.String("/check"),
},
})
service2.RegisterIpInstance(jsii.String("IpInstance"), &IpInstanceBaseProps{
Ipv4: jsii.String("54.239.25.192"),
})
app.Synth()
Properties
failureThresholdoptionalnumberfailure_thresholdoptionalint | floatfailureThresholdoptionalNumberFailureThresholdoptionaldoubleFailureThresholdoptional*float64 = 1 #The number of consecutive health checks that an endpoint must pass or fail for Route 53 to change the current status of the endpoint from unhealthy to healthy or vice versa.
resourcePathoptionalstringresource_pathoptionalstrresourcePathoptionalStringResourcePathoptionalstringResourcePathoptional*string = '/' #The path that you want Route 53 to request when performing health checks.
Do not use when health check type is TCP.
typeoptionalHealthCheckTypetypeoptionalHealthCheckTypetypeoptionalHealthCheckTypeTypeoptionalHealthCheckTypeTypeoptionalHealthCheckType = HTTP #The type of health check that you want to create, which indicates how Route 53 determines whether an endpoint is healthy.
Cannot be modified once created. Supported values are HTTP, HTTPS, and TCP.