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
HCP Terraform adds run queue visibility and new ephemeral workspace features
HCP Terraform and Terraform Enterprise gain new features related to ephemeral workspaces along with run queue visibility for HCP Terraform specifically.
Automate AWS deployments with HCP Terraform and GitHub Actions
Learn how to use GitHub Actions to automate HCP Terraform operations.
Access AWS from HCP Terraform with OIDC federation
Securely access AWS from HCP Terraform using OIDC federation, eliminating the need to use access keys.