Skip to main content

Insight | May 23, 2014

The killer Acquia Cloud feature you need to start using right now

By Justin Emond

If you have read our blog you know we are big fans of automation and drush here at Third and Grove. Anytime we can throw a bash script at the problem, we do.

Acquia provides a great platform for running Drupal. The platform is essentially a tuned hosting environment to make Drupal performant and stable and make development a breeze by following best practices. However, Acquia’s killer (and my favorite) feature are Acquia Cloud hooks. Cloud Hooks are very simple at their core: Acquia will run any bash scripts you place in certain folder locations in your repository when certain events occur.

Which events? Three main ones:

  1. After you deploy a new tag or branch (not when you just push code, this is confusing)
  2. After you copy the database from one environment to another
  3. After you copy files from one environment to another

Once you install Acquia Cloud Hooks you will see this self-explanatory folder structure:

  • common
    • post-code-deploy
    • post-db-copy
    • post-files-copy
  • dev
    • post-code-deploy
    • post-db-copy
    • post-files-copy
  • test
    • post-code-deploy
    • post-db-copy
    • post-files-copy
  • prod
    • post-code-deploy
    • post-db-copy
    • post-files-copy

Simply put your bash scripts in the right folder, ensure they have the executable bit (chmod +x blah.sh), push to Acquia and trigger the event. Acquia even passes in helpful event-related context information to each bash script so your script can dynamically adapt to the specifics of the event (like knowing which database was just copied).

OK, now what?

Cloud Hooks are simple but very powerful. What can you do with them? There are lots of possibilities.

One use is to put your site into development or testing friendly mode. We do this for every project we host on Acquia. Using Cloud Hooks we trigger our custom Drush command to reroute email, disable caching, repoint Google Analytics, and a bunch of other things every time the database is copied from production to dev. This means a developer doesn’t have to remember to configure dev after each database copy. Simply drag the database from prod to dev and when the sync is complete the dev site is ready and safe for QA testing.

What else? Using Cloud Hooks you could trigger a cache clear in production when you deploy a new tag (I know you wouldn’t deploy branches to production, right?).

What about Pantheon?

Pantheon is a platform similar to Acquia but built for Drupal and Wordpress. Unfortunately, as of this writing, they don’t have an equivalent feature of which I’m aware. In addition, as I understand it you can’t run bash scripts on Pantheon so our approach won’t work. (This is one reason we have limited our recommendation to clients to host on Pantheon.) It is likely possible for us to use hook_update_N()s instead of bash scripts, but then we would lose the power of lower level *NIX commands with which to script.

More Resources

Drop us a line

Have a project in mind?

Contacting Third and Grove may cause awesomeness. Side effects include a website too good to ignore. Proceed at your own risk.

Reduced motion disabled