Configuring the cuttle CLI
SPEKTRA Edge Context
The cuttle command can switch between multiple settings (called contexts); one context is associated with an Environment and an Account.
To retrieve contexts, use cuttle config context list. This command
displays all contexts contained in the configuration file. Contexts that
are currently enabled are marked with ACTIVE.
Use the cuttle config context set command to add or change contexts.
This command creates a new context if the specified context does not exist,
or updates the existing value if it already exists.
The following is an example of a command that sets the environment and
account respectively in a context named $CONTEXT_NAME.
cuttle config context set $CONTEXT_NAME \}
--environment $ENVIRONMENT_NAME \
--account $ACCOUNT_NAME
| Options | Description |
|---|---|
--active |
Use the current context instead of specifying a context name. In the above example, ߋ$CONTEXT_NAME is no longer needed. |
--environment |
Specify the name of the environment to use in the relevant context. |
--active-environment |
Set the environment enabled for the current context to the relevant context. |
--account |
Specifies the name of the account to use in the relevant context. |
--active-acount |
Set the account enabled in the current context to the relevant context. |
--default-values |
Specifies the values to use by default in the relevant context (see below). |
--default-value-set |
Specify values to be used by default in the relevant context (see below). |
To see list of environments or accounts, you can use:
$ cuttle config environment list
$ cuttle config account list
Context Default Values
Use --default-values or --default-value-set to set default values
for projects and regions used in context. This way you can avoid specifying
--project or --region params when accessing EdgeLQ API.
The following is an example of how to set up a project with $PROJECT and
a region with $REGION.
cuttle config context set --active --default-value-set project=$PROJECT,region=$REGION
To set individual values, specify --default-values.
cuttle config context set --active --default-values project=$PROJECT
If you want to remove the default value, give only the key.
cuttle config context set --active --default-values project
SPEKTRA Edge Environments
The environment (Environment) does not need to be edited by the user if only the commercial environment is used. The settings for the commercial environment are automatically set by default.
If you need access to another SPEKTRA Edge deployment, you can add it as a named environment. Your deployment operator provides the three values below.
Set them once so the commands below can be pasted as-is:
ENV_NAME=my-deployment
AUTH_DOMAIN=auth.example.com
CONTROLLER_DOMAIN=apis.example.com
AUTH_CLIENT_ID=your-client-id
# Add environment
cuttle config environment set $ENV_NAME \
--auth-domain $AUTH_DOMAIN \
--domain $CONTROLLER_DOMAIN \
--auth-client-id $AUTH_CLIENT_ID
# Add context using new environment. Use current account.
cuttle config context set $ENV_NAME --environment $ENV_NAME --active-account
# Activate context
cuttle config context activate $ENV_NAME
# Go back to default (production)
cuttle config context activate default
| Value | Meaning |
|---|---|
$ENV_NAME |
A local name for the environment, used to select it later. |
$AUTH_DOMAIN |
The authentication domain for that deployment. |
$CONTROLLER_DOMAIN |
The API domain for that deployment. |
$AUTH_CLIENT_ID |
The OAuth client ID issued for CLI access to that deployment. |
Example: the stg01b staging environment
stg01b is a commonly used staging deployment. Its values are fixed, so this
block can be pasted as-is:
# Add environment
cuttle config environment set stg01b \
--auth-domain auth-dev.edgelq.com \
--domain stg01b.edgelq.com \
--auth-client-id zQvQ3Js18JLKwySX3haxGLhQ4QgRle4Z
# Add context using new environment. Use current account.
cuttle config context set stg01b --environment stg01b --active-account
# Activate context
cuttle config context activate stg01b
Switch back to the commercial environment when you are finished:
cuttle config context activate default
Adding the environment does not grant access to it. You still need an account on that deployment, and a role binding on the project you intend to use — see Accounts and access.
Most “my project has disappeared” reports are a context left pointing at
staging. cuttle config context list shows the active one, and a project that
exists in the commercial environment is not visible from stg01b, or the
reverse.
SPEKTRA Edge Accounts
The cuttle command allows you to switch between multiple accounts (including service accounts).
A list of accounts can be obtained at cuttle config account list.
To register a new account, use cuttle auth login.
To switch the account used in the current context, give the
cuttle config context set command --account or --active-account.
Login Automation
When using the cuttle command in an environment without human
intervention to automate the process, the use of a service account
avoids the periodic re-login with cuttle auth login and the MFA
processing required for it.
Using ServiceAccount as an Account
By default, cuttle uses User as an Account when accessing EdgeLQ. It is
possible also to use ServiceAccount, more recommended for automated access.
You can create ServiceAccount in a project, if you don’t have one. Note it requires you already have configured cuttle:
# Create service account resource. Each ServiceAccount has its own region,
# but it can use still all the regions (public keys are shared).
$ cuttle iam create service-account $ACCOUNT_ID --parent projects/$PROJECT/regions/$REGION
# Create service account key - and store creds in a file.
$ cuttle iam create service-account-key $KEY_ID --parent projects/$PROJECT/regions/$REGION/serviceAccounts/$ACCOUNT_ID \
--algorithm RSA_2048 --credentials-output-file credentials.json
Assigning roles to ServiceAccount is out of scope of this document, refer to IAM specification.
Once you have credentials.json file, you can add it to the cuttle:
$ cuttle config account add-service-account credentials.json
You can see new account in the list obtained by cuttle config account list.
You may then create new context using this new account name:
$ cuttle config context set <contextName> --environment <envName> --account <accountName>