Check out v4 of the Fauna CLI
v4 of the Fauna CLI is now in beta. The new version introduces enhancements to the developer experience, including an improved authentication workflow. To get started, check out the CLI v4 quick start. |
fauna create-key
Create a key to access a database.
Syntax
fauna create-key <DBNAME> [<ROLE>] [--[no-]color ]
[--endpoint <value>] [--environment <value>]
[--secret <value>] [--timeout <value>]
[--url <value>]
Description
The create-key
command creates a key that allows access to the DBNAME
database.
The key is assigned one of the following built-in roles:
-
admin
(default) -
server
-
server-readonly
You can’t use this command to create a key in a parent or peer database. To access a database outside of the current database, log in to the Fauna Dashboard.
Arguments
Argument | Description |
---|---|
|
Name of the database to create a key for. |
|
Role. Must be one of:
|
Options
Option | Description |
---|---|
|
Enables or disables color formatting for the output. Color formatting is
enabled by default if the terminal supports it (determined using
chalk/supports-color). Use
|
|
Connection endpoint from |
|
Environment to use, from a Fauna project. |
|
Help for |
|
Authentication secret. Overrides the
secret in Use a scoped key to interact with a child database using a parent database’s admin key. For example, with a parent database’s admin key secret of |
|
Connection timeout (milliseconds). |
|
Database URL. Overrides the URL in |
Example
Create a key for a top-level database
To create a key for a top-level database, pass an empty string to the
--environment
option.
The following command creates a key with the server
role for the top-level
ECommerce
database:
fauna create-key --environment='' ECommerce server
To create a key for a top-level database, you must use a secret scoped to the
account’s top-level context. You can create this secret and use it by default
using the fauna cloud-login
command.
Create a key for a child database
To create a key for a child database, you must use a secret scoped to the parent
database. You can pass a secret using the --secret
option.
The following command creates a key with the server-only
role for the
childDB
child database:
fauna create-key --secret='fn...' childDB server-readonly
Is this article helpful?
Tell Fauna how the article can be improved:
Visit Fauna's forums
or email docs@fauna.com
Thank you for your feedback!