Skip to main content

What you’ll need

Before you begin, make sure you have:

Quickstart

1

Set up your project

Create a new directory and add the provider configuration:
mkdir my-terraform-project
cd my-terraform-project
Create a provider.tf file with the following content:
terraform {
  required_providers {
    bunnynet = {
      source = "BunnyWay/bunnynet"
    }
  }
}

provider "bunnynet" {
  api_key = "your-api-key"
}
You can also use the BUNNYNET_API_KEY environment variable instead of hardcoding your API key. See Authentication for more options.
2

Initialize Terraform

Run the init command to download the bunny.net provider:
terraform init
3

Define your resources

Create a main.tf file with your infrastructure. This example creates a Storage Zone with an index file and a Pull Zone:
resource "bunnynet_storage_zone" "my_storage" {
  name      = "my-project-name"
  zone_tier = "Edge"
  region    = "DE"
}

resource "bunnynet_storage_file" "index" {
  zone    = bunnynet_storage_zone.my_storage.id
  path    = "index.html"
  content = "<h1>Hello world!</h1><p>Deployed with Terraform.</p>"
}

resource "bunnynet_pullzone" "my_cdn" {
  name = bunnynet_storage_zone.my_storage.name

  origin {
    type        = "StorageZone"
    storagezone = bunnynet_storage_zone.my_storage.id
  }

  routing {
    tier = "Standard"
  }
}
Replace my-project-name with your desired project name.
4

Preview and apply

Preview the changes Terraform will make:
terraform plan
Apply the configuration to create your resources:
terraform apply
Type yes when prompted to confirm.
bunnynet_storage_zone.my_storage: Creating...
bunnynet_storage_zone.my_storage: Creation complete after 3s
bunnynet_pullzone.my_cdn: Creating...
bunnynet_pullzone.my_cdn: Creation complete after 0s
bunnynet_storage_file.index: Creating...
bunnynet_storage_file.index: Creation complete after 0s

Apply complete! Resources: 3 added, 0 changed, 0 destroyed.
5

Verify your deployment

Open the bunny.net dashboard to see your new resources. Your content is now being served through the bunny.net CDN.

Next steps

Resources

Explore all available Terraform resources

Data Sources

Query existing bunny.net resources

Authentication

Configure provider authentication options

Provider docs

Official Terraform Registry documentation