docs: @Override
      protected void register(ServiceInstance instance) {
          // step 1 get domain from config
          // set service from config
          // check if service exists
          // register service if not
          // register instance to service
  
          Map<String, String> instanceAttributes = new HashMap<>();
  
          // you can't just put anything in there like a custom config. Only certain things are allowed or you get weird errors
          // see https://docs.aws.amazon.com/Route53/latest/APIReference/API_autonaming_RegisterInstance.html
          //if the service uses A records use these
          if (instance.getPort() > 0) {
              instanceAttributes.put("AWS_INSTANCE_PORT", Integer.toString(instance.getPort()));
          }
          if (amazonComputeInstanceMetadataResolver != null) {
              Optional<ComputeInstanceMetadata> instanceMetadata = amazonComputeInstanceMetadataResolver.resolve(environment);
              if (instanceMetadata.isPresent()) {
                  ComputeInstanceMetadata computeInstanceMetadata = instanceMetadata.get();
                  if (computeInstanceMetadata.getPublicIpV4() != null) {
                      instanceAttributes.put(AWS_INSTANCE_IPV4, computeInstanceMetadata.getPublicIpV4());
                  } else {
                      if (computeInstanceMetadata.getPrivateIpV4() != null) {
                          instanceAttributes.put(AWS_INSTANCE_IPV4, computeInstanceMetadata.getPrivateIpV4());
                      }
                  }
  
                  if (!instanceAttributes.containsKey(AWS_INSTANCE_IPV4)) {
                      // try ip v6
                      if (computeInstanceMetadata.getPublicIpV4() != null) {
                          instanceAttributes.put(AWS_INSTANCE_IPV6, computeInstanceMetadata.getPublicIpV6());
                      } else {
                          if (computeInstanceMetadata.getPrivateIpV6() != null) {
                              instanceAttributes.put(AWS_INSTANCE_IPV6, computeInstanceMetadata.getPrivateIpV6());
                          }
                      }
                  }
              }
          }
  
  
          ConvertibleValues<String> metadata = instance.getMetadata();
  
          String instanceId = null;
          if (instance.getInstanceId().isPresent()) {
              instanceId = instance.getInstanceId().get();
          } else {
              // try the metadata
              if (metadata.contains("instanceId")) {
                  instanceId = metadata.asMap().get("instanceId");
              } else {
                  if (LOG.isErrorEnabled()) {
                      LOG.error("Cannot determine the instance ID. Are you sure you are running on AWS EC2?");
                  }
              }
          }
          RegisterInstanceRequest instanceRequest = new RegisterInstanceRequest().withServiceId(route53AutoRegistrationConfiguration.getAwsServiceId())
                  .withInstanceId(instanceId).withCreatorRequestId(Long.toString(System.nanoTime())).withAttributes(instanceAttributes);
  
          Future<RegisterInstanceResult> instanceResult = getDiscoveryClient().registerInstanceAsync(instanceRequest);
          Flowable<RegisterInstanceResult> flowableResult = Flowable.fromFuture(instanceResult);
  
  
          //noinspection SubscriberImplementation
          flowableResult.subscribe(new Subscriber<RegisterInstanceResult>() {
  
              @Override
              public void onNext(RegisterInstanceResult registerInstanceResult) {
                  if (LOG.isInfoEnabled()) {
                      LOG.info("Called AWS to register service [{}] with {}", instance.getId(), route53AutoRegistrationConfiguration.getAwsServiceId());
                  }
                  if (registerInstanceResult.getOperationId() != null) {
                      ServiceRegistrationStatusTask serviceRegistrationStatusTask = new ServiceRegistrationStatusTask(getDiscoveryClient(),
                              route53AutoRegistrationConfiguration,
                              instance,
                              registerInstanceResult.getOperationId());
                      executorService.execute(serviceRegistrationStatusTask);
                  }
  
              }
  
              @Override
              public void onSubscribe(Subscription s) {
                  s.request(1);
              }
  
              @Override
              public void onError(Throwable t) {
                  if (LOG.isErrorEnabled()) {
                      LOG.error("Error registering instance with AWS:" + t.getMessage(), t);
                  }
                  if (route53AutoRegistrationConfiguration.isFailFast() && instance instanceof EmbeddedServerInstance) {
                      LOG.error("Error registering instance with AWS and Failfast is set: stopping instance");
                      ((EmbeddedServerInstance) instance).getEmbeddedServer().stop();
                  }
              }
  
              @Override
              public void onComplete() {
                  if (LOG.isInfoEnabled()) {
                      LOG.info("Success calling register service request [{}] with {} is complete.", instance.getId(),
                              route53AutoRegistrationConfiguration.getAwsServiceId());
                  }
              }
          });
  
      }