{ config, lib, ... }:
let
  cfg = config.khscodes.cloudflare;
in
{
  options.khscodes.cloudflare = {
    data.dns_zones = lib.mkOption {
      type = lib.types.listOf lib.types.str;
      default = [ ];
    };
  };
  config = lib.mkIf cfg.enable {
    data.cloudflare_zone = lib.listToAttrs (
      lib.lists.map (zone: {
        name = lib.khscodes.sanitize-terraform-name zone;
        value = {
          name = zone;
        };
      }) (lib.lists.unique cfg.data.dns_zones)
    );
  };
}
