Create a sandbox with the CLI

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.

Steps

Follow these steps to get up and running quickly with Sandbox.

  1. Enter this command to install the 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
    

📘

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 sets the parameter to ‘yes’. The CLI updates your configuration file. If you want to route sandbox traffic to different development origins, configure your sandbox client.

  1. 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.
    
  2. 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/
  3. 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.

Syntax and examples

Sandbox CLI provides a variety of options to create a sandbox. Use the create [options]command with options as described in the table below.

SyntaxDescription
-r, --rules 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 The hostname of your Akamai property, such as www.example.com.
-c, --clonable Indicates whether sandbox can be replicated by other developers.
-C, --cpcode CP code for sandbox. Unique identifier used for billing and reporting.
-n, --name Name of sandbox.
-H, --requesthostnames Comma-delimited list of request hostnames within the sandbox.
--recipe Path to JSON file that includes customizable sandbox templates.
--origin-from <property | config>Redirect origin traffic to the origins defined in your Akamai property or config file.
-h, --helpDisplay 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
    

👍

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


Did this page help you?