Sandbox CLI

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

Before you begin

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

Add the EdgeWorkers behavior to a property and Create a code bundle. To test using the Sandbox CLI you'll need the EdgeWorker ID and the active version number. You can find this information using the EdgeWorkers Management application. See the Sandbox User Guide for more information about how to test site and property changes in an isolated development environment before actual deployment.

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

How to

  1. Run this command to install Sandbox CLI:
    akamai install sandbox
  2. Create a sandbox in one of these ways.
    1. 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
      
    2. 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
      
    Note: 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.
  3. Run this command to connect to the sandbox:
    akamai sandbox start
    You will see this message confirming that you are connected to the sandbox:
    INFO c.a.devpops.connector.ConnectorMain - Successfully launched Akamai Sandbox Client 
    Note: Once you are connected to the sandbox you need to open a new terminal window to run commands.
  4. Run this command to add an EdgeWorker ID to the sandbox:
    akamai sandbox add-edgeworker <edgeworker-id> <edgeworker-tarball>
    Important: Run this add-edgeworker command for each EdgeWorker ID in the property.
    Note: Sandbox will use the version active in staging if you make a request without adding an EdgeWorker ID.
  5. Test the EdgeWorker ID's 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/

  6. Check for the X-Akamai-Sandbox: true response header, indicating that the request was routed through the sandbox.
    Note: All Sandbox traffic is tagged with the X-Akamai-Sandbox: true response header .
    See the Debugging section for more information about to debug the EdgeWorkers script.
  7. Run this command every time you update your EdgeWorkers code:
    akamai sandbox update-edgeworker <edgeworker-id> <edgeworker-tarball>
  8. Repeat steps 5 and 6 each time you update your EdgeWorkers script.