createHealthCheck method

Future<CreateHealthCheckResponse> createHealthCheck({
  1. required String callerReference,
  2. required HealthCheckConfig healthCheckConfig,
})

Creates a new health check.

For information about adding health checks to resource record sets, see HealthCheckId in ChangeResourceRecordSets.

ELB Load Balancers

If you're registering EC2 instances with an Elastic Load Balancing (ELB) load balancer, do not create Amazon Route 53 health checks for the EC2 instances. When you register an EC2 instance with a load balancer, you configure settings for an ELB health check, which performs a similar function to a Route 53 health check.

Private Hosted Zones

You can associate health checks with failover resource record sets in a private hosted zone. Note the following:

  • Route 53 health checkers are outside the VPC. To check the health of an endpoint within a VPC by IP address, you must assign a public IP address to the instance in the VPC.
  • You can configure a health checker to check the health of an external resource that the instance relies on, such as a database server.
  • You can create a CloudWatch metric, associate an alarm with the metric, and then create a health check that is based on the state of the alarm. For example, you might create a CloudWatch metric that checks the status of the Amazon EC2 StatusCheckFailed metric, add an alarm to the metric, and then create a health check that is based on the state of the alarm. For information about creating CloudWatch metrics and alarms by using the CloudWatch console, see the Amazon CloudWatch User Guide.

May throw TooManyHealthChecks. May throw HealthCheckAlreadyExists. May throw InvalidInput.

Parameter callerReference : A unique string that identifies the request and that allows you to retry a failed CreateHealthCheck request without the risk of creating two identical health checks:

  • If you send a CreateHealthCheck request with the same CallerReference and settings as a previous request, and if the health check doesn't exist, Amazon Route 53 creates the health check. If the health check does exist, Route 53 returns the settings for the existing health check.
  • If you send a CreateHealthCheck request with the same CallerReference as a deleted health check, regardless of the settings, Route 53 returns a HealthCheckAlreadyExists error.
  • If you send a CreateHealthCheck request with the same CallerReference as an existing health check but with different settings, Route 53 returns a HealthCheckAlreadyExists error.
  • If you send a CreateHealthCheck request with a unique CallerReference but settings identical to an existing health check, Route 53 creates the health check.

Parameter healthCheckConfig : A complex type that contains settings for a new health check.

Implementation

Future<CreateHealthCheckResponse> createHealthCheck({
  required String callerReference,
  required HealthCheckConfig healthCheckConfig,
}) async {
  ArgumentError.checkNotNull(callerReference, 'callerReference');
  _s.validateStringLength(
    'callerReference',
    callerReference,
    1,
    64,
    isRequired: true,
  );
  ArgumentError.checkNotNull(healthCheckConfig, 'healthCheckConfig');
  final $result = await _protocol.sendRaw(
    method: 'POST',
    requestUri: '/2013-04-01/healthcheck',
    payload: CreateHealthCheckRequest(
            callerReference: callerReference,
            healthCheckConfig: healthCheckConfig)
        .toXml(
      'CreateHealthCheckRequest',
      attributes: [
        _s.XmlAttribute(_s.XmlName('xmlns'),
            'https://route53.amazonaws.com/doc/2013-04-01/'),
      ],
    ),
    exceptionFnMap: _exceptionFns,
  );
  final $elem = await _s.xmlFromResponse($result);
  return CreateHealthCheckResponse(
    healthCheck:
        HealthCheck.fromXml(_s.extractXmlChild($elem, 'HealthCheck')!),
    location: _s.extractHeaderStringValue($result.headers, 'Location')!,
  );
}