11 Extending Terraform by Writing a Custom Provider
This chapter covers:
- Developing a custom Terraform provider from scratch
- Implementing CRUD operations for managed resources
- Writing acceptance tests for the provider schema and resource files
- Deploying a serverless API to listen to requests from the provider
- Building and installing third-party providers
Extending Terraform by writing your own provider is one of the most satisfying things you can do with the technology. It demonstrates a high-level proficiency and grants you the power to bend Terraform to your will. Nevertheless, even the simplest provider is still a considerable investment in time and effort. When might it be worth it to write your own Terraform provider?
Two excellent reasons are:
- Wrapping a remote API so you can manage your infrastructure as code
- Exposing utility functions to Terraform
Almost all Terraform providers wrap remote API’s, because this is what they were designed to do. Recall from chapter 2 that Terraform Core is essentially a glorified state management engine. Without Terraform providers, Terraform would not know how to provision cloud-based infrastructure. By creating a custom provider, you enable Terraform to manage more and new kinds of resources.