# Bunny Provider

> Manage Bunny.net CDN and edge computing resources with Pulumi

The Bunny provider enables you to manage Bunny.net CDN, storage, DNS, and edge computing resources using Pulumi. This provider is dynamically bridged from the [Terraform Bunnynet Provider](https://registry.terraform.io/providers/simplesurance/bunny).

## Installation

Install the Bunnynet provider package using your preferred package manager:

<Tabs>
  <Tab title="bun">
    ```bash
    bun add pulumi-bunnynet
    ```
  </Tab>
  <Tab title="pnpm">
    ```bash
    pnpm add pulumi-bunnynet
    ```
  </Tab>
  <Tab title="yarn">
    ```bash
    yarn add pulumi-bunnynet
    ```
  </Tab>
  <Tab title="npm">
    ```bash
    npm install pulumi-bunnynet
    ```
  </Tab>
</Tabs>

## Configuration

### Getting API Key

1. Log in to your Bunny.net account at [bunny.net](https://bunny.net)
2. Navigate to Account → API
3. Copy your API key

### Provider Setup

```bash
pulumi config set bunnynet:apiKey YOUR_API_KEY --secret
```

Or using environment variables:

```bash
export BUNNY_API_KEY="your-api-key"
```

## Quick Start

```typescript
import * as bunnynet from "pulumi-bunnynet";

// Create a pull zone (CDN)
const pullZone = new bunnynet.Pullzone("my-cdn", {
    name: "my-website-cdn",
    origin: {
        type: "OriginUrl",
        url: "https://example.com",
    },
});

export const cdnDomain = pullZone.cdnDomain;
```

## Key Features

### Pull Zones (CDN)

```typescript
const pullZone = new bunnynet.Pullzone("cdn", {
    name: "my-cdn",
    origin: {
        type: "OriginUrl",
        url: "https://origin.example.com",
    },
    cacheEnabled: true,
    cacheExpirationTime: 3600,
});
```

To use a storage zone as the origin instead of a URL:

```typescript
const storageZone = new bunnynet.StorageZone("storage", {
    name: "my-storage",
    region: "DE",
    zoneTier: "Standard",
});

const pullZone = new bunnynet.Pullzone("cdn", {
    name: "my-cdn",
    origin: {
        type: "StorageZone",
        storagezone: storageZone.storageZoneId,
    },
}, { dependsOn: [storageZone] });
```

### Storage Zones

```typescript
const storageZone = new bunnynet.StorageZone("storage", {
    name: "my-storage",
    region: "DE", // Germany
    zoneTier: "Standard",
    replicationRegions: ["NY", "LA"],
});
```

### DNS Management

```typescript
const dnsZone = new bunnynet.DnsZone("dns", {
    domain: "example.com",
});

const dnsRecord = new bunnynet.DnsRecord("www", {
    zone: dnsZone.dnsZoneId,
    name: "www",
    type: "A",
    value: "192.168.1.1",
    ttl: 300,
});
```
