Fix Pantheon Site aliases with a policy file

Pantheon automatically generates Drush site alias files for every site.  The canonical URI for a site is sometimes not the one you expect. This can return unexpected drush urls for drush uli, and the command line will report back caches were cleared on a "site" you were perhaps not expecting.

It is preferable to not edit the generated file, so that the local copy may be easily updated with a pristine copy any time the set of available sites changes.

Place a policy.drush.inc folder in ~/.drush/ and you will be golden:

policy.drush.inc
<?php

/**
  * Implements hook_drush_sitealias_alter
  *
  */
function policy_drush_sitealias_alter(&$alias_record) {


  if ($alias_record['uri'] == 'www.greenbizintelligence.org') {
    $alias_record['uri'] = 'www.greenbiz.com';
  }

  if ($alias_record['uri'] == 'new-ee.berkeley.edu') {
    $alias_record['uri'] = 'new-eecs.berkeley.edu';
  }
  if ($alias_record['uri'] == 'dev-ee.berkeley.edu') {
    $alias_record['uri'] = 'dev-eecs.berkeley.edu';
  }

}
 


reference: https://pantheon.io/blog/fix-drush-site-aliases-policy-file