---
layout: "fastly"
page_title: "Fastly: kvstore"
sidebar_current: "docs-fastly-resource-kvstore"
description: |-
  Provides a persistent, globally consistent key-value store accessible to Compute services during request processing.
---

# fastly_kvstore

Provides a persistent, globally consistent key-value store accessible to Compute services during request processing.

-> **Note** The `kv_store` feature does not support seeding the store with data. This is because the size of objects that can be stored is very large and Terraform is designed for containing [configuration, not data](https://developer.fastly.com/learning/integrations/orchestration/terraform/#configuration-not-data). You should use either the [Fastly CLI](https://developer.fastly.com/learning/tools/cli/), [Fastly API](https://developer.fastly.com/reference/api/) or one of the available [Fastly API Clients](https://developer.fastly.com/reference/api/#clients) to populate your KV Store.

## Example Usage

Basic usage:

```terraform
# IMPORTANT: Deleting a KV Store requires first deleting its resource_link.
# This requires a two-step `terraform apply` as we can't guarantee deletion order.
# e.g. resource_link deletion within fastly_service_compute might not finish first.
resource "fastly_kvstore" "example" {
  name = "my_kv_store"
}

resource "fastly_service_compute" "example" {
  name = "my_compute_service"

  domain {
    name = "demo.example.com"
  }

  package {
    filename         = "package.tar.gz"
    source_code_hash = data.fastly_package_hash.example.hash
  }

  resource_link {
    name        = "my_resource_link"
    resource_id = fastly_kvstore.example.id
  }

  force_destroy = true
}

data "fastly_package_hash" "example" {
  filename = "package.tar.gz"
}
```

## Import

Fastly KV Stores can be imported using their Store ID, e.g.

```sh
$ terraform import fastly_kvstore.example xxxxxxxxxxxxxxxxxxxx
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `name` (String) A unique name to identify the KV Store. It is important to note that changing this attribute will delete and recreate the KV Store, and discard the current entries. You MUST first delete the associated resource_link block from your service before modifying this field.

### Optional

- `force_destroy` (Boolean) Allow the KV Store to be deleted, even if it contains entries. Defaults to false.
- `location` (String) The regional location of the KV Store. Valid values are `US`, `EU`, `ASIA`, and `AUS`.

### Read-Only

- `id` (String) The ID of this resource.
