Starting with CloudShell 9.2, it is possible to store information for later use in the sandbox using the API. This feature is related to this idea.
This capability can be used to store sandbox-specific information that is required for your orchestration processes and shells, like user details, unique IDs returned from 3rd party systems, or data created during the setup process that is needed for teardown.
The data is stored as key-value pairs in a container that is attached to the sandbox and can only be inserted/retrieved via CloudShell Automation API. Note that we don’t impose any limitations on the data and its format, and the data isn’t stored encrypted. Also, for completed sandboxes, the data is kept but cannot be modified.
The following API methods are provided:
SetSandboxData: sets the key-value pairs in the custom data container.
GetSandboxData: retrieves custom data from the sandbox
ClearSandboxData: clears the custom data container
Note that only sysadmins and domain admins can get/set/clear the sandbox data.
So let’s start by setting two key-value pairs: Key1 and Key2:
Now that we have some custom data on the sandbox, let’s learn how to retrieve it:
And finally, let’s learn how to remove the data we stored on the container:
End-to-end example: Managing registration keys for AWS services
In this example, we’ll use a customized setup script to store an authentication key for an AWS CDN service on the sandbox and a customized teardown script that will unregister the CDN service and then clear the metadata from the sandbox. In this example, we assume that a CloudShell service called CDN Service is used to perform the actual registration to Amazon.
Custom setup script that registers an Amazon CDN service:
Custom teardown script that unregisters the CDN service and clears the sandbox metadata:
Using custom sandbox data in JSON format
JSON is a very common data format so we figured we’d include some code samples.