Secret collections¶
Learn how to manage secrets (create, get, update, delete) and make runs with your tool of choice.
- CLI: the Nextmv Command Line Interface (CLI).
- Python SDK: a Software Development Kit (SDK) for Python developers.
- Cloud API: an HTTP API for developers to integrate with the Nextmv platform.
A secret collection defines one or more secrets used by your optimization model during execution. You can reference a secret collection either in an application instance configuration, or directly when starting a run. The platform then injects the secrets into the container during the optimization run as environment variables and files.
A secret collection can contain up to 20 secrets. Each secret has the following attributes:
- Type: determines how to inject the secret into the runtime.
env: the secret is injected as an environment variable.file: the secret is injected as a file.
- Location: specifies where to put the secret.
- For
envtype, it's the name of the environment variable to use, such asACME_LICENSE_KEY. - For
filetype, it's the relative path to the execution directory for the file, for examplelicenses/acme.lic. Files are stored relative to the execution home directory. You cannot store a secret above the home directory (ie/mydir/myfilewill be located at./mydir/myfilefrom the perspective of your optimization code). The execution directory is considered to be where theapp.yamlmanifest file is located.
- For
- Value: the actual value of the secret. This value must be text, and is
limited to 1 KB.
- For
envtype, the value is the value of the environment variable. - For
filetype, the value is the content of the file.
- For
Secret values are write-only¶
Once set, a secret value cannot be retrieved through the Cloud API, the
Python SDK, the CLI, or Console. When you get a secret collection, every
secret value is replaced with the masked placeholder ***************. The
type and location of each secret stay visible, so you can still inspect
which secrets a collection contains. Runs that use the collection still
receive the real secret values.
Because the masked placeholder is never a real value, any secret value equal
to *************** is rejected with a 400 Bad Request error when creating
or updating a secret collection.
Updating a secret collection¶
All updates to a secret collection go through the partial-update (PATCH)
endpoint. In a single request, you can:
- Change the name and/or description of the collection.
- Create, update, or delete individual secrets, identified by their type and location.
You only send the changes you want to make, so you never need to resend the values of the secrets you are not changing. The request is applied completely or not at all. To change the location of a secret, delete it and create a new one, providing its value again.