12 Terraform providers

 

This chapter covers

  • Using the Terraform Provider Scaffolding template to bootstrap your development
  • Using Terraform Plugin Framework to build a provider
  • Utilizing the provider, data, resource and function interfaces
  • Creating your development environment and enabling local use
  • Signing and publishing your module to a registry

Writing a Terraform provider is not something the average user of Terraform will ever have to do. The reality is that there are a huge number of providers already out there, and most developers can make do with what’s there. That being said, there are several reasons why a developer may decide to build a provider:

  • If a team is building a platform they want other developers to use, then there’s a big advantage in allowing them to control that platform with Terraform. Most companies that are selling a developer-focused platform are likely to consider this, but it can also be true of teams building internal platforms.
  • Teams that are using open source platforms without a provider already written may find themselves writing one. This is what we will be doing in this chapter.
  • Now that it’s possible to create functions in providers, teams may find it useful for certain types of data processing. The open source Terraform Core Functions (https://mng.bz/BX2J) provider is a great example of this.

12.1 Design

12.2 Developer environment

12.2.1 Template

12.2.2 Developer overrides

12.3 Terraform Plugin Framework features

12.3.1 Schemas

12.3.2 Error handling and logging

12.3.3 Testing

12.4 Provider interface

12.4.1 Template cleanup

12.4.2 Provider model and schema

12.4.3 Provider configuration

12.4.4 Provider testing

12.5 Data source

12.5.1 Data source schema

12.5.2 Configure

12.5.3 Read

12.5.4 Registration