---
title: fastly.toml package manifest format
summary: null
url: https://www.fastly.com/documentation/reference/compute/fastly-toml
---

Fastly services provide execution environments for your custom [edge code](https://www.fastly.com/documentation/reference/glossary#term-edge-code). In the case of [VCL services](https://www.fastly.com/documentation/guides/full-site-delivery/fastly-vcl), you can upload VCL source code, which is compiled on the Fastly platform. However, [Compute services](https://www.fastly.com/documentation/guides/compute) are compiled in your own environment using the [Fastly CLI](https://www.fastly.com/documentation/reference/cli), and the resulting binary is uploaded to the Fastly platform.

Compute packages are configured using a `fastly.toml` file in the root of the package directory tree. This file specifies configuration metadata related to a variety of tasks:

1. attribution of the package (e.g., name, author)
2. information required by the `fastly` CLI to compile and upload it to a compatible Fastly service
3. configuration of local server environments
4. bootstrapping of service configuration

In general, you should not write a `fastly.toml` file yourself. Instead, create a new Compute project using the [fastly CLI](https://www.fastly.com/documentation/reference/cli) by executing:

```term
$ fastly compute init
```

This will walk you through the creation of the project and will write the `fastly.toml` file for you.

## Example

The following is an example of a `fastly.toml` file for a project built using our [Rust SDK](https://www.fastly.com/documentation/guides/compute/developer-guides/rust):

```toml title="fastly.toml" linenums
manifest_version = 3
name = "my-compute-project"
description = "A wonderful Compute project that adds edge computing goodness to my application architecture."
authors = ["me@example.com"]
language = "rust"
service_id = "SU1Z0isxPaozGVKXdv0eY"

[scripts]
build = "cargo build --bin fastly-compute-project --release --target wasm32-wasip1 --color always"
```

## Reference

The syntax of fastly.toml is the [TOML format](https://toml.io/).

The TOML format supports comments. A line that begins with a `#` character is ignored:

```toml
# This is a comment.
```

Property names and values are separated by `=`. The following properties are defined for `fastly.toml` files (refer to the [TOML specification](https://toml.io/en/v1.0.0-rc.3) to understand the 'Types' mentioned below):

{/_ NOTE TO MAINTAINERS: The indents in the table below use unicode non-breaking space characters. Don't use regular spaces - they look the same in most editors. _/}

| Property name      | Type          | Description                                                                                                                                                                                                                                                                                                                                                                    |
| ------------------ | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `manifest_version` | Number        | Package manifest schema version number. Currently at version `3`. Any breaking changes to the manifest format should be accompanied by a change to the manifest version and the format changes will be documented here.                                                                                                                                                        |
| `name`             | String        | Name of the package. If there is no `service_id` specified in the same manifest, a new service will be created and this will become the name of the service as well as the name of the uploaded package. If the project is deployed to an existing service, any change to the `name` will update the name of the Compute package, but will not change the name of the service. |
| `authors`          | Array: string | An array of strings, listing email addresses of the authors of the project, for audit purposes. Displayed in the web interface and reported back via the API.                                                                                                                                                                                                                  |
| `cloned_from`      | String        | The source of the project code. Auto-populated when running `fastly compute init`.                                                                                                                                                                                                                                                                                             |
| `description`      | String        | Brief description of the project, for audit purposes. Displayed in the web interface and reported back via the API.                                                                                                                                                                                                                                                            |
| `language`         | String        | Language used for the project. `"rust"`, `"javascript"`, or `"go"` (if using an official Fastly-supported SDK) or `"other"` (if using a [custom SDK](https://www.fastly.com/documentation/guides/compute/developer-guides/custom)). This determines how the `fastly` CLI will compile your project to WebAssembly before it is uploaded to the Fastly edge cloud.              |
| `profile`          | String        | Name of the profile account the Fastly CLI should use to make API requests. The profile consists of a token and email that is associated with a profile 'name'.                                                                                                                                                                                                                |
| `service_id`       | String        | The Fastly service ID of the service to which the `fastly` CLI should deploy the package. If not specified, a new service will be created when the project is deployed.                                                                                                                                                                                                        |
| `setup`            | Table         | Describes a set of service configuration that works with the code in the package. See [setup information](https://www.fastly.com/documentation/reference/compute/fastly-toml#setup-information) below. Ignored if `service_id` is present.                                                                                                                                     |
| `scripts`          | Table         | Customisation options for the Fastly CLI build step. See [Scripts](https://www.fastly.com/documentation/reference/compute/fastly-toml#scripts) below.                                                                                                                                                                                                                          |
| `└─ build`         | String        | Custom shell command to produce a Wasm binary (the output path should be `bin/main.wasm`).                                                                                                                                                                                                                                                                                     |
| `└─ env_file`      | String        | Path to a file containing KEY=VALUE environment variables (one per line) to set in the shell when executing the `post_init`, `build` and `post_build` scripts. Values take precedence over those defined inline using `env_vars` (supported in the [Fastly CLI](https://www.fastly.com/documentation/reference/cli) v10.6.0+).                                                 |
| `└─ env_vars`      | Array: string | Environment variables to set in the shell when executing the `post_init`, `build` and `post_build` scripts.                                                                                                                                                                                                                                                                    |
| `└─ post_build`    | String        | Custom shell command to run after the build step in the Fastly CLI.                                                                                                                                                                                                                                                                                                            |
| `└─ post_init`     | String        | Custom shell command to run after the initialization step in the Fastly CLI (supported in the [Fastly CLI](https://www.fastly.com/documentation/reference/cli) v10.3.0+).                                                                                                                                                                                                      |
| `local_server`     | Table         | Describes the configuration for the local server built into the Fastly CLI, which can be invoked with <kbd>fastly compute serve</kbd>. See [local server](https://www.fastly.com/documentation/reference/compute/fastly-toml#local-server) below.                                                                                                                              |

## Scripts

The `[scripts]` section instructs the [Fastly CLI](https://www.fastly.com/documentation/reference/tools/cli) to run certain commands as part of its compile process.

The `build` property tells the CLI how to compile your project. It must produce a `bin/main.wasm` binary. From version [`v4.0.0`](https://github.com/fastly/cli/releases/tag/v4.0.0) onward, configuring the `build` property is required. When you <kbd>fastly compute init</kbd> the template project we set up for you will have a build script suitable for the language you've chosen to use.

Customizing the build script can be useful when you want to use an alternative build process. For example although our [JavaScript SDK](https://www.fastly.com/documentation/guides/compute/developer-guides/javascript) doesn't require a module bundler such as [webpack](https://webpack.js.org), you could choose to use one by adding it to the build command:

```toml title="fastly.toml"
[scripts]
build = "$(npm bin)/webpack && $(npm bin)/js-compute-runtime ./bin/index.js ./bin/main.wasm"
```

This will prompt webpack to bundle the project's `./src/index.js` into a `./bin/index.js`. `js-compute-runtime` then takes the bundled file and produces the required `./bin/main.wasm` binary. `build` can also be used to swap out an alternative compiler, e.g., to take advantage of [TinyGo's smaller memory footprint in Go projects](https://www.fastly.com/documentation/guides/compute/developer-guides/go).

`post_build` is executed after the Wasm binary has been produced, but before it has been packaged into a `.tar.gz` archive file. This allows for further optimization of the produced Wasm binary if required. Here is an example which defines a `post_build` step for a project built using our [Go SDK](https://www.fastly.com/documentation/guides/compute/developer-guides/go):

```toml title="fastly.toml"
[scripts]
build = "tinygo build -target=wasip1 -o bin/main.wasm ./"
post_build = "wasm-strip bin/main.wasm"
```

`env_vars` should contain an array of key/value pairs defining environment variables you want to have set within the context of the shell that executes your `post_init`/`build`/`post_build` script.

Here is an example of defining `env_vars` for a Go project that wants to use the standard Go compiler instead of the default TinyGo:

```toml title="fastly.toml"
[scripts]
env_vars = ["GOARCH=wasm", "GOOS=wasip1"]
build = "go build -o bin/main.wasm ."
```

`post_init` runs after a project has been initialized, and is ideally suited to run dependency installation processes, such as `npm install` in the case of JavaScript projects.

## Local server

The `[local_server]` section of the `fastly.toml` file specifies how <kbd>fastly compute serve</kbd> should simulate the Fastly platform to enable you to test a package on your local machine.

To see how this configuration is used, read more about [testing and debugging Compute programs](https://www.fastly.com/documentation/guides/compute/developer-guides/testing).

### Data model

{/_ NOTE TO MAINTAINERS: The indents in the table below use unicode non-breaking space characters. Don't use regular spaces - they look the same in most editors. _/}

| Property name                | Type          | Description                                                                                                                                                                                                                                                                                          |
| ---------------------------- | ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `local_server`               | Table         | Describes the configuration for the local server built into the Fastly CLI, which can be invoked with <kbd>fastly compute serve</kbd>.                                                                                                                                                               |
| `└─ viceroy_version`         | String        | The version of [Viceroy](https://github.com/fastly/viceroy), the local server engine, to use. If not specified, the latest will be used and updated automatically.                                                                                                                                   |
| `└─ acls`                    | Table         | A list of [Access control stores](https://www.fastly.com/documentation/guides/security/access-control-lists/about-acls) that should be provided by the local server.                                                                                                                                 |
| `   └─ {name}`               | Table         | Each ACL is a section whose name is the string used as the [resource link](https://www.fastly.com/documentation/reference/api/services/resource) ID.                                                                                                                                                 |
| `      └─ file`              | String        | The path to a JSON file containing the ACL entries. The JSON structure is the same as the [Update an ACL](https://www.fastly.com/documentation/reference/api/acls/acls/#acl-update-request-body-entry) API endpoint.                                                                                 |
| `└─ backends`                | Table         | A list of backends that should be provided by the local server.                                                                                                                                                                                                                                      |
| `   └─ {name}`               | Table         | Each backend is a section whose name is the string used as the backend ID in the package code.                                                                                                                                                                                                       |
| `      └─ url`               | String        | The URL of the server to which to route requests made by the package to this backend. Must contain a scheme and host. May contain a port or path prefix. See below for examples.                                                                                                                     |
| `      └─ override_host`     | String        | Used to override the `Host` header in requests sent to the local server's backends.                                                                                                                                                                                                                  |
| `      └─ cert_host`         | String        | Define the hostname that the server certificate should declare, and turn on validation during backend connections. You should enable this if you are using SSL/TLS, and setting this will enable SSL for the connection as a side effect.                                                            |
| `      └─ use_sni`           | Boolean       | Use SNI when opening the backend connection? Defaults to true.                                                                                                                                                                                                                                       |
| `└─ config_stores`           | Table         | A list of [config stores](https://www.fastly.com/documentation/guides/compute/edge-data-storage/about-edge-data-stores/#about-config-store) that should be provided by the local server.                                                                                                             |
| `   └─ {name}`               | Table         | Each config store is a section whose name is the string used as the config store ID in the package code.                                                                                                                                                                                             |
| `      └─ contents`          | Table         | A section containing inline config store items. Only used when `format` is set to `inline-toml`. See below for examples.                                                                                                                                                                             |
| `         └─ {key}`          | String        | Individual config store items.                                                                                                                                                                                                                                                                       |
| `      └─ file`              | String        | The path to a JSON file containing the config store items that the local server should provide to the app. Only used when `format` is set to `json`. See below for examples.                                                                                                                         |
| `      └─ format`            | String        | The format of the config store items. Supports `json`, `inline-toml`.                                                                                                                                                                                                                                |
| `└─ kv_stores`               | Table         | A list of [KV stores](https://www.fastly.com/documentation/guides/compute/edge-data-storage/about-edge-data-stores) that should be provided by the local server.                                                                                                                                     |
| `   └─ {name}`               | Table / Array | Each KV store is a table or array whose name is the string used as the [resource link](https://www.fastly.com/documentation/reference/api/services/resource) ID.                                                                                                                                     |
| `      └─ file`              | String        | (When `{name}` is a table) Points to a file relative to the project root that contains the KV store test data.                                                                                                                                                                                       |
| `      └─ format`            | String        | (When `{name}` is a table) Describes the format of the file. Required. Must be set to `json`.                                                                                                                                                                                                        |
| `      └─ (array entry)`     | Table         | (When `{name}` is an array) represents a single KV store entry.                                                                                                                                                                                                                                      |
| `         └─ file`           | String        | Points to a file relative to the project root. See below for examples.                                                                                                                                                                                                                               |
| `         └─ data`           | String        | Bytes of data. Note that `file` and `data` are exclusive parameters.                                                                                                                                                                                                                                 |
| `         └─ metadata`       | String        | Bytes of metadata. Optional.                                                                                                                                                                                                                                                                         |
| `└─ secret_stores`           | Table         | A list of [secret stores](https://www.fastly.com/documentation/guides/compute/edge-data-storage/about-edge-data-stores/#about-secret-store) that should be provided by the local server.                                                                                                             |
| `   └─ {name}`               | Table / Array | Each secret store is a table or array whose name is the string used as the resource link ID.                                                                                                                                                                                                         |
| `      └─ file`              | String        | (When `{name}` is a table) Points to a file relative to the project root that contains the secret store test data. See below for examples.                                                                                                                                                           |
| `      └─ format`            | String        | (When `{name}` is a table) Describes the format of the file. Required. Must be set to `json`.                                                                                                                                                                                                        |
| `      └─ (array entry)`     | Table         | (When `{name}` is an array) represents a single secret store entry.                                                                                                                                                                                                                                  |
| `         └─ file`           | String        | Points to a file relative to the project root.                                                                                                                                                                                                                                                       |
| `         └─ data`           | String        | Bytes of data. Note that `file` and `data` are exclusive parameters.                                                                                                                                                                                                                                 |
| `└─ geolocation`             | Table         | A set of geolocation data to use for geolocation related SDK features.                                                                                                                                                                                                                               |
| `   └─ format`               | String        | The format of the geolocation data. Supports `json`, `inline-toml`.                                                                                                                                                                                                                                  |
| `   └─ file`                 | String        | The path to a JSON file containing the geolocation data that the local server should provide to the app. Only used when `format` is set to `file`. See below for examples.                                                                                                                           |
| `   └─ addresses`            | Table         | A table of IP addresses, where each address maps to a set of geolocation data.                                                                                                                                                                                                                       |
| `      └─ {ipaddress}`       | Table         | An IP address                                                                                                                                                                                                                                                                                        |
| `         └─ {geo_variable}` | String        | A geolocation variable. Available keys are `as_name`, `as_number`, `area_code`, `city`, `conn_speed`, `conn_type`, `continent`, `country_code`, `country_code3`, `country_name`, `latitude`, `longitude`, `metro_code`, `postal_code`, `proxy_description`, `proxy_type`, `region` and `utc_offset`. |
| `└─ pushpin`                 | Table         | Describes the configuration for usage with Pushpin to [test realtime messaging features](https://www.fastly.com/documentation/guides/concepts/real-time-messaging/fanout/#local-testing).                                                                                                            |
| `   └─ enable`               | Boolean       | Whether to enable Pushpin in the local development environment.                                                                                                                                                                                                                                      |
| `   └─ pushpin_path`         | String        | (optional) The path to a local installation of `pushpin` binary. If omitted, the system path is searched.                                                                                                                                                                                            |
| `   └─ proxy_port`           | Number        | (optional, advanced) The TCP port to bind the listener for the Pushpin proxy. If omitted, `7677` is used.                                                                                                                                                                                            |
| `   └─ publish_port`         | Number        | (optional, advanced) The TCP port to bind the listener for the Pushpin publisher. If omitted, `5561` is used.                                                                                                                                                                                        |

### ACLs

Local [Access control stores](https://www.fastly.com/documentation/guides/security/access-control-lists/about-acls) can be made available to your application using ACL entries loaded from a referenced JSON file.

For example, if you have the following `my-acl.json` file:

```json title="my-acl.json"
{
  "entries": [
    { "prefix": "1.2.3.0/24", "action": "BLOCK" },
    { "prefix": "127.0.0.0/8", "action": "ALLOW" }
  ]
}
```

You can then define an ACL in your `fastly.toml` file using the entries in `my-acl.json`:

```toml title="fastly.toml"
[local_server]
acls.test-acl = {file = "./my-acl.json"}
```

The ACL can then be referenced from the Compute app as `test-acl`, i.e. in the call to open the ACL.

> **HINT:** The JSON entries file supports the same structure as used in the [Update an ACL](https://www.fastly.com/documentation/reference/api/acls/acls/#acl-update-request-body-entry) api.fastly.com endpoint (the `op` field is ignored).

### Backends

Test backends are local or remote servers to which we should route traffic coming from your package, and act as substitutes for real [backends](https://www.fastly.com/documentation/guides/integrations/non-fastly-services/developer-guide-backends). Each backend is a table and contains a single `url` key:

```toml title="fastly.toml"
[local_server]
  [local_server.backends]
    [local_server.backends.backend_a]
      url = "http://127.0.0.1/"
    [local_server.backends.backend_b]
      url = "https://example.org/"
      override_host = "example.org"
    [local_server.backends.backend_c]
      url = "https://example.org/path/prefix"
      override_host = "example.org"
    [local_server.backends.backend_d]
      url = "http://127.0.0.1:8080/"
```

If the `url` property contains a path component, then any request to that backend will be prefixed with that path. For the example shown above, a request to `GET /foo` issued by your package to the `backend_c` backend will result in a request being made to `https://example.org/path/prefix/foo`.

> **HINT:** Using a path prefix is useful if your service has multiple backends and, in your test environment, you have a single server that is standing in for all of the backends. The one backend-mocking server can use the path prefix to determine which backend is being targeted by the fetch.

### Config stores

Test stores can be defined either as local JSON files that contain the items your app requires to run, or they can be written inline into the fastly.toml file.

For example, if you had an app that required a set of localized strings to be loaded from a config store named `strings`:

```json title="strings.json"
{
  "en.welcome": "welcome",
  "de.welcome": "willkommen",
  "fr.welcome": "bienvenue",
  "es.welcome": "bienvenido"
}
```

You can then reference this store in your `fastly.toml` file:

```toml title="fastly.toml"
[local_server]
  [local_server.config_stores]
    [local_server.config_stores.strings]
      file = "strings.json"
      format = "json"
```

Alternatively you can inline that file directly within the fastly.toml:

```toml title="fastly.toml"
[local_server]
  [local_server.config_stores]
    [local_server.config_stores.strings]
      format = "inline-toml"
    [local_server.config_stores.strings.contents]
      "en.welcome" = "welcome"
      "de.welcome" = "willkommen"
      "fr.welcome" = "bienvenue"
      "es.welcome" = "bienvenido"
```

### KV and secret stores

Local [KV stores](https://www.fastly.com/documentation/guides/compute/edge-data-storage/about-edge-data-stores/) and [secret stores](https://www.fastly.com/documentation/guides/compute/edge-data-storage/about-edge-data-stores/) containing test data can be made available to your application. To do this, create a table entry for the store under `[local_server.kv_stores]` or `[local_server.secret_stores]`, and specify a `file` value of a JSON file relative to the project root and a `format` value of `json`.

> **IMPORTANT:**
> Values written to the local KV store are not persisted when the local development server is terminated.

Populate the JSON file with key-value pairs of the test items in the store, where each key is the string key of each store entry item, and whose value is one of the following:

- a single string used as the data bytes of the store entry

- a JSON object with the fields:
  - `data` - a string used as the data bytes of the store entry
  - `file` - a file relative to the project root that contains the bytes of the store entry
  - `metadata` (KV store only) - a string used as the bytes of the [metadata](https://www.fastly.com/documentation/documentation/reference/api/services/resources/kv-store-item/#metadata) of the store entry

Note that `data` and `file` are mutually exclusive per entry.

Example KV store:

```toml title="fastly.toml"
[local_server.kv_stores]
example_store = { file = '../test/data/example_kv_store.json', format = 'json' }
```

```json title="../test/data/example_kv_store.json"
{
  "first": "This is some data",
  "second": {
    "file": "../test/data/some-object.txt",
    "metadata": "This is some metadata"
  }
}
```

Example secret store:

```toml title="fastly.toml"
[local_server.secret_stores]
example_store = { file = '../test/data/example_secret_store.json', format = 'json' }
```

```json title="../test/data/example_secret_store.json"
{
  "api-key": "api-key-value",
  "cert": {
    "file": "../test/data/some-cert"
  }
}
```

Alternatively, use keys and values defined in the TOML file. To do this, specify an array of objects for the example store containing your test data.

For each entry in your array, specify a `key` value as the string key of each store entry item, along with:

- `data` - a string used as the data bytes of the store entry
- `file` - a file relative to the project root that contains the bytes of the store entry
- `metadata` (KV store only) - a string used as the bytes of the metadata of the KV store entry
- `env` (Secret store only) - the name of an environment variable that contains the bytes of the secret store entry. If
   the environment variable is undefined, then the empty string is used as its value.

Note that `data`, `file`, and (Secret store only) `env` are mutually exclusive per entry.

```toml title="fastly.toml"
[local_server]
  [local_server.kv_stores]
    [[local_server.kv_stores.example_store]]
      key = "first"
      data = "This is some data"
    [[local_server.kv_stores.example_store]]
      key = "second"
      file = "../test/data/some-object.txt"
      metadata = "This is some metadata"
```

```toml title="fastly.toml"
[local_server]
  [local_server.secret_stores]
    [[local_server.secret_stores.example_store]]
      key = "api-key"
      data = "api-key-value"
    [[local_server.secret_stores.example_store]]
      key = "cert"
      file = "../test/data/some-cert"
    [[local_server.secret_stores.example_store]]
      key = "super-secret-value"
      env = "SECRET_VALUE"
```

> **HINT:**
> When using the `env` definition with the Secret store, set the environment variable when starting the local development server. For example:
>
> ```term
> SECRET_VALUE=my-secret-value fastly compute serve
> ```

### Geolocation

Compute SDKs expose geolocation-related features to provide information about the origin of a request. When running within the local server, geolocation data is mocked and if you wish can be defined in the configuration:

```toml
[local_server.geolocation]
  format = "inline-toml"
  [local_server.geolocation.addresses]
    [local_server.geolocation.addresses."127.0.0.1"]
      as_name = "Dummy, Inc."
      city = "New York"
      latitude = 1.23
      longitude = 1.23
```

Alternatively, you can reference an external file by setting `format` to "json" and including a `file` property containing a path to a JSON file. The format of the JSON file is an object where keys are IP addresses and values are the geolocation properties for that IP:

```json
{
  "127.0.0.1": {
    "as_name": "Fastly Test",
    "as_number": 12345,
    "area_code": 123,
    "city": "Test City",
    "conn_speed": "broadband",
    "conn_type": "wired",
    "continent": "NA",
    "country_code": "CA",
    "country_code3": "CAN",
    "country_name": "Canada",
    "latitude": 12.345,
    "longitude": 54.321,
    "metro_code": 0,
    "postal_code": "12345",
    "proxy_description": "?",
    "proxy_type": "?",
    "region": "CA-BC",
    "utc_offset": -700
  }
}
```

### Pushpin

Fanout, the [real-time messaging](https://www.fastly.com/documentation/guides/concepts/real-time-messaging/fanout/) feature of Compute, can be tested in the local testing environment using [Pushpin](https://pushpin.org), the open-source reverse-proxy that Fanout is based on.

> **IMPORTANT:** To test Fanout features in the local development environment, you will need the following:
>
> - [Fastly CLI](https://www.fastly.com/documentation/reference/tools/cli/) version 13.1.0 or newer
> - [Viceroy](https://github.com/fastly/Viceroy) version 0.14.0 or newer (usually managed by Fastly CLI)
> - [a local installation](https://pushpin.org/docs/install/) of Pushpin

To enable this feature, include the `pushpin` section and set `enable` to `true`:

```toml title="fastly.toml"
[local_server.pushpin]
enable = true
```

By default, the Fastly CLI looks for the `pushpin` binary in your system path. To specify the location of `pushpin` in an alternative location, you can set it in the `fastly.toml` file or on the command line when starting the test environment.

To set `pushpin_path` to the path of your local `pushpin` binary:

```toml title="fastly.toml"
[local_server.pushpin]
enable = true
pushpin_path = "/path/to/pushpin"
```

To specify the path to `pushpin` when starting the test environment:

```term
fastly compute serve --pushpin-path=/path/to/pushpin
```

When you run `fastly compute serve`, Pushpin will be configured based on the [defined backends](https://www.fastly.com/documentation/reference/compute/fastly-toml#backends) and started alongside your Compute application, enabling it for "Fanout handoff".

The publishing API is available at `http://localhost:5561/publish/` and cannot be configured.

### Environments

The local server may be invoked with an `--env` argument that specifies the name of an environment. Environments are defined by creating files of the form `fastly.{ENV-NAME}.toml` (e.g., `fastly.staging.toml`), alongside the `fastly.toml` file. Environment-specific files define an alternative configuration for `[local_server]`.

For example, the following configuration matches the one above, except that it defines a different URL for `backend_b`:

```toml title="fastly.staging.toml"
[local_server]
  [local_server.backends]
    [local_server.backends.backend_a]
      url = "http://127.0.0.1/"
    [local_server.backends.backend_b]
      url = "http://localhost:1234/"
    [local_server.backends.backend_c]
      url = "https://example.org/path/prefix"
    [local_server.backends.backend_d]
      url = "http://127.0.0.1:8080/"
```

## Setup information

The optional `[setup]` section of the fastly.toml file allows the Fastly CLI and web interface to provide a smarter experience when a deployment of a package requires a Fastly service to be created, normally when you run <kbd>fastly compute deploy</kbd> for the first time.

Compute programs are able to use features of Fastly services configured outside the program by referring to the feature - such as a backend or config store - by name. It's therefore 

[Starter kits](https://www.fastly.com/documentation/solutions/starters) may include `[setup]` in their fastly.toml file so that the Fastly CLI has all the information needed to create a service in which that starter kit can be deployed.

Once a Compute project is associated with a Fastly service, the `[setup]` data is no longer used, and the service configuration can be managed normally via the web interface, the API, using CLI commands, or [third-party orchestration tooling](https://www.fastly.com/documentation/guides/integrations/non-fastly-services/developer-guide-terraform).

### Data model

{/_ NOTE TO MAINTAINERS: The indents in the table below use unicode non-breaking space characters. Don't use regular spaces - they look the same in most editors. _/}

| Property name                  | Type   | Description                                                                                                                                                                                                                                          |
| ------------------------------ | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `setup`                        | Table  | Describes a set of service configuration that works with the code in the package.                                                                                                                                                                    |
| `└─ backends`                  | Table  | A list of backends that are required to be created on a first run of `compute deploy`.                                                                                                                                                               |
| `   └─ {name}`                 | Table  | The name of the backend used to connect to it from inside the package code, e.g. "api". Required.                                                                                                                                                    |
| `      └─ description`         | String | Label to describe the backend, e.g. "API origin server".                                                                                                                                                                                             |
| `      └─ address`             | String | Hostname or IP address of the backend.                                                                                                                                                                                                               |
| `      └─ port`                | Number | Port number of the backend.                                                                                                                                                                                                                          |
| `└─ config_stores`             | Table  | A list of [config stores](https://www.fastly.com/documentation/guides/compute/edge-data-storage/about-edge-data-stores/#about-config-store) that are required to be created on a first run of `compute deploy`.                                      |
| `   └─ {name}`                 | Table  | The name of the config store used to reference it from inside the package code, e.g. "config". Required.                                                                                                                                             |
| `      └─ description`         | String | Label to describe the store, e.g. "Configuration settings".                                                                                                                                                                                          |
| `      └─ items`               | Table  | List of predefined store items for stores requiring a fixed set of entries.                                                                                                                                                                          |
| `         └─ {key}`            | Table  | The key for the store item. Required.                                                                                                                                                                                                                |
| `            └─ value`         | String | Suggested value for the store item.                                                                                                                                                                                                                  |
| `               └─ input_type` | String | Input type hint, allowing for validation and improved input form usability (not supported in the [Fastly CLI](https://www.fastly.com/documentation/reference/cli)). One of `string`, `number`, `integer`, `email`, `url`, `http-header`, `password`. |
| `            └─ description`   | String | Label to describe the key/value pair.                                                                                                                                                                                                                |
| `└─ kv_stores`                 | Table  | A list of [KV stores](https://www.fastly.com/documentation/guides/compute/edge-data-storage/about-edge-data-stores) that are required to be created on a first run of `compute deploy`.                                                              |
| `   └─ {name}`                 | Table  | The name of the KV store used to reference it from inside the package code, e.g. "data". Required.                                                                                                                                                   |
| `      └─ description`         | String | Label to describe the store.                                                                                                                                                                                                                         |
| `      └─ items`               | Table  | List of predefined store items for stores requiring a fixed set of entries.                                                                                                                                                                          |
| `         └─ {key}`            | Table  | The key for the store item. Required.                                                                                                                                                                                                                |
| `            └─ file`          | String | File path to use as the value for the store item (supported in the [Fastly CLI](https://www.fastly.com/documentation/reference/cli) v10.5.0+).                                                                                                       |
| `            └─ value`         | String | Suggested value for the store item.                                                                                                                                                                                                                  |
| `               └─ input_type` | String | Input type hint, allowing for validation and improved input form usability (not supported in the [Fastly CLI](https://www.fastly.com/documentation/reference/cli)). One of `string`, `number`, `integer`, `email`, `url`, `http-header`, `password`. |
| `            └─ description`   | String | Label to describe the key/value pair.                                                                                                                                                                                                                |
| `└─ secret_stores`             | Table  | A list of [Secret stores](https://www.fastly.com/documentation/guides/compute/edge-data-storage/about-edge-data-stores/#about-secret-store) that are required to be created on a first run of `compute deploy`.                                      |
| `   └─ {name}`                 | Table  | The name of the Secret store used to reference it from inside the package code, e.g. "secrets". Required.                                                                                                                                            |
| `      └─ description`         | String | Label to describe the store.                                                                                                                                                                                                                         |
| `      └─ entries`             | Table  | List of predefined store items for stores requiring a fixed set of entries.                                                                                                                                                                          |
| `         └─ {key}`            | Table  | The key for the store item. Required.                                                                                                                                                                                                                |
| `            └─ description`   | String | Label to describe the key/value pair. The secret value is intentionally omitted to avoid secrets from being included in the manifest. Instead, secret values are input during setup.                                                                 |
| `└─ log_endpoints`             | Table  | A list of [log endpoints](https://www.fastly.com/documentation/guides/integrations/non-fastly-services/developer-guide-logging) that are required to be created on a first run of `compute deploy`.                                                  |
| `   └─ {name}`                 | Table  | The name of the log endpoint used to reference it from inside the package code, e.g. "bigquery_requests". Required.                                                                                                                                  |
| `      └─ provider`            | String | The name of the log provider (e.g. BigQuery, NewRelic etc). Used as part of a generic message to the user indicating the type of provider needed.                                                                                                    |

### Example setup configuration

The following configuration demonstrates how to configure two separate backends (named `httpbin` and `httpme`) and a dictionary populated with two keys (named `s3-primary-host` and `s3-fallback-host`):

```toml
[setup]

  [setup.backends]

    [setup.backends.httpbin]
      address = "httpbin.org"
      description = "A simple HTTP Request & Response Service."
      port = 443

    [setup.backends.httpme]
      address = "http-me.fastly.dev"
      description = "HTTP me is a tiny express app initally designed to replicate the features of HTTPBin.org"
      port = 443

  [setup.config_stores]

    [setup.config_stores.service_config]
      description = "Configuration data for my service"

      [setup.config_stores.service_config.items]

        [setup.config_stores.service_config.items.s3-primary-host]
          value = "eu-west-2"

        [setup.config_stores.service_config.items.s3-fallback-host]
          value = "us-west-1"
```

### Declaring resources without values

It's possible to define resources that are required, but to not provide any configuration for them, other than a name.

```toml title="fastly.toml \[setup] sections with no fields defined"
[setup.backends.api]
[setup.backends.content]
[setup.log_endpoints.request_logger]
```

This configuration states that two backend resources (one called 'api' and the other 'content') and a log endpoint resource (called 'request_logger') are required. When presented with this configuration, the Fastly CLI will prompt the user for the fields relevant to each resource, and a default value provided within the prompt if applicable.
