Custom module block programmatically assigning it to a specific role
This is how I did it.

function _&lt;module-name&gt;_check_user_access() {
  $roles = [
    'editor',
    'admin',
  ];


  $current_role = \Drupal::currentUser()-&gt;getRoles();
  foreach($roles as $role) {
    if($role == $current_role[1]) {
      return TRUE;
    }
  }

  return FALSE;
}


See my blog post for more information about it