This guide will explain how to add & use secrets in the environment and inside services. Secrets are sensitive key value pairs that you add at run time to use in your services. You can use secrets to pass credentials to access your database, s3 bucket, OpenAI API, environment name, JWT auth keys, cookie secrets and other environment specific information.Documentation Index
Fetch the complete documentation index at: https://docs.localops.co/llms.txt
Use this file to discover all available pages before exploring further.
When you save secrets, all secrets are encrypted and stored in your connected cloud account’s secret manager. For example, in AWS, all the secrets are encrypted/stored in Parameter Store.LocalOps only stores the
KEY names for reference.Usage & environment vars
LocalOps securely passes each key value pair as environment variable to your service. So you can read them and use in code as you would do for any other environment variable.How to add/update secrets
During service creation
In New Service form, you can see a section called “Secrets”. You can add your key value pairs in that section and create the service. If you don’t have all secrets handy when you are creating the service, you can add them after service created. We don’t deploy a service until you trigger them from UI or via git push.After service creation
Navigate to Environment > Services > Service section to find “Secrets” tab. In there, you can add/update your secrets anytime.Environment level vs Service level secrets
Secrets can be added at two levels:- Environment level
- Service level
Refer global secrets in services
For the secrets added in the global/environment secrets. You can refer them in your service by using the following syntax. For example: If you haveDB_HOST, DB_USER secrets in global secrets, you can refer them in your service by using the
following syntax:
Using service alias in secrets
You can also refer to secrets from other services by using the following syntax: For example: If you haveAPI_KEY secret in another service, you can refer it in your service by using the following
syntax:
$svc-abc is the alias of the service
where the secret is defined.
Importing other service secrets
You can also import all the secrets defined in another service by using a special key.__import_svc as the key and the alias of the service which you want to import as the value. Any secret added in
the current service will override the imported secret.
Built in secrets
Following secrets are passed by default by the platform for convenience.| Secret Key / Environment variable | Value |
|---|---|
LOPS_SVC_HOST | Public domain of a service. Applicable for web service. |
LOPS_INTERNAL_HOST | Private internal host name of a service. Applicable for web or internal services. |
LOPS_PREVIEW | true/false based on whether the service is spun up temporarily for a pull request (PR). |
POD_IP | IP address assigned to a pod. |
HOST_IP | IP address assigned to the node where the service is running. |