Getting started with Astra CLI

Initialize the Astra CLI and run your first commands.

Retrieve your application token

The Astra CLI requires an application token to authenticate with Astra. For instructions on how to create an application token, see Manage application tokens.

To increase the security of your Astra account, DataStax recommends that you grant your application token only the bare minimum permissions required to perform the tasks you’ll be running in Astra.

Set up a new configuration

Use the astra setup command to initialize the Astra CLI:

astra setup --token APPLICATION_TOKEN

Replace APPLICATION_TOKEN with your application token. The token format is AstraCS: followed by a unique token string.

Result
[OK]    Configuration has been saved.
[OK]    Setup completed.
[INFO]  Enter 'astra help' to list available commands.

The Astra CLI is now initialized and ready to use.

The Astra CLI configuration, including your application token, is stored in ~/.astrarc. The information in this file is used whenever you run the astra command.

First commands

  • Display the current version of the CLI.

astra --version
  • Display your configuration list, validating setup is complete.

astra config list

Output:

 +-----------------------------------------+
 | configuration                           |
 +-----------------------------------------+
 | alex@altostrat.com                      |
 +-----------------------------------------+

Get Help

Once installed, Astra CLI provides extensive documentation for any command.

It also provides some bash autocompletion, use the TAB key twice to get a list of propositions.

Autocompletion

astra <TAB> <TAB>

Output:

 --no-color  config      db          help        role        setup       shell       user
  • Command-line documentation*

Groups of command will get you the different command avalable.

  • Display main help

astra help

Output:

usage: astra <command> [ <args> ]

Commands are:
    help     View help for any command
    setup    Initialize configuration file
    shell    Interactive mode (default if no command provided)
    config   Manage configuration file
    db       Manage databases
    role     Manage roles (RBAC)
    user     Manage users

See 'astra help <command>' for more information on a specific command.
  • Display help for a command group, such as: astra db

astra help db

Output:

NAME
        astra db - Manage databases

SYNOPSIS
        astra db { cqlsh | create | create-keyspace | delete | dsbulk | get |
                list } [--] [ --token <AUTH_TOKEN> ]
                [ --config-file <CONFIG_FILE> ] [ --no-color ]
                [ {-v | --verbose} ] [ {-conf | --config} <CONFIG_SECTION> ]
                [ --log <LOG_FILE> ] [ {-o | --output} <FORMAT> ] [cmd-options]
                <cmd-args>

        Where command-specific options [cmd-options] are:
            cqlsh: [ --debug ] [ {-f | --file} <FILE> ] [ {-k | --keyspace} <KEYSPACE> ]
                    [ --version ] [ {-e | --execute} <STATEMENT> ] [ --encoding <ENCODING> ]
            create: [ {-k | --keyspace} <KEYSPACE> ] [ --if-not-exist ] [ {-r | --region} <DB_REGION> ]
            create-keyspace: {-k | --keyspace} <KEYSPACE> [ --if-not-exist ]
            delete:
            dsbulk:
            get:
            list:

        Where command-specific arguments <cmd-args> are:
            cqlsh: <DB>
            create: <DB_NAME>
            create-keyspace: <DB>
            delete: <DB>
            dsbulk: [ <dsbulkArguments>... ]
            get: <DB>
            list:

        See 'astra help db <command>' for more information on a specific command.
  • Display help for a specific command, such as: astra db list

For unitary commands all options details are provided.

astra help db list

Output:

NAME
        astra db list - Display the list of Databases in an organization

SYNOPSIS
        astra db list [ {-conf | --config} <CONFIG_SECTION> ]
                [ --config-file <CONFIG_FILE> ] [ --log <LOG_FILE> ]
                [ --no-color ] [ {-o | --output} <FORMAT> ]
                [ --token <AUTH_TOKEN> ] [ {-v | --verbose} ]

OPTIONS
        -conf <CONFIG_SECTION>, --config <CONFIG_SECTION>
            Section in configuration file (default = ~/.astrarc)

        --config-file <CONFIG_FILE>
            Configuration file (default = ~/.astrarc)

        --log <LOG_FILE>
            Logs will go in the file plus on console

        --no-color
            Remove all colors in output

        -o <FORMAT>, --output <FORMAT>
            Output format, valid values are: human,json,csv

        --token <AUTH_TOKEN>
            Key to use authenticate each call.

        -v, --verbose
            Verbose mode with log in console

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com