Infrastructure provisioning using Terraform

- By Ankul Kumar


You can now provision infrastructure using Terraform through Shippable builds without having to worry about  merge conflicts in state files. If you aren't familiar with it, Terraform is a tool for building, changing and versioning infrastructure safely and efficiently. It can manage existing and popular service providers as well as  a part of a custom in-house solution. You can now use Terraform to provision your infrastructure in Shippable. Here's how to get started:

Step 1: Create Terraform project

Create a Terraform project with the required infrastructure configuration. You can clone our sample Terraform project from GitHub to get started. In addition, your project should also have a shippable.yml file. Here is a sample shippable.yml file as a starting point:


language: none



   - FOO=”bar”

  -  secure: <encrypted output>



   - cp -vr /shippableci/shippable/provision/terraform.tfstate .


   - terraform apply



   - cp -fvr terraform.tfstate /shippableci/shippable/provision








Here is a guide key components of the sample shippable.yml file:
  • The `pre_prov` section has script(s) that you want to execute before provisioning (eg. `terraform plan` or copying file from `/shippableci/shippable/provision` to project directory).
  • The `prov` section has script(s) for provisioning infrastructure. If this section is not present in shippable.yml, `terraform apply` will be executed by default.
  • The `post_prov` section has script(s) that you would like to run after provisioning (eg. copying new state file from project directory to `/shippableci/shippable/provision`).
  • You can encrypt your secure environment variables and use them in env tag. (Instructions for doing this can be found in the Shippable documentation.)

Step 2: Add project on Shippable

  1. Push this project to your GitHub or Bitbucket private repository.
  2. Login to Shippable, go to `Account Settings`, and sync your account by click on `Sync`.
  3. Go to your subscription, Click on `Infra` tab and click on `Enable Project`terraform4.png

     4. Find your terraform project in the list and click on `Enable` button.terraform1.png

     5. Your project will now show up in the `Infra` tab. Click on the `Provision` button to start provisioning your infrastructure.terraform3.png

     6. Once the build completes infrastructure will be provisioned:


NOTE: '/shippableci/shippable/provision' is a generic folder to save and restore all files. You should put new files back in this folder to be saved for next provision in the `on_success` section of the 'infra' tag. Let us know if you want Shippable to support your favorite provisioning tools!

Try Shippable

Topics: terraform