New Terraform Tutorials on Using and Creating Custom Terraform Providers
Learn how to create a custom Terraform provider with this new collection of Terraform tutorials on HashiCorp Learn.
Terraform providers serve as bridges between the Terraform Core and target APIs. We have created a collection of tutorials to show you how to use and create custom Terraform providers. The example provider interacts with a fictional coffee-shop application, HashiCups.
In the first tutorial, Perform CRUD Operations with Providers, you will use the Terraform HashiCups provider to create, read, update, and delete HashiCups resources. In the process, you will be able to see how the provider interacts with the HashiCups API by viewing the HashiCups logs. This tutorial also highlights new updates that Terraform 0.13 brings to providers, such as defining provider source in your configuration and where providers are locally stored.
The remaining tutorials walk you through re-creating the Terraform HashiCups provider using the Terraform Plugin SDK v2.
- In Setup and Implement Read, you will set up the Terraform provider boilerplate and define a Terraform data resource. This allows you to retrieve information from external APIs to use in your Terraform configuration.
- In Add Authentication to a Provider, you will add authentication to the HashiCups provider. This allows you to access protected endpoints so you can create, update, and delete resources.
- In Implement Complex Read, you will add a data source from a protected endpoint. The data model is nested and contains many different data types. As a result, you will use flattening functions to convert the API’s JSON response into a `schema.Resource`.
- In Debug a Terraform Provider, you will add warning and error messages to the provider using `diag.Diagnostics`. This type is new to Terraform Plugin SDK v2 and aims to assist users through debugging.
- In Implement Create, you will add functionality to create a new resource to the provider.
- In Implement Update, you will add functionality to update a resource to the provider.
- In Implement Delete, you will add functionality to delete a resource to a provider.
By the end of this collection, you will be able to take these intuitions to create your own custom Terraform provider.
Sign up for the latest HashiCorp news
More blog posts like this one
Fix the developers vs. security conflict by shifting further left
Resolve the friction between dev and security teams with platform-led workflows that make cloud security seamless and scalable.
HashiCorp at AWS re:Invent: Your blueprint to cloud success
If you’re attending AWS re:Invent in Las Vegas, Dec. 2 - Dec. 6th, visit us for breakout sessions, expert talks, and product demos to learn how to take a unified approach to Infrastructure and Security Lifecycle Management.
Speed up app delivery with automated cancellation of plan-only Terraform runs
Automatic cancellation of plan-only runs allows customers to easily cancel any unfinished runs for outdated commits to speed up application delivery.