The command-line interface (CLI) is a downloadable utility you can use to control EdgeKV functionality. It lets you administer EdgeKV without writing code against Akamai’s administrative APIs or using the Akamai Control Center UI. The CLI also enables you to script EdgeKV behaviors. This CLI is fully integrated with the EdgeWorkers CLI, enabling both products to be administered from a single interface.
You can issue commands to trigger activities including database initialization, namespace management, token creation, and CRUD operations.
To use this tool you need:
Usage:
akamai install edgeworkers
Usage:
akamai update edgeworkers
The EdgeWorkers CLI lets you set default values for the command options. There are two ways to create a config file:
~/.akamai-cli/ew-config
, and store the properties as follows:
[default]
edgeworkerName=testEW
groupId=12345
versionId=1-0-2
config
command to set default properties:
akamai edgeworkers config set <key> <value>
Available property names are displayed here.
When installing the Akamai CLI using the “akamai install edgeworkers” command you may run into a “Package directory already exists” error. This is likely because you already have the EdgeWorkers CLI package installed. In this case, please try updating the EdgeWorkers CLI package using “akamai update edgeworkers”.
If you continue to encounter this error when trying to update the Akamai CLI using the “akamai update edgeworkers” command, uninstall the Akamai CLI using the “akamai uninstall edgeworkers” command. This will remove the existing installation, allowing you to reinstall using the “akamai install edgeworkers” command.
Docker installation error
When installing Akamai CLI using docker, you may run into “Error: Cannot find module. ‘.bin/src/edgekv/ekv-cli-main.js”.
Build-time workaround - use this when building the Docker image
RUN akamai install edgeworkers && cd $AKAMAI_CLI_HOME/.akamai-cli/src/cli-edgeworkers/ && npm run build
Runtime workaround - use this if Docker is already running
cd ~/.akamai-cli/src/cli-edgeworkers/ && npm install --unsafe-perm
The EdgeKV CLI –overwrite option for the token create and download commands does not work when you change the token name associated with a namespace.
As a workaround, you can manually delete the token in question from the edgekv_tokens.js file before using the –save_path option. You can then use the token create and download CLI commands with the –save_path option to update the edgekv_tokens.js file.
For a broader list of all known EdgeKV issues please refer to the Akamai TechDocs here.
EdgeKV CLI enables you to manage the EdgeKV database by calling the EdgeKV API from within the utility.
Conventions:
Usage:
akamai edgekv [options] [command]
Options:
Syntax | Description |
---|---|
-V, –version | Display the version number for the EdgeKV CLI program |
–debug | Show debug information. |
–edgerc <path> |
Use credentials in edgerc file for command. (Default file location is ~/.edgerc). Refer to Get Started with APIs for more information. |
–section <name> |
Use this section in edgerc file. (Default section is [default]) |
–configSection <configSection> |
Use this section in the ew-config file that contains the default config properties set. (Default section is [default]) |
–timeout <timeout> |
You can specify a timeout value for a command in seconds to override the 1 minute default. For example, if you add “–timeout 10” to a command, it will timeout if the server takes more than 10 second to respond. |
-h, –help | Display information on how to use this EdgeKV command. |
Commands:
Command | Alias | Description |
---|---|
help [command] |
Display information on how to use the given command. |
initialize | init | Initialize an EdgeKV database. |
show status | Show the status of an EdgeKV database. |
modify db --dataAccessPolicy <databaseDataAccessPolicy> |
Modify the EdgeKV database data access policy. |
create ns <environment> <namespace> --retention <retention> |
Create an EdgeKV namespace in an Akamai environment. Specify the retention period of the namespace in days. |
show ns <environment> <namespace> |
Retrieve an EdgeKV namespace in an Akamai environment. |
list ns <environment> |
List the namespaces provisioned in an Akamai environment. |
modify ns <environment> <nameSpace> |
Modify an EdgeKV namespace in an Akamai environment. |
write <itemType> <environment> <namespace> <groupId> <itemId> <items> |
Write the text item or JSON item supplied in a file for the given namespace, group id, and item id in an Akamai environment. |
read item <environment> <namespace> <groupId> <itemId> |
Read an item for the given namespace, group id, and item id in an Akamai environment. |
delete item | del item <environment> <namespace> <groupId> <itemId> |
Delete an item for the given namespace, group id, and item id in an Akamai environment. |
list items <environment> <namespace> <groupId> |
List the items for the given namespace and group id in an Akamai environment. |
create token | create tkn <tokenName> [options] |
Create an EdgeKV access token. |
list tokens [options] |
List of all tokens the user has permission to download. |
download token <tokenName> [options] |
Download an edgekv token. |
revoke token <tokenName> |
Revoke an EdgKV access token. |
list auth-groups [options] |
List the permission groups with EdgeKV Access. |
list groups <environment> <nameSpace> |
List the data groups for a given namespace in an Akamai environment. |
modify auth-group <namespaceId> <groupId> |
Modify the permission group associated with the namespace. |
config list | Get all values in the config file. |
config get <key> |
Get a config value from a section in the config file. |
config set <key> <value> |
Set a config value in a section. |
config save -p <properties> |
Save config properties in a section. |
config unset <key> |
Unset a config value in a section. |
Return Codes:
Return Code | Description |
---|---|
0 | Command executed successfully. |
1 | Command failed. |
Initialize the EdgeKV database. This action is only required once to initialize your EdgeKV database and provision the default EdgeKV namespace on Akamai’s staging and production environments. It also creates a new, dedicated CP code used to track your EdgeKV usage. Before you can perform any other EdgeKV operations you must successfully complete this step. The EdgeKV Database Data Access Policy - Manage
role is required to initialize an EdgeKV database.
Usage: akamai edgekv initialize
Option | Existance | Description |
---|---|---|
-h, –help | optional | Display information on how to use this EdgeKV command |
–dataAccessPolicy | optional | Set the data access policy.restrictDataAccess : If set to true, the database can only access data from Akamai’s Enhanced TLS network. If set to false, the database can access data from both Akamai’s Enhanced TLS and Standard TLS networks. If you set this option to false your account needs to have EdgeDB::Standard_TLS_Support entitlement.allowNamespacePolicyOverride : If set to true, the database data access policy can be overridden when the namespace is created. If set to false, data access policy overrides are not accepted. |
Check the initialization status of the EdgeKV database
Usage: akamai edgekv show status
Option | Description |
---|---|
-h, –help | Display information on how to use this EdgeKV command |
Modify the EdgeKV database data access policy. This option does not change the data access policy for existing namespaces. It only applies to namespaces created after you successfully apply this option. The EdgeKV Database Data Access Policy - Manage
role is required to modify the database data access policy.
Usage: akamai edgekv modify db --dataAccessPolicy <databaseDataAccessPolicy>
Example: akamai edgekv modify db --dataAccessPolicy='restrictDataAccess=true,allowNamespacePolicyOverride=false'
Option | Existance | Description |
---|---|---|
-h, –help | optional | Display information on how to use this EdgeKV command |
–dataAccessPolicy | required | Set the data access policy.restrictDataAccess : If set to true, the database can only access data from Akamai’s Enhanced TLS network. If set to false, the database can access data from both Akamai’s Enhanced TLS and Standard TLS networks. If you set this option to false your account needs to have EdgeDB::Standard_TLS_Support entitlement.allowNamespacePolicyOverride : If set to true, the database data access policy can be overridden when the namespace is created. If set to false, data access policy overrides are not accepted. |
Create a namespace
Usage: akamai edgekv create ns <environment> <nameSpace>
Option | Existence | Description |
---|---|---|
-h, –help | optional | Display information on how to use this EdgeKV command. |
–retention | Required | Retention period of the namespace in days. |
–groupId | Required | Group identifier. Set it to 0 to allow all groups in your account to access the namespace. If you want to restrict the namespace to a specific group, enter the group id. This value MUST be the same for both the staging and production instances of a namespace. |
–geoLocation | optional | Specifies the persistent storage location for data when creating a namespace on the production network. This can help optimize performance by storing data where most or all of your users are located. The value defaults to US on the STAGING and PRODUCTION networks. For more information refer to the EdgeKV Documenation. |
–dataAccessPolicy | optional | Override the database data access policy.restrictDataAccess : If set to true, the database can only access data from Akamai’s Enhanced TLS network. If set to false, the database can access data from both Akamai’s Enhanced TLS and Standard TLS networks. The database data access policy allowNamespacePolicyOverride needs to be set to true to override the data access policy. |
Argument | Existence | Description |
---|---|---|
environment | required | The Akamai environment on which to create this namespace, either “staging” or “production” |
namespace | required | Namespace identifier. |
Retrieve a list of all namespaces
Usage: akamai edgekv list ns <environment>
Option | Description |
---|---|
-h, –help | Display information on how to use this EdgeKV command. |
-d, –details | Displays details of the namespace. |
–order-by | Choose column to order by when displaying detailed namespace list. |
–asc, –ascending | Sort using acscending order (default). |
–desc, –descending | Sort using descending order. |
Argument | Existence | Description |
---|---|---|
environment | required | The Akamai environment from which to retrieve a list of namespaces, either “staging” or “production”. |
Retrieve the details for a single namespace
Usage: akamai edgekv show ns <environment> <nameSpace>
Option | Description |
---|---|
-h, –help | Display information on how to use this EdgeKV command. |
Argument | Existence | Description |
---|---|---|
environment | required | The Akamai environment from which to retrieve namespace details, either “staging” or “production”. |
namespace | required | Namespace identifier. |
Modify the namespace
Usage: akamai edgekv modify ns <environment> <nameSpace>
Option | Existence | Description |
---|---|---|
-h, –help | optional | Display information on how to use this EdgeKV command. |
–retention | Required | Retention period of the namespace in days. |
Create or update (upsert) a single item into a namespace and group.
Usage: akamai edgekv write <itemType> <environment> <namespace> <groupId> <itemId> <value>
Option | Description | |
---|---|---|
-h, –help | Display information on how to use this EdgeKV command | |
–sandboxId | optional | sandbox-id to use for the data operation. You can use the akamai sandbox list CLI command to view a list of available sandboxes. |
Argument | Existence | Description |
---|---|---|
itemType | required | Item type can be ‘text’ or ‘jsonfile’ |
environment | required | The Akamai environment on which to create or update this item, either “staging” or “production” |
namespace | required | Namespace identifier |
groupid | required | Group identifier |
itemid | required | Item identifier |
value | required | If the itemType is ‘text’ the value can be a text string. If the itemType is ‘jsonfile’ the value can be the path/name of a file containing the item value in valid JSON format. |
Retrieve an item from a namespace and group
Usage: akamai edgekv read item <environment> <nameSpace> <groupId> <itemId>
Option | Description | |
---|---|---|
-h, –help | Display information on how to use this EdgeKV command. | |
–sandboxId | optional | sandbox-id to use for the data operation. You can use the akamai sandbox list CLI command to view a list of available sandboxes. |
Argument | Existence | Description |
---|---|---|
environment | required | The Akamai environment on which to read this item, either “staging” or “production”. |
namespace | required | Namespace identifier |
groupid | required | Group identifier |
itemid | required | Item identifier |
Delete an item in a namespace and group
Usage: akamai edgekv delete item <environment> <nameSpace> <groupId> <itemId>
Option | Description | |
---|---|---|
-h, –help | Display information on how to use this EdgeKV command. | |
–sandboxId | optional | sandbox-id to use for the data operation. You can use the akamai sandbox list CLI command to view a list of available sandboxes. |
Argument | Existence | Description |
---|---|---|
environment | required | The Akamai environment on which to delete this item, either “staging” or “production”. |
namespace | required | Namespace identifier |
groupid | required | Group identifier |
itemid | required | Item identifier |
List items within a namespace and group
Usage: akamai edgekv list items <environment> <nameSpace> <groupId>
Option | Existence | Description |
---|---|---|
-h, –help | Optional | Display information on how to use this EdgeKV command |
–maxItems | Optional | Maximum number of items to return per request, up to the system limits |
–sandboxId | optional | sandbox-id to use for the data operation. You can use the akamai sandbox list CLI command to view a list of available sandboxes. |
Argument | Existence | Description |
---|---|---|
environment | required | The Akamai environment on which to list the items, either “staging” or “production” |
namespace | required | Namespace identifier |
groupid | required | Group identifier |
Create an access token to use within the EdgeWorkers code bundle to authorize access to the EdgeKV database.
Usage:
akamai edgekv create token <tokenName> --save_path=<path> --overwrite --staging={allow|deny} --production={allow|deny} --expiry=<date> --ewids={all|<comma_separated_list_of_ewids> --namespace=<namespace_id>+permissions,<namespace_id>+permissions
Example: ` edgekv create token token1 –save_path=/Documents/hellomgmt.tgz –overwrite –staging=allow –production=deny –ewids=all –namespace=default+rwd,marketing+r –expiry=2020-12-30`
Option | Existence | Description |
---|---|---|
–save_path | Optional | Path specifying where to save the edgekv_tokens.js token file. We recommend that you save the token file in the same location as the EdgeWorkers code bundle file (.tgz). The EdgeWorkers code bundle is then automatically updated every time this command updates the edgekv_tokens.js token file. If a path is not provided the token value is displayed. This token must be securely stored and manually added to the edgekv_tokens.js token file and EdgeWorkers code bundle. |
-o, –overwrite | Optional | This option is used in conjunction with the –save_path option to overwrite the value of an existing token with the same name in the edgekv_tokens.js file. |
–staging | Required | Acceptable value: ‘allow’, ‘deny’. Specifies whether the token will be allowed or denied in the staging environment. |
– production | Required | Acceptable value: ‘allow’, ‘deny’. Specifies whether the token will be allowed or denied in the production environment. |
– ewids | Required | Acceptable value: - ‘all’, - A comma separated list of up to a maximum of 8 EdgeWorker IDs. This restricts token usage to the specified EdgeWorker IDs. |
–namespace | Required | Value: A comma separated list of up to a maximum of 20 namespace identifier and permission combinations. This list specifies where the token can be used. The permissions format is any combination of the following letters: - ‘r’ to authorize the token for read operations - ‘w’ to authorize the token for write operations - ‘d’ to authorize the token for delete operations. Example: “myNamespace1+rwd,myNamespace2+rw” |
–expiry | Optional | Expiration date of the token. Format of the expiry date is ISO 8601 format: yyyy-mm-dd. Optional for Enhanced Token Workflow. |
-h, –help | Optional | Display information on how to use this EdgeKV command. |
Argument | Existence | Description |
---|---|---|
tokenName | required | token name |
List of all tokens the user has permission to download.
Usage: akamai edgekv list tokens
Option | Description |
---|---|
-h, –help | Display information on how to use this EdgeKV command. |
–include-expired | Retrieves both expired and valid tokens. |
Refreshes an EdgeKV Enhanced Token Workflow access token.
Usage:
akamai edgekv refresh token <tokenName>
Argument | Existence | Description |
---|---|---|
tokenName | required | token name |
Retrieve an EdgeKV access token.
Usage:
akamai edgekv download token <tokenName> --save_path=<path> --overwrite
Option | Existence | Description |
---|---|---|
–save_path | Optional | Path specifying where to save the edgekv_tokens.js token file. We recommend that you save the token file in the same location as the EdgeWorkers code bundle file (.tgz). The EdgeWorkers code bundle is then automatically updated every time this command updates the edgekv_tokens.js token file. If a path is not provided the token value is displayed. This token must be securely stored and manually added to the edgekv_tokens.js token file and EdgeWorkers code bundle. |
-o, –overwrite | Optional | This option is used in conjunction with the –save_path option to overwrite the value of an existing token with the same name in the edgekv_tokens.js file. |
-h, –help | Display information on how to use this EdgeKV command. |
Argument | Existence | Description |
---|---|---|
tokenName | required | token name |
Revoke an EdgeKV access token.
Usage:
akamai edgekv revoke token <tokenName>
Argument | Existence | Description |
---|---|---|
tokenName | required | token name |
List the data groups for a given namespace in an Akamai environment.
Usage:
akamai edgekv list groups <environment> <namespace>
Example:
akamai edgekv list groups production default
Option | Description |
---|---|
-h, –help | Display information on how to use this EdgeKV command. |
Argument | Existence | Description |
---|---|---|
environment | required | The Akamai environment from which to retrieve a list of groups, either “staging” or “production”. |
namespace | required | Namespace identifier |
List the permission groups with EdgeKV access
Usage:
edgekv list auth-groups [options]
Example:
edegkv list auth-groups --groupId gid1,gid2 --include_ew_groups
Option | Description |
---|---|
–groupIds | List the EdgeKV access capabilities for the specified permission groups, separated by a comma |
–include_ew_groups | List all permission groups with EdgeKV or EdgeWorkers access capabilities |
-h, –help | Display information on how to use this EdgeKV command |
Modify the permission group associated with the namespace
Usage:
edgekv modify auth-group <namespaceId> <groupId>
Argument | Existence | Description |
---|---|---|
namespaceId | required | Namespace identifier |
groupid | required | Group identifier |
Get all default properties in a section of the config file.
Usage: akamai config list
Option | Existence | Description |
---|---|---|
-h, –help | optional | output usage information |
default
. To use a different section, specify the akamai edgeworkers
command with option --configSection <configSeciont>
.config
commands.Get one specific default value in a section of the config file.
Usage: akamai config get <key>
Option | Existence | Description |
---|---|---|
-h, –help | optional | output usage information |
Argument | Existence | Description |
---|---|---|
key | required | Name of default property |
Allows customers set/update a specific default value in a section of the config file.
Usage: akamai config set <key> <value>
Option | Existence | Description |
---|---|---|
-h, –help | optional | output usage information |
Argument | Existence | Description |
---|---|---|
key | required | Name of default property |
value | required | Value of default property |
Allows customers unset a specific default value in a section of the config file.
Usage: akamai config unset <key>
Option | Existence | Description |
---|---|---|
-h, –help | optional | output usage information |
Argument | Existence | Description |
---|---|---|
key | required | Name of default property |
Allows customers save the default values in bulk.
Usage: akamai config save [options]
Option | Existence | Description |
---|---|---|
-h, –help | optional | output usage information |
-p, –properties | required | Config properties. Use format 'key=value' to set a property and white space to split them. |
For more information on EdgeKV, refer to the following resources:
If you experience any issues with the CLI or feel like there’s anything missing, let us know or simply create an issue or a PR on the repo.