code: def get_consul_configuration_from_environment() -> ConsulConfiguration:
      
      address = os.environ[CONSUL_ADDRESS_ENVIRONMENT_VARIABLE]
      if "://" in address:
          raise EnvironmentError(f"Invalid host: {address}. Do not specify scheme in host - set that in "
                                 f"{CONSUL_SCHEME_ENVIRONMENT_VARIABLE}")
  
      host_port_split = address.split(":")
      host = host_port_split[0]
      if len(host_port_split) == 1:
          _get_logger().info(
              f"No port specified in address read from the environment - using default port: {DEFAULT_CONSUL_PORT}")
          port = DEFAULT_CONSUL_PORT
      else:
          port = host_port_split[1]
  
      return ConsulConfiguration(
          host=host,
          port=port,
          token=os.environ.get(CONSUL_TOKEN_ENVIRONMENT_VARIABLE, DEFAULT_CONSUL_TOKEN),
          scheme=os.environ.get(CONSUL_SCHEME_ENVIRONMENT_VARIABLE, DEFAULT_CONSUL_SCHEME),
          datacentre=os.environ.get(CONSUL_DATACENTRE_ENVIRONMENT_VARIABLE, DEFAULT_CONSUL_DATACENTRE),
          verify=os.environ.get(CONSUL_VERIFY_ENVIRONMENT_VARIABLE, DEFAULT_CONSUL_VERIFY),
          certificate=os.environ.get(CONSUL_CERTIFICATE_ENVIRONMENT_VARIABLE, DEFAULT_CONSUL_CERTIFICATE))
docs: Gets configuration on how to connect to Consul from the environment.
      :return: the configuration derived from the environment
      :raises KeyError: if a required environment variable has not been set