Manage Settings & Secrets¶
Most deployments need configuration alongside the code: environment variables for the instance, credentials for the systems an App talks to, and the App's own settings. This page shows how to manage each of them through the API so they can ship with your pipeline.
| What | Where it lives | Sensitive? | Applied when |
|---|---|---|---|
| Instance settings | The instance's environment variables — the Settings tab in the Console | No — stored and shown in the clear | Next Update |
| Secrets | Organization-level, associated with one or more instances, delivered as environment variables | Yes — the value can't be read back | Next Update or Restart |
| App configuration | The App's PLUGINS_CONFIG entry, part of the instance's image |
No — reference a Secret for sensitive values | Next Update |
export NAUTOBOT_CLOUD_TOKEN="<your-token>"
export ORG_ID="<your-organization-id>"
export RESOURCE_ID="<instance-id>"
api() { curl -sf -H "Authorization: Token $NAUTOBOT_CLOUD_TOKEN" -H "Content-Type: application/json" -H "App-Id: ci-deploy" "$@"; }
Instance Settings¶
An instance's settings are its config object — a flat map of environment variable names to values. The object is stored as a whole, so read the current settings, apply your changes, and write the complete object back:
CURRENT=$(api "https://nautobot.cloud/api/resource/$RESOURCE_ID/" | jq '.config')
UPDATED=$(echo "$CURRENT" | jq '. + {"BANNER_TOP": "Development", "MAX_PAGE_SIZE": "500"}')
api -X PATCH "https://nautobot.cloud/api/resource/$RESOURCE_ID/" -d "{\"config\": $UPDATED}"
The change is staged; run an Update to apply it (see Update an Instance). To remove a setting, omit it from the object you write back.
Tip
Use instance settings for non-sensitive, environment-specific values that differ between Development, Staging, and Production. Anything sensitive belongs in a Secret.
Secrets¶
Secrets are created once for the Organization and then associated with the instances that need them. Each Secret is delivered to its instances as an environment variable. See Create & Use Secrets for how they behave.
Create a Secret¶
SECRET_ID=$(api -X POST "https://nautobot.cloud/api/secret/" -d @- <<JSON | jq -r '.id'
{
"name": "my-app-develop API key",
"slug": "MY_APP_DEVELOP_API_KEY",
"env": "MY_APP_API_KEY",
"secret_value": { "MY_APP_API_KEY": "s3cr3t" },
"organization": "$ORG_ID",
"description": "Set by the my-app deployment pipeline."
}
JSON
)
| Field | Description |
|---|---|
name |
Human-readable name shown in the Console. |
slug |
A unique identifier for the Secret within your Organization. Use it to find the Secret again on later runs. |
env |
The environment variable the Secret is exposed as inside the instance. |
secret_value |
A JSON object whose single key is the environment variable name and whose value is the secret. |
Creating a Secret takes a moment. Wait until its state is Available before associating it:
until [ "$(api "https://nautobot.cloud/api/secret/$SECRET_ID/" | jq -r '.state')" = "Available" ]; do sleep 5; done
Update a Secret's value¶
To rotate a credential, write a new value to the existing Secret. Look it up by slug so a re-run of your pipeline updates the Secret it created rather than making a second one:
SECRET_ID=$(api "https://nautobot.cloud/api/secret/?organization__id=$ORG_ID&limit=200" | jq -r '.results[] | select(.slug == "MY_APP_DEVELOP_API_KEY") | .id')
api -X PATCH "https://nautobot.cloud/api/secret/$SECRET_ID/" -d '{"secret_value": {"MY_APP_API_KEY": "n3w-s3cr3t"}}'
The instance reads the new value the next time it starts — run a Restart or an Update to pick it up.
Associate a Secret with an instance¶
api -X POST "https://nautobot.cloud/api/secret/$SECRET_ID/associate/" -d "{\"resources\": [\"$RESOURCE_ID\"]}"
To remove the association, send the same request with -X DELETE. An instance can hold only one Secret per environment variable name, and a Secret that is already associated doesn't need to be associated again — check the Secret's resources list first.
When creating an instance, pass the Secret IDs in associated_secrets so they are available on first start.
Reference a Secret from App Configuration¶
App configuration is visible in the Console, so never write a credential into it directly. Set the field to the Secret's environment variable name prefixed with nautobot_cloud__ instead, as described in Reference a Secret in an App's Configuration. Put the reference in the App configuration you stage on the instance in Step 5:
Associate the Secret with the instance before you stage the configuration; a reference to a Secret that isn't associated is refused.
Putting It Together in a Deployment¶
A deployment that ships code and configuration together does the following, in order:
- Create or update the Secrets and wait for each to be
Available. - Associate any new Secrets with the instance.
- Stage the new image, the App configuration (with Secret references), and any changed instance settings in a single
PATCH. - Trigger the Update, which restarts the instance on the new image with the new settings and Secret values.
The GitHub Actions example implements this sequence — provide sensitive App settings as NAUTOBOT_CLOUD_INSTANCE_SECRETS and it creates the Secrets, associates them, and writes the references into the App configuration for you.