Create a sandbox with the CLI

Quickly create a sandbox at the command line.

Before you begin

Refer to the technical setup requirements.

When you create a sandbox, you need to reference a property on the CDN. The sandbox will inherit hostnames and a rule tree from the property configuration. If you have an Image Manager policy active on the staging network Sandbox automatically applies those setting against traffic in your dev environment. Follow these steps to get up and running quickly.

How to

  1. Enter this command to install Sandbox CLI:
    akamai install sandbox
  2. Create a sandbox based on a hostname in your Property Manager configuration.
    akamai sandbox create --hostname www.example.com --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, then 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.

  4. Test your connection 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/

  5. 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 .

Example

Sandbox CLI provides a variety of options to create a sandbox. Use the create [options] command with options as described in the table below.
Create sandbox options
Syntax Description
-r, --rules <file> Rule tree associated with the Akamai property.
-p, --property <property_id property_name : version> Property to include in the sandbox. If you don’t specify a version number, Sandbox CLI uses the current production version.
-o, --hostname <hostname> The hostname of your Akamai property, such as www.example.com.
-c, --clonable <boolean> Indicates whether sandbox can be replicated by other developers.
-n, --name <string> Name of sandbox.
-H, --requesthostnames <string> Comma-delimited list of request hostnames within the sandbox.
--recipe <path> Path to JSON file that includes customizable sandbox templates.
-h, --help Display usage information.
These code snippets are a few examples of options for creating a sandbox:
  • Create a sandbox based on a hostname in your Akamai property configuration that is currently active on the production network.

    akamai sandbox create --hostname www.example.com --name sandbox_for_example.com

  • 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

  • Create a sandbox based on a specific version of a property configuration and define a custom request hostname you can use in your development machine browser.

    akamai sandbox create --property example_prod_pm:42 --name sandbox_for_example.com --requesthostnames localhost,dev.example.com

  • Create a sandbox by uploading a JSON file that contains a property manager rule tree (this example references rules_example.json).

    akamai sandbox create --rules ~/<rule-tree-path>/rules_example.json --name sandbox_for_example.com --requesthostnames localhost,dev.example.com

Next steps

Review the Sandbox CLI READ ME for a complete list of commands and usage.