Skip to main content
Hero Background Image

Using Cloud Hooks on Acquia Cloud Hosting

January 15, 2014

As Drupal experts our team at Mediacurrent is very familiar with Acquia’s cloud based hosting solution "Acquia Cloud". In fact, Mediacurrent is an official Acquia Partner. Because of our partnership and because Acquia Cloud is an excellent solution, we end up working with a lot of clients who are utilizing Cloud already or helping clients move on to Acquia’s platform. One of my favorite features of the Acquia Cloud platform is Acquia’s Cloud Hooks system.

What are Cloud Hooks?
Cloud Hooks are a simple automation system that can be used to manage a variety of issues that are typical of a modern cloud hosting setup.

Acquia Cloud Hosting has multiple environments to work in: Develop, Staging and Production. Having full featured Develop, Staging and Production environments is extremely useful for a number of reasons, but can present challenges when managing data and code between the environments.

Acquia Cloud's UI allows users to do push button deployment of code and data between each environment. This is a fantastic feature but can be a headache when there are configuration changes required between environments.  Think of a website architecture where the Staging CDN configuration differs from that on Production, and on Develop the CDN should be disabled completely. This represents a manual change every time data is moved between environments.

Cloud hooks offer an elegant solution to this issue. Cloud Hooks are just scripts that are automatically triggered based on certain actions in the Cloud UI. This gives a lot of flexibility to developers to solve problems and manage configuration.

How do I use Cloud Hooks?
So how do we use cloud hooks? The first step is to check out the cloud hooks repository from github ( This will then be added to the root of your acquia code repository, adjacent to the docroot, in a folder called hooks. The directory structure represents the different actions that we can hook into, and looks like this:


with each base folder (common, prod etc) having three different directories in them, a directory for each action that can be targetted. The actions are:

  • “post-code-deploy”
  • “post-db-copy”
  • “post-files-copy”

by placing a script in the correct directory, it will be executed upon the desired action.

For example:
If we wanted to clean all user passwords from our production data as it comes down to staging and develop, we could create a script to do so and place it in the /hooks/test/post-db-copy and /hooks/dev/post-db-copy directories respectively. When the user moves data down from prod to staging, and then from staging to develop, our scripts would execute.

Cloud Hooks in Practice
Cleaning user data and changing CDN configuration are good examples, but Cloud Hooks cover a wide variety of use cases. At Mediacurrent we have setup Cloud Hook automation to solve a number problems, from managing domain name based translation i18n configuration (and Domain Access sites) to automated code deployment. The Cloud Hooks repository also has a number of examples in the /hooks/samples folder.

Acquia Cloud API
Cloud Hooks can also be called explicitly using the Acquia Cloud API. You will need to submit a ticket to get the API enabled on your account. Once it is enabled, developers can trigger Cloud Hooks via RESTful calls to the provided URI. These can be incorporated into custom scripts or can be used directly with Drush. For example, you could update the Develop servers database with the latest data by using a custom drush command that does aPOST to // This would then also trigger any scripts in the /hooks/dev/post-db-copy and /hooks/common/post-db-copy to sanitize or manipulate the data being copied as needed. Combining this with Acquia's provided Drush Aliases is also an excellent way to allow team members to work with the Acquia Cloud account while avoiding the limitations on access to the Cloud UI.

Cloud Hooks are a powerful automation tool available to Cloud Hosting users. They complement the Cloud UI and allow developers the flexibility to automate deployment tasks between all three environments. Cloud Hooks should be considered whenever preparing to move a site to Acquia Cloud Hosting or when developing one from scratch on that platform.