{ khscodesLib, ... }:
{ config, lib, ... }:
let
  cfg = config.khscodes.vault;
in
{
  options.khscodes.vault = {
    output = {
      approle_auth_backend_role = lib.mkOption {
        type = lib.types.attrsOf (
          khscodesLib.mkSubmodule {
            options = {
              role_name = lib.mkOption {
                type = lib.types.str;
                description = "The name of the role. Can be used instead of hardcoding the role, to create a dependency in OpenTofu";
              };
            };
            description = "vault_approle_auth_backend_role output";
          }
        );
      };
    };
  };
  config = {
    khscodes.vault.output.approle_auth_backend_role = lib.mapAttrs (
      name: value:
      let
        sanitizedName = khscodesLib.sanitize-terraform-name name;
      in
      {
        role_name = "\${ vault_approle_auth_backend_role.${sanitizedName}.role_name }";
      }
    ) cfg.approle_auth_backend_role;
  };
}
