DEV Community

Code[ish]

17. Integrating Terraform with Heroku

Terraform is an open source project to help automate the provisioning of infrastructure resources and services for your application. It integrates with cloud platforms through open source plugins, called providers. Mars Hall is a Heroku engineer that works on the Heroku provider. Rather than using a CLI or a web UI, Terraform provides a platform-agnostic configuration file written in the Hashicorp Configuration Language, or HCL. This sets Terraform apart from similar tools like Chef, which relies on Ruby, or Ansible, which only relies on provisioning server state.

The conversation veers towards the architecture of a provider and how individuals can contribute to the Heroku provider integration. Essentially, a platform exposes some HTTP endpoints that a provider than communicates with. This means that while open source community can contribute to a provider, there are some feature requests which are dependent on the platform exposing accessibility first. Mars suggests that individuals first open an issue with their request, and a Heroku engineer will convey whether that's on the roadmap or free to accept pull requests. Although HCL is easy to learn, all of the providers—and Terraform itself—is written in Go.

Some best practices are provided for larger organizations interested in working with Terraform on Heroku. Among these include strict guidelines for always using Terraform to manage an app's configuration; using consistent naming schemes to indicate that an app is managed by Terraform; and relying on provisioner health checks to help guide Terraform's automation steps. The episode ends with a look forward at the next release of both Terraform and Heroku's provider plugin.

  • Terraform, an open source program to create and change infrastructure, is the core subject for this episode
  • On GitHub, the Terraform Providers organization lists all of the open source providers that work with Terraform
  • Using Terraform with Heroku is a DevCenter article with more information on the integration of Heroku with Terraform

Episode source