{ lib, config, ... }:
let
  cfg = config.khscodes.vault;
in
{
  options.khscodes.vault = {
    mount = lib.mkOption {
      type = lib.types.attrsOf (
        lib.khscodes.mkSubmodule {
          options = {
            type = lib.mkOption {
              type = lib.types.str;
              description = "Type of mount";
            };
            path = lib.mkOption {
              type = lib.types.str;
              description = "Path of the mount";
              default = null;
            };
            default_lease_ttl_seconds = lib.mkOption {
              type = lib.types.nullOr lib.types.int;
              description = "Default lease ttl in seconds";
              default = null;
            };
            max_lease_ttl_seconds = lib.mkOption {
              type = lib.types.nullOr lib.types.int;
              description = "Max lease ttl in seconds";
              default = null;
            };
            options = lib.mkOption {
              type = lib.types.nullOr lib.types.attrs;
              description = "Options for the mount";
              default = null;
            };
            description = lib.mkOption {
              type = lib.types.nullOr lib.types.str;
              description = "Usage description for the mount";
              default = null;
            };
          };
          description = "vault_mount";
        }
      );
      description = "Defines a vault mount";
      default = { };
    };
  };
  config = lib.mkIf cfg.enable {
    resource.vault_mount = lib.mapAttrs' (name: value: {
      name = lib.khscodes.sanitize-terraform-name name;
      value = value;
    }) cfg.mount;
  };
}
