Terraform: Building a Custom Provider
Add Terraform support for any API
Topic: System Administration
Do you use APIs that you wish Terraform had a provider for? Maybe you have internally developed APIs that you’d like to manage with Terraform. Or you just want to contribute to the open source providers to help them better support your use cases.
Terraform makes it possible to document and automate the creation, modification, and destruction of almost anything that can be managed by an API. This means that it’s finally conceivable to automate the management of everything that your software stacks needs to actually run in any environment, including cloud resources, domain name system (DNS) entries, content delivery network (CDN) configuration, internal resources, and much more.
Join expert Sean Kane to learn how to build your own custom provider for Hashicorp’s open source and free Terraform tool. You’ll get hands-on running a small API for creating to-do reminders, then use the Go language to build a provider that will allow Terraform to fully manage the objects in the server.
What you'll learn-and how you can apply it
By the end of this live online course, you’ll understand:
- How to use the Go programming language to create a custom Terraform provider that can easily manage almost any REST API
And you’ll be able to:
- Add support for creating, reading, updating, and deleting API objects
- Add support for reading API objects as data sources
- Add support for importing preexisting objects into Terraform state
This training course is for you because...
- You need to understand how to extend Terraform so that you can support more of your infrastructure with a single tool.
- Basic comfort with the Unix command line is helpful
- Basic comfort using REST APIs
- Comfortable using Terraform for simple infrastructure management
- Comfortable reading and writing in Go programming language
- A modern computer and OS
- Recent Linux, OS X, or Windows 10
- Reliable and fast internet connectivity
- Download and run the Hashicorp Terraform (0.12+) installer for your OS
- Go version 1.15 or greater
- Go Swagger
- Docker Desktop & Docker Compose
- A graphical web browser
- A text editor
- Git client
- Read Terraform: Up & Running, second edition (book)
About your instructor
Sean Kane is a lead site reliability engineer at New Relic. He's had a long career in production operations, with many diverse roles across a broad range of industries. Sean is the lead inventor on a container-related patent and spends a lot of his spare time writing, teaching, and speaking about modern production operations. He is an avid traveler, hiker, and camper and lives in the US Pacific Northwest with his wife, children, and dogs.
The timeframes are only estimates and may vary according to how the class is progressing
Introduction (15 minutes)
- Presentation: Terraform overview; terminology; defining the problem
- Hands-on exercise: Install the tools
Exploring the API (40 minutes)
- Presentation: Overview of the Todo API
- Hands-on exercises: Build the API server locally; launch the API server locally; manually manage objects with the Todo API
- Break (5 minutes)
Writing the provider (55 minutes)
- Hands-on exercises: Create the provider—provider.go and provider_test.go; add a resource—resource_todo.go and resource_todo_test.go
- Break (5 minutes)
Extending the provider (60 minutes)
- Hands-on exercises: Add a data source—data_source_todo.go and data_source_todo_test.go; import testing resources; test the provider; build your provider for multiple platforms; build a Terraform provider bundle