Adding a Variable
1
Open the service
Select the service on the canvas, then open the Env Vars tab.
2
Edit
Click Edit environment variables. Add a key and a value for each variable.
Keys are usually uppercase with underscores, like
DATABASE_URL.3
Save, then Apply
Save records your changes on the canvas. They do not reach the running
service until you click Apply and the environment is deployed.
.env file. Suga shows you what it found so you can drop anything you do not want before confirming.
Saved values are hidden by default. Click the eye button beside a value to reveal it.
Secrets
Click the lock button beside a value to mark it Sensitive. The value is encrypted, and once saved it is never shown again in the canvas, in logs, or through the API. You can replace it, but you cannot read it back. You can turn this off while you are still editing. Once you save, the choice is fixed. When you import a.env file, keys that look like secrets are marked sensitive for you. Check the review list before confirming, because saving locks them.
Referencing Another Service
A service often needs a value that belongs to another service, like a database password or the address of an internal API. Rather than copying the value, reference it. Type{{ in a value field. A picker opens listing everything you can reference, and typing filters it. Pick a value and the reference drops in where your cursor was.
A reference looks like this:
Values Suga Provides
Every service receives a set of variables describing where it can be reached. You will mostly use them through references, so one service can read the address of another.
A variable only exists when it applies. A service with no public endpoint has no
SUGA_PUBLIC_HOSTNAME, rather than an empty one. SUGA_TCP_PORT is assigned while the deploy runs, so it is not available on a service that has never been deployed.
To give one service the public address of another, reference it:
A reference to a
SUGA_ value the target does not have, such as the public
hostname of a service with no public endpoint, is not reported as broken. It
resolves to nothing and your service receives the text {{...}} unchanged.
Check that the service you are pointing at has the endpoint you expect.SUGA_ is reserved. You cannot create a variable whose name starts with it.
Build Time and Run Time
The variables above are available while your service runs. A build needs its own, because the build happens before the service exists. Some frameworks read configuration when they build rather than when they start. Values that end up in code the browser downloads are in this group, likeVITE_ variables in a Vite app or NEXT_PUBLIC_ variables in Next.js. Setting these as service variables has no effect, because the build already finished without them.
To set them, open the Config tab, click the pencil on the connected repository to open Edit Build Configuration, and expand Additional Settings.
- On an auto-detected build the field is Environment Variables. Values are available to the build and are not stored in the image.
- On a Dockerfile build the field is Build Arguments. Declare each one with
ARG KEYin your Dockerfile, or the build will not see it. Values passed this way can be read back out of the finished image.
DEPOT_, BUILDKIT_ or GIT_, and common system names like PATH, HOME and NODE_OPTIONS.