Using Backblaze B2 as State Storage for OpenTofu
Infrastructure as Code (IaC) tools like OpenTofu rely on state files to keep track of the resources they manage. This state file is critical—it’s how OpenTofu knows what’s already been deployed, updated, or destroyed. If you’re looking for a cost-effective, reliable, and scalable storage solution for your state files, Backblaze B2 is an excellent choice.
The good news? Configuring OpenTofu to use Backblaze B2 is a breeze! It’s almost identical to setting up Amazon S3 as the backend, with just a tiny tweak. Let’s walk through it.
Why Choose Backblaze B2?
- Cost Savings: Backblaze B2 offers cloud storage at a fraction of the cost of traditional providers.
- S3 Compatibility: Fully supports the S3 API, so you can reuse familiar configurations.
- Performance and Reliability: Backed by robust infrastructure for seamless operation.
If you’re already comfortable with S3, you’re in for an easy ride. If not, don’t worry—this guide will make you feel like a pro.
The Configuration
Here’s how you can configure OpenTofu to store its state file in Backblaze B2:
- Set Up Your Backend Configuration
In your terraform
block, define the backend as s3
and provide Backblaze-specific settings.
|
|
What’s with all the skip_
settings? They’re required because Backblaze doesn’t support some AWS-specific features like regions and metadata APIs. These skips ensure everything runs smoothly.
- Initialize the Backend
Once your configuration is ready, initialize it with the following command:
Here’s what each flag does:
access_key
: Your Backblaze application key ID.secret_key
: Your Backblaze application key.
What Happens Next?
That’s it! Your state file is now stored securely in Backblaze B2. From this point, you can continue doing some magic and casting spells as usual.
So go ahead, give Backblaze B2 a try!
What is OpenTofu, and Why Does It Matter?
OpenTofu is an open-source alternative to HashiCorp’s Terraform, born after HashiCorp switched Terraform’s licensing model from open-source to the more restrictive Business Source License (BSL). OpenTofu is a community-driven fork of Terraform, ensuring that infrastructure-as-code (IaC) tools remain truly open and accessible to everyone.
Why OpenTofu Matters:
- True Open-Source: Maintains an open license, enabling collaboration and innovation without restrictions.
- Continuity: Provides a drop-in replacement for Terraform users, ensuring seamless adoption with existing configurations.
- Community-Driven: Built and governed by a growing community of developers, prioritizing users’ needs over corporate interests.
- Future-Proof: Protects IaC tools from sudden licensing changes that could disrupt workflows.
OpenTofu is more than a fork—it’s a stand for openness and trust in the infrastructure ecosystem.