Create and manage Fastly resources with the Fastly CLI

fastly is an open-source command line tool for interacting with the Fastly API. Use it to create services, manage backends and domains, upload VCL or build and deploy Compute packages. Convenient access to Fastly from where you are working with your code, or from your CI environment.

$ fastly backend create --name app_server --address example.edgecompute.app --service-id abcdef1234567890 --version latest
SUCCESS: Created backend app_server (service abcdef1234567890 version 1)

Installing

Option 1: Install a prebuilt binary from the GitHub releases page

Prebuilt binaries are available for multiple operating systems. Un-archive the binary and place it into a directory which is included in your $PATH.

Operating SystemRelease
Linuxx86, amd64, or arm64
macOSamd64 or arm64
Windowsx86, amd64, or arm64

IMPORTANT: You can verify the integrity of the binary using the SHA256 checksums file fastly_x.x.x_SHA256SUMS provided alongside the release.

Option 2: Install a package from the GitHub releases page

Packages are available for Debian-based, Fedora-based, and SUSE-based Linux distributions. Follow the instructions below for your specific distribution:

  • Debian/Ubuntu (Debian-based distributions):

    1. Download the .deb package from the releases page.
    2. Open a terminal and navigate to the directory containing the downloaded file.
    3. Run the following command to install the package:
      sudo apt install ./fastly_<version>_linux_<arch>.deb
    4. Replace <version> and <arch> with the appropriate version and architecture details from the downloaded file.
  • Fedora/CentOS/Rocky Linux/AlmaLinux/Red Hat Enterprise Linux (Fedora-based distributions):

    1. Download the .rpm package from the releases page.
    2. Open a terminal and navigate to the directory containing the downloaded file.
    3. Run the following command to install the package:
      sudo dnf install fastly_<version>_linux_<arch>.rpm
    4. Replace <version> and <arch> with the appropriate version and architecture details from the downloaded file.
  • openSUSE/SUSE Linux (SUSE-based distributions):

    1. Download the .rpm package from the releases page.
    2. Open a terminal and navigate to the directory containing the downloaded file.
    3. Run the following command to install the package:
      sudo zypper in fastly_<version>_linux_<arch>.rpm
    4. Replace <version> and <arch> with the appropriate version and architecture details from the downloaded file.

Option 3: Install using a third-party package manager

The Fastly CLI is available on some third-party package managers.

HINT: Using package managers to install the Fastly CLI is convenient because they are widely available in many environments, and the installation process is the same across these environments.

npm

If Node.js is available on your system, you can obtain the Fastly CLI from npmjs.org and add it to your system globally. Installing the Fastly CLI this way does not tie it to JavaScript, and the result is effectively the same as any of the other installation methods listed.

$ npm install -g @fastly/cli@latest

Homebrew

If Homebrew is available on your system, you can use it to obtain the Fastly CLI and add it to your system globally.

$ brew install fastly/tap/fastly

Verify your installation

After installation, verify that everything works by running fastly version. For example:

$ fastly version
Fastly CLI version vX.Y.Z (abc0001)
Built with go version go1.18 linux/amd64
Viceroy version: viceroy X.Y.Z

You'll be notified if a new version is available. You can update it using the fastly update command.

Configuring

The CLI interacts with Fastly via our API, authenticated using an API token. Configure the CLI to act on your behalf by generating a token in the web interface, then choose one of the following options to give the CLI access to your API token:

  • (Recommended) Run fastly profile create and follow the interactive prompts. This will store your API token credential in a configuration file and remember it for subsequent commands.
  • Include the token explicitly on each command you run using the --token or -t flags.
  • Set a FASTLY_API_TOKEN environment variable.

If authentication credentials are defined in multiple places, they are resolved according to the following order of precedence: command-line flags (highest priority), environment variables, and config file (lowest).

For an overview of all available commands, run fastly with no arguments. Succinct help about any command or subcommand is available via the --help flag (e.g., fastly service --help). For verbose help, use the help command (e.g., fastly help service).

Usage

For a full list of commands available in the Fastly CLI, run fastly help or see the CLI command reference.

Shell auto-completion

The CLI can generate completions for all commands, sub-commands and flags. To install the completions, source them in your ~/.bash_profile (or equivalent):

$ eval "$(fastly --completion-script-bash)"

Or for ZSH in your ~/.zshrc file:

$ eval "$(fastly --completion-script-zsh)"

Reload your profile (or log out and log in again), and you should be able to autocomplete fastly commands by pressing TAB. Try it by typing fastly backen⇥.

Metadata collection

Fastly collects metadata about the Compute programs that you compile using the CLI, in accordance with our data processing and privacy policies. This is what we collect:

  • Build information : Information regarding the time taken for builds and compilation processes that helps us identify bottlenecks and optimize performance.
  • Packages used in source : The list of packages imported in your source code, enabling us to prioritize support and compatibility testing for the most commonly used third-party components.
  • Machine information (requires explicit opt-in): General, non-identifying system specifications (CPU, RAM, operating system) to better understand the hardware landscape our CLI operates in.
  • Script information : Customization options for the CLI build step. See Scripts for reference.

Build, package and script information is collected by default. You'll need to explicitly opt-in to send machine information.

The preferences are recorded in the internal configuration of the CLI, which can be viewed by running fastly config. Here is an example of a CLI configuration that sets data-collection preferences:

[wasm-metadata]
build_info = "[enable|disable]"
machine_info = "[enable|disable]"
package_info = "[enable|disable]"
script_info = "[enable|disable]"

You can selectively enable and disable metadata collection:

# Disable metadata collection on a per-command basis (i.e. disable for this invocation only).
$ fastly compute [build|hash-files|publish|serve] --metadata-disable
# Permanently disable metadata collection.
$ fastly compute metadata --disable
# Permanently enable metadata collection.
$ fastly compute metadata --enable
# Selectively enable or disable certain categories.
$ fastly compute metadata [--enable-build|--disable-build]
$ fastly compute metadata [--enable-machine|--disable-machine]
$ fastly compute metadata [--enable-package|--disable-package]
$ fastly compute metadata [--enable-script|--disable-script]

You can also enable or disable all metadata collection using environment variables, which can be particularly useful when running the CLI in an unsupervised environment such as a CI/CD pipeline.

$ FASTLY_WASM_METADATA_DISABLE=[true|false]

To see what metadata is being collected, run the following command. This data will not be sent to Fastly unless you deploy your Compute service.

$ fastly compute build --metadata-show