Configuring the cuttle CLI

How to configure 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 an access to staging environment, you can add it with the following command:

## 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 ## go back to default (production) cuttle config context activate default

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>