Skip to main content

Styra CLI

The Styra CLI is a command-line interface tool that enables users to interact with the Styra platform and manage their policies and data. This section describes the steps to install and configure the Styra CLI on Mac, Linux, and Windows operating systems.

The following table includes the download links for the Styra CLI.

Table 1 - CLI Download Links
OSDownload Link
macOS M1 (ARM CPU)darwin/arm64/styra
macOS (Intel CPU)darwin/amd64/styra
Linux (ARM CPU)linux/arm64/styra
Linux (Intel CPU)linux/amd64/styra
Windowswindows/amd64/styra.exe

Installing the Styra CLI​ on Mac or Linux

The following instructions are used to install the Styra CLI on Mac or Linux.

  1. Download the appropriate CLI binary on your terminal.

    curl -o styra ${STYRA_CLI_URL}
  2. Move the downloaded file into your shell's executable path.

    mv styra /usr/local/bin/styra
  3. Change the permissions of the downloaded file to make it executable.

    chmod u+x /usr/local/bin/styra
  4. Confirm the installation is properly installed.

    styra --help
tip

If you are using a Mac and see an error message that Styra CLI "can't be opened because Apple cannot check it for malicious software" you can add an exception by running:

xattr -d com.apple.quarantine /usr/local/bin/styra

This message only appears once after installing a new version of the Styra CLI.

Installing the Styra CLI​ on Windows

The following instructions are used to install the Styra CLI on Windows.

  1. Download the Styra CLI.

  2. By default, the Styra CLI is downloaded to \Users\%username%\Downloads\styra. While you can choose any folder for the Styra CLI installation, we suggest installing it in \Users%username%\AppData\Local and adding it to your path. This folder is recommended because if you decide to use the Styra VS Code extension, it will automatically keep the Styra CLI binary up to date.

  3. Confirm the installation is properly installed.

    styra --help
tip

If you are running Windows and see an error message from Microsoft that an unrecognized app is prevented from running, click Run anyway. This message only appears once after installing a new version of the Styra CLI.

Authenticate with Styra DAS

To use the Styra CLI, authenticate it with your Styra DAS instance using an API token. This API token can be generated through the Styra DAS UI and establishes authentication through a configuration file or environment variables.

Authenticate using a Configuration File

To authenticate using a configuration file, run the following command:

styra configure

You will be prompted for your secure Styra DAS organization URL (for example, https://das-id.styra.com) and your API token. This command creates a configuration file in your home directory at .styra/config.

Authenticate using Environment Variables

Environment variables can be a useful method for authentication when running Styra CLI commands in a CI/CD environment. To set up this authentication approach, it is recommended that you define the required environment variables in the following table before executing any Styra CLI commands.

ENVVALUE
STYRA_ORGANIZATION_IDYour Styra DAS organization URL without the protocol (for example, <das-id>.styra.com).
STYRA_TOKENThe plain text value of the API token you created using the Styra DAS UI.

Docker Container

The Styra CLI is also available pre-installed in a Docker container downloadable at hub.docker.com/r/styra-cli.

Install the Custom CA Certificates

To enable Styra CLI to access services, a server certificate issued by a custom CA can be configured. To verify the presented certificate from the service, you need to add the corresponding CA certificate to the Styra CLI client. You can specify the directory where the CA certificate(s) are stored in the container by using the environment variable SSL_CERT_DIR. The CA certificates directory can be mounted using the Docker volume option (-v) when launching the Styra CLI container.

For example:

docker run -v $HOME:/home/styra \
-v /host/etc/certs:/container/etc/certs \
-e SSL_CERT_DIR="/container/etc/certs" \
styra/cli