Use Sandbox to create an isolated development environment to test your
EdgeWorkers functions locally before deploying to the content delivery network.
Note: If you need flexible options and more
control, use the
Sandbox API to test your EdgeWorkers.
How to
-
Run this command to install Sandbox
CLI:
-
Create a sandbox in one of these ways.
- 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
- 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.
-
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.
-
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.
-
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/
-
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.
-
Run this command every time you update
your EdgeWorkers code:
akamai sandbox update-edgeworker <edgeworker-id> <edgeworker-tarball>
-
Repeat steps 5 and 6 each time you
update your EdgeWorkers script.