Easy Storage + Easy Provisioning: Backblaze Is Now a Terraform Provider

Backblaze + HashiCorp Terraform logos

Isn’t it nice when you tell someone to do something, and they just…do it? No step-by-step instructions necessary. For developers, that someone is Terraform, and that something is provisioning infrastructure for large-scale DevOps projects.

Terraform is an open-source infrastructure as code (IaC) tool developed by HashiCorp. Instead of using imperative commands (step-by-step instructions), Terraform uses declarative code (“here’s what I want”). Developers simply describe a desired end state—for example, the number of virtual machines or Kubernetes clusters they need—and Terraform generates and executes a plan for reaching that end state.

Backblaze B2 Cloud Storage is now a provider in the Terraform registry, which will support developers in their IaC efforts. This means you can provision and manage B2 Cloud Storage resources directly from your Terraform configuration file, alongside any other providers that you may already be using in your workflow.

What is infrastructure as code?
Infrastructure as code (IaC) transforms the user interfaces (UI) of infrastructure providers like Backblaze B2 into code. Developers can “provision” or set up the infrastructure they need using that code rather than setting it up manually in the UI or command line interface. Since the set up is codified, it can be automated.

How Does Terraform Work?

Terraform helps developers manage infrastructure at scale for sophisticated software projects. It automates the work of defining, deploying, and updating infrastructure, thus improving speed and reliability and avoiding human error in complex development environments. Because it uses declarative language, you don’t have to worry about the API-level calls between your application and your providers—Terraform handles that for you.

Terraform takes a DevOps-first approach, incorporating best practices in their platform so that you can focus on other needs. For example, it allows you to use the same configuration to provision testing, staging, and production environments rather than rewriting the code for those environments each time, which can introduce mistakes and configuration drift (i.e. when the configuration that you used to provision your environment doesn’t match the actual environment).

Since Terraform is pluggable by design, users have access to the best features of 500+ providers in one platform. Providers can include infrastructure as a service offerings like Backblaze B2, platform as a service companies like Heroku, or software as a service solutions like Cloudflare. For DevOps outfits that need to manage a diverse toolset with a legion of configurations and various kinds of infrastructure for different purposes, Terraform’s automation enables speed and efficiency, reducing operating cost over time.

HashiCorp Terraform logo

How Terraform + Backblaze B2 Delivers Benefits

Developers working in Terraform can now easily tap into Backblaze B2. Using Terraform’s declarative code, you can spin up and maintain B2 Cloud Storage resources including storage buckets and access keys.

Bucket settings, lifecycle settings, and CORS rules all can be controlled via the Terraform configuration file. These settings appear as flags which allow for automated configuration across all your environments. Within that Terraform configuration file, you can also reference a bucket, a single file, or multiple files within a bucket.

This gives developers greater freedom of choice when it comes to cloud storage providers. If you’re using AWS S3 or Google Cloud Storage in Terraform (or any other storage provider) and have considered implementing a multi-cloud approach or switching your cloud provider altogether, this integration enables you to easily set up, test, and start using B2 Cloud Storage—unlocking the astonishing ease, transparent pricing, and affordability the platform is known for.

How to Get Started Using Backblaze B2 in Terraform

After creating your Backblaze B2 account, using B2 Cloud Storage through Terraform is as easy as defining the various resources you want in your Terraform configuration file. For instance, let’s say you want the same Backblaze B2 configuration across your test, staging, and production environments. Instead of manually configuring Backblaze B2 for each environment, you can create a Terraform configuration file to:

  • Provision N public Backblaze B2 buckets.
  • Assign each bucket one access key.
  • Create a secret key for each access key.

You can then apply that configuration file to each of your environments.

Whether you are new to Terraform or are ready to use B2 Cloud Storage as a provider, here’s a step-by-step quickstart guide.

illustration of sending data to the Backblaze cloud

Why Being a Terraform Provider Is Exciting

As software projects become more multifaceted, developers are increasingly relying on IaC and automating code. Adding Backblaze B2 to the IaC “movement” will help developers scale and manage storage resources alongside everything else they control with Terraform.

Providing astonishingly easy cloud storage is our mission. Making provision of that storage easier for developers is part of Terraform’s DNA. Joining the Terraform registry combines easy storage with easy storage automation.

We look forward to continuing to serve the Terraform community and growing our provider functionality.

This open-source release was made possible thanks to our community contributors, Paweł Polewicz (ppolewicz) and Maciej Lech (mlech-reef).
print

About Amrit Singh

Amrit Singh is a product marketer at Backblaze but an engineer at heart, helping developers build and grow their applications on the B2 Cloud Storage platform. He's always looking out for new and innovative ways developers utilize cloud storage to build next-gen tech stacks. So if you want to chat about anything cloud or technology, connect with him on Instagram: @akooms or Linkedin: Amrit Singh.