The module creates an object storage bucket in Backblaze B2 with optional default server-side encryption (SSE-B2). Key features:

  • access mode selection
  • server-side encrypted (SSE-B2 and AES256) by default
  • lifecycle rules for automatic deletion of hidden file versions

The module supports default server-side encryption using Backblaze B2 native encryption (SSE-B2) with AES256 algorithm.

Log in to Corewide IaC registry

Once you have a Corewide Solutions Portal account, this one-time action will use your browser session to retrieve credentials:

 shellterraform login solutions.corewide.com
Provision instructions

Initialize mandatory providers:

Copy and paste into your Terraform configuration and insert the variables:

 hclmodule "tf_backblaze_b2_bucket" {
  source  = "solutions.corewide.com/backblaze/tf-backblaze-b2-bucket/backblaze"
  version = "~> 1.0.0"

  # specify module inputs here or try one of the examples below
  ...
}

Initialize the setup:

 shellterraform init
Define update strategy

Corewide DevOps team strictly follows Semantic Versioning Specification to provide our clients with products that have predictable upgrades between versions. We recommend pinning patch versions of our modules using pessimistic constraint operator (~>) to prevent breaking changes during upgrades.

To get new features during the upgrades (without breaking compatibility), use ~> 1.0 and run terraform init -upgrade

For the safest setup, use strict pinning with version = "1.0.0"

Storage Bucket in Backblaze B2

Storage Bucket management in Backblaze
Module
15% off
$300
$255
TOTAL $255
BUY
v1.0.0 released 9 months ago

The module creates an object storage bucket in Backblaze B2 with optional default server-side encryption (SSE-B2). Key features:

  • access mode selection
  • server-side encrypted (SSE-B2 and AES256) by default
  • lifecycle rules for automatic deletion of hidden file versions

The module supports default server-side encryption using Backblaze B2 native encryption (SSE-B2) with AES256 algorithm.

Minimal setup with default parameters:

 hclmodule "b2" {
  source  = "solutions.corewide.com/backblaze/tf-backblaze-b2-bucket/backblaze"
  version = "~> 1.0"

  name = "foo"
}

Private encrypted bucket with files retention and a API credentials restricted to this bucket only

 hclresource "b2_application_key" "backup" {
  key_name   = "backup-${module.b2.bucket.bucket_name}"
  bucket_ids = [module.b2.bucket.bucket_id]

  capabilities = [
    "writeFiles",
    "readFiles",
    "listFiles",
    "listBuckets",
  ]
}

module "b2" {
  source  = "solutions.corewide.com/backblaze/tf-backblaze-b2-bucket/backblaze"
  version = "~> 1.0"

  name                      = "foo"
  add_random_suffix         = true
  access_mode               = "private"
  enable_default_encryption = true

  tags = {
    environment = terraform.workspace
  }

  files_retention = {
    file_name_prefix             = ""
    days_from_hiding_to_deleting = 30
  }
}

Outputs with the bucket connection details and access credentials:

 hcloutput "bucket_name" {
  value       = module.b2.bucket.bucket_name
  description = "Name of the B2 bucket"
}

output "bucket_endpoint" {
  value       = module.b2.bucket_endpoint
  description = "Base URL for the S3-compatible API"
}

output "bucket_access_key_id" {
  value       = b2_application_key.backup.application_key_id
  description = "Access key ID for the B2 bucket"
  sensitive   = true
}

output "bucket_secret_access_key" {
  value       = b2_application_key.backup.application_key
  description = "Secret access key for the B2 bucket"
  sensitive   = true
}
Variable Description Type Default Required Sensitive
name B2 bucket name. Minimal length is 6 characters string yes no
access_mode B2 bucket access mode. Allowed values: private, public-read string private no no
add_random_suffix Append a random suffix to the bucket name to ensure uniqueness. Please note: modifying this variable will trigger the re-creation of the bucket bool false no no
enable_default_encryption Enable default bucket server-side encryption (SSE-B2/AES256) bool true no no
files_retention Configures automatic deletion of file versions after N days for files with the specified prefix object {} no no
files_retention.days_from_hiding_to_deleting Specifies how long to retain file versions that are not the current version before permanent deletion number no no
files_retention.file_name_prefix Prefix to filter files the lifecycle rule applies to. If empty, applies to all files in the bucket string no no
tags Tag(s) that must be assigned to the B2 bucket map(string) {} no no
Output Description Type Sensitive
bucket Contains all the B2 Bucket attributes resource no
bucket_endpoint Base URL for the S3-compatible API attribute no
Dependency Version Kind
terraform >= 1.9 CLI
Backblaze/b2 ~> 0.11 provider
hashicorp/random ~> 3.0 provider

Not sure where to start?
Let's find your perfect match.