> ## Documentation Index
> Fetch the complete documentation index at: https://bunny.net/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Importing stream library

> Learn how to import an existing Stream library and its associated resources into Terraform.

When you create a Stream library, bunny.net automatically provisions a Pull Zone and Storage Zone. To manage these resources with Terraform, you need to import them into your state.

> [tab] Terraform 1.5+
>
> **1. Define the stream library**
>
> Create or update your Terraform configuration with the stream library resource:
>
> ```hcl theme={null}
> resource "bunnynet_stream_library" "library" {
>   name = "my-library"
> }
> ```
>
> **2. Apply the configuration**
>
> Run apply to create or sync the library:
>
> ```bash theme={null}
> terraform apply
> ```
>
> **3. Add resources with import blocks**
>
> Define the associated Pull Zone and Storage Zone resources, along with import blocks:
>
> ```hcl theme={null}
> resource "bunnynet_pullzone" "pullzone" {
>   name = "my-library-pullzone"
>
>   origin {
>     type        = "StorageZone"
>     storagezone = bunnynet_stream_library.library.storage_zone
>   }
>
>   routing {
>     tier = "Volume"
>   }
> }
>
> resource "bunnynet_storage_zone" "storage" {
>   name      = "my-library-storage"
>   region    = "DE"
>   zone_tier = "Standard"
> }
>
> import {
>   to = bunnynet_pullzone.pullzone
>   id = bunnynet_stream_library.library.pullzone
> }
>
> import {
>   to = bunnynet_storage_zone.storage
>   id = bunnynet_stream_library.library.storage_zone
> }
> ```
>
> **4. Apply to import**
>
> Run apply to import the resources into your Terraform state:
>
> ```bash theme={null}
> terraform apply
> ```
>
> The Pull Zone and Storage Zone are now managed by Terraform.

> [tab] Terraform 1.4 and earlier
>
> **1. Define the stream library**
>
> Create or update your Terraform configuration with the stream library resource:
>
> ```hcl theme={null}
> resource "bunnynet_stream_library" "library" {
>   name = "my-library"
> }
> ```
>
> **2. Apply the configuration**
>
> Run apply to create or sync the library:
>
> ```bash theme={null}
> terraform apply
> ```
>
> **3. Add resources and outputs**
>
> Define the associated Pull Zone and Storage Zone resources, with outputs to retrieve their IDs:
>
> ```hcl theme={null}
> resource "bunnynet_pullzone" "pullzone" {
>   name = "my-library-pullzone"
>
>   origin {
>     type        = "StorageZone"
>     storagezone = bunnynet_stream_library.library.storage_zone
>   }
>
>   routing {
>     tier = "Volume"
>   }
> }
>
> resource "bunnynet_storage_zone" "storage" {
>   name      = "my-library-storage"
>   region    = "DE"
>   zone_tier = "Standard"
> }
>
> output "pullzone_id" {
>   value = bunnynet_stream_library.library.pullzone
> }
>
> output "storage_zone_id" {
>   value = bunnynet_stream_library.library.storage_zone
> }
> ```
>
> **4. Get the resource IDs**
>
> Run plan to retrieve the Pull Zone and Storage Zone IDs from the outputs:
>
> ```bash theme={null}
> terraform plan
> ```
>
> Note the IDs shown in the output.
>
> **5. Import the resources**
>
> Use the IDs to import each resource into your Terraform state:
>
> ```bash theme={null}
> terraform import bunnynet_pullzone.pullzone <pullzone_id>
> terraform import bunnynet_storage_zone.storage <storage_zone_id>
> ```
>
> Replace `<pullzone_id>` and `<storage_zone_id>` with the actual IDs from the previous step.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.