Akamai CLI

The Akamai CLI is a powerful and extensible toolkit that allows you to manage and configure Akamai's platform and various products directly from the command line.

For more information about how to install the Akamai CLI into your local development environment see Akamai CLI. Once you've installed the Akamai CLI you can add the EdgeWorkers and Sandbox CLI packages.

EdgeWorkers CLI

The EdgeWorkers command line interface (CLI) expedites the process of registering, uploading, activating, and testing EdgeWorkers functions on the Akamai Edge network.

Before you install the EdgeWorkers CLI package you need to install the Akamai CLI.

  1. Run this command to install EdgeWorkers CLI:
akamai install edgeworkers
  1. Once you've installed the EdgeWorkers CLI you can manage EdgeWorkers functions by calling the EdgeWorkers API.

    Go to Akamai CLI for EdgeWorkers for an overview of commands you can use to manage your EdgeWorkers.

Sandbox CLI

You can use Sandbox to create an isolated development environment to test your EdgeWorkers functions locally before deploying to the content delivery network.

Before you install the Sandbox CLI package you need to install the Akamai CLI.

You'll also need the EdgeWorker ID and the active version number. You can find this information using the EdgeWorkers Management application.

For more information about how to test site and property changes in an isolated development environment before actual deployment review the Sandbox User Guide.

📘

If you need flexible options and more control, use the Sandbox API to test your EdgeWorkers.

  1. Run this command to install the Sandbox CLI:
akamai install sandbox
  1. You can create a sandbox in one of two ways.

  2. Run this command to create a sandbox based on a hostname in your Property Manager configuration:

akamai sandbox create --hostname www.example.com --name sandbox_for_example.com
  1. Run this command to create a sandbox based on a specific version of a property configuration (this example references version 42):
akamai sandbox create --property example_prod_pm:42 --name sandbox_for_example.com

📘

When creating the sandbox based on a property, the CLI automatically scans the Property Manager configuration, detects all the origin hostnames defined in the file, and asks you to confirm if you want sandbox requests to go directly to these origins.

If you have access to the origins displayed, enter y for yes and the CLI will update your configuration file. If not, see the Sandbox User Guide for more information about how to configure your sandbox client.

  1. Run this command to connect to the sandbox:
akamai sandbox start
  1. You'll see this message confirming that you are connected to the sandbox:

    `INFO c.a.devpops.connector.ConnectorMain - Successfully launched Akamai Sandbox Client` 
    

📘

Once you are connected to the sandbox you need to open a new terminal window to run commands.

  1. Run this command to add an EdgeWorker ID to the sandbox:
akamai sandbox add-edgeworker <edgeworker-id> <edgeworker-tarball>

👍

Run this add-edgeworker command for each EdgeWorker ID in the property.

📘

Sandbox will use the version active in staging if you make a request without adding an EdgeWorker ID.

  1. Test the EdgeWorker IDs that you've added to the sandbox in one of these ways.

    • Browser: Open your /etc/hosts file and point the hostname associated with the property configuration to 127.0.0.1, then enter http://<your-hostname>:9550 in your browser.

    • Curl: Run this command: curl --header 'Host: www.example.com' http://127.0.0.1:9550/

  2. Check for the X-Akamai-Sandbox: true response header, indicating that the request was routed through the sandbox.

📘

All Sandbox traffic is tagged with the X-Akamai-Sandbox: true response header.

See the Enable enhanced debug headers for more information about how to debug the EdgeWorkers script.

  1. Run this command every time you update your EdgeWorkers code:
akamai sandbox update-edgeworker <edgeworker-id> <edgeworker-tarball>
  1. Repeat step 7 each time you update your EdgeWorkers script.

Did this page help you?