Follow our new tutorial to build your summer playlist with Terraform using a community-authored Spotify provider. Hear from the author and share your playlist for a chance to win a free HashiCorp T-shirt.
Terraform manages infrastructure by making calls to the APIs of cloud providers like Amazon Web Services, Microsoft Azure, and Google Cloud. It translates your Terraform configuration files into the correct API calls using plugins called providers. HashiCorp and our partners officially maintain some providers, but you can write and publish a provider against any API.
This means Terraform can manage almost any service, not just cloud infrastructure. There are providers that order Dominos pizza and build a fictional coffee shop for learning called HashiCups. Last year, community member Conrad Ludgate wrote a Spotify provider that uses a Terraform data source to search Spotify for an artist, album, or song, and use that data to build a playlist.
See how to use Terraform to build your own Spotify playlist in a new HashCorp Learn tutorial, and read on to hear from Conrad about how he created the provider. Click the link below to read the tutorial and also learn about how you can win a free HashiCorp T-shirt by sharing your own playlist.
We asked Conrad about his experience writing the Spotify provider, and he shared some great advice for anyone who wants to learn more about provider development or contribution.
Q: Why did you write the Spotify provider?
Conrad Ludgate: I love Terraform. I used to write shell scripts using the AWS CLI to set up cloud infrastructure automatically in my CI. It never worked well and would always eventually break. When I started my current job, I learned about Terraform, and instantly knew it was something great.
Eventually, I found myself looking through the
terraform-provider-aws repository to find out which APIs the provider used to create resources. At that point, I realized how simple Terraform providers are to create, and just had to build something of my own. This Spotify provider was a good introduction for me, since I've played around with the API in the past.
Q: That fits with our advice to start learning Terraform by looking at a provider for an API that you already know. What documentation did you rely on when writing the provider?
Conrad: I mostly used the Custom Provider tutorial series on HashiCorp Learn, which introduced me to how providers are set up. I also explored the code of existing providers I already used. That showed me how to structure a big project with many resources.
Q: How was your experience writing and testing the provider?
Conrad: I'm already familiar with Go, so writing the provider was easy for me. Testing was a bit more complicated, and it took me a while to figure out how the testing utilities worked. For the Spotify provider, I did all my testing manually. This was fine, but it eventually got tedious having to build the provider, install it, then run
terraform init and
More recently, I built another provider that's a little bit more serious and figured out how to use the
terraform-sdk test functions combined with an API mock to properly unit test the provider.
Q: How was the process of moving the provider to the registry?
Conrad: Terraform’s documentation for this is superb. Using GoReleaser made the whole thing simple. All I needed was a GPG key and an account on the registry. Then I used that key to sign the release binaries from the provider, and the Terraform register picked them up in minutes.
Q: How has the provider changed since you wrote it?
Conrad: Before v1.0, Terraform went through a lot of changes with each new version. I originally started with v0.11 which was quite a bit different from current versions. Ultimately, the Terraform SDK API didn't change too much, so it didn’t need huge amounts of effort to keep the provider working. Since updating it to work with v0.14, it's still working now on the stable v1.0.
Besides general upkeep, I've gained more experience with creating Terraform providers. I've refactored the code a few times to clean up the general structure and made it much nicer to read through.
Q: That’s great to hear! Are you open to community contributions to the provider?
Conrad: Absolutely! I'm a big fan of open source. I also have some new Terraform provider fun planned for the future once I can find some spare time again (hint, it features Rust). Contribute to the Spotify provider here.
Follow our new HashiCorp Learn tutorial to build and share your Spotify playlist for a chance to win a HashiCorp T-shirt. If Conrad’s story inspired you to write your own provider, follow our custom providers tutorials to get started.
Discover other interesting providers by browsing the Terraform registry.
AWS and HashiCorp are collaborating to develop Terraform modules.
With a live demo, two engineers from Mozilla’s Pocket show how they use CDK for Terraform to define and provision infrastructure in a TypeScript application.
Read this curated list of HashiCorp learning resources to help practitioners and organizations better understand the cloud operating model.