Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

External services

An external service is a workspace-owned connection to software that Code as Usual does not install or manage. Built-in fixed-target templates are available for PostgreSQL, MySQL, MariaDB and Redis. The service remains on the customer’s server; Code as Usual controls which project environments receive a private route and credentials for it.

Outbound HTTPS destinations are not external services. Register and publish those separately under Administration → Network access.

Before you register PostgreSQL

In the app: Administration → Environment catalog

Build and publish the PostgreSQL client package if developers should use psql in terminals. It is optional: applications can use the service’s JDBC, host, port and credential variables without installing psql. The external service controls the connection and does not install client programs.

Create a dedicated PostgreSQL account and database outside Code as Usual. Give that account only the database permissions required by the projects that will use the service.

Register and publish a service

In the app: Administration → External services → Register service

Who can do this: a workspace administrator.

  1. Select the required service template.
  2. Enter a stable service key and a recognizable name.
  3. Enter the server name or IP address and TCP port. localhost means the Code as Usual host, not the environment container.
  4. Choose the TLS mode used by that service.
  5. Enter the database, dedicated username and password. For Redis, enter the database index and ACL username expected by that installation.
  6. Save the draft.
  7. For PostgreSQL, select Test connection and wait for it to succeed.
  8. Select Publish.

The PostgreSQL connection test is read-only: it opens and validates a login but does not run application SQL. MySQL, MariaDB and Redis drafts currently validate their fixed-target configuration and encrypted credential, but do not perform a product-protocol login during publication. The password is encrypted before it is stored and is never returned to the browser. A failed draft can be corrected by deleting it and registering a new draft.

Publishing is deliberately separate from registration. A project cannot select an unpublished service; PostgreSQL must additionally pass its connection test.

Give a project access

In the app: Projects → project title → Settings → Environment

  1. Select the published external service.
  2. Optionally select the published PostgreSQL client package if developers should connect interactively with psql.
  3. Save the new project profile revision.
  4. Create a new environment from that profile.

Changing a workspace service or project profile never changes a running environment silently. Every environment stores a receipt for the exact service revision and credential version it received.

Find the connection names

Code as Usual derives a stable variable prefix from the service key. For example, the key development-db becomes:

CAU_SERVICE_DEVELOPMENT_DB

The app shows this prefix and every available variable in three places:

  • Administration → External services → Usage… shows the names that a future attached environment will receive.
  • Project → Environment → Connected services → Usage… shows the exact services attached to that environment.
  • The database icon in an open terminal’s footer opens the same Usage dialog and can insert the psql command directly into that terminal.

The UI deliberately shows variable names, not secret values. You do not need to find or inspect a hidden file to discover how to use a service.

The same information is available inside the running environment for people, scripts and AI agents:

cau-env services
cau-env service <service-id>

The first command lists only services connected to that environment. Use the ID from its first column with the second command. The resulting guide explains the available variables and connection workflow but never prints passwords or resolved secret values.

Variables shared by credentialed services

The following variables are available for PostgreSQL, MySQL, MariaDB and Redis. Replace CAU_SERVICE_DEVELOPMENT_DB with the prefix shown in Usage….

VariablePurpose
CAU_SERVICE_DEVELOPMENT_DB_TYPERegistered service type
CAU_SERVICE_DEVELOPMENT_DB_HOSTPrivate relay host an application in the environment must use
CAU_SERVICE_DEVELOPMENT_DB_PORTPrivate relay port
CAU_SERVICE_DEVELOPMENT_DB_DATABASEDatabase name or Redis database index
CAU_SERVICE_DEVELOPMENT_DB_USERDatabase user or Redis ACL username
CAU_SERVICE_DEVELOPMENT_DB_PASSWORD_FILEPath to the private read-only password file
CAU_SERVICE_DEVELOPMENT_DB_PASSWORDPassword value for clients that cannot read a file
CAU_SERVICE_DEVELOPMENT_DB_TLS_MODERegistered TLS policy
CAU_SERVICE_DEVELOPMENT_DB_BINDING_DIRPrivate directory containing generated files

Configure the selected client or application with the generated relay host and port, not the original server address. Client option names differ between products and versions, so apply the shown TLS policy using that client’s own settings. The application remains responsible for supplying its client library or JDBC driver.

Prefer _PASSWORD_FILE when a program supports it. _PASSWORD exists for frameworks that only accept an environment variable, but environment variables are easier for another process in the same environment to inspect. Never print either form in terminal output or logs.

Use PostgreSQL in a terminal

Open Connected services → Usage… and choose Insert psql command. Code as Usual inserts, but does not execute, a command such as:

PGSERVICEFILE="$CAU_SERVICE_DEVELOPMENT_DB_PGSERVICEFILE" \
  PGSERVICE=code_as_usual psql

Review the command and press Enter. Copy psql command is available when the Usage dialog is opened outside a terminal. These actions require the optional PostgreSQL client runtime package; application variables do not.

The complete PostgreSQL binding is also available to ordinary shell scripts:

VariablePurpose
CAU_SERVICE_DEVELOPMENT_DB_TYPEService type; currently postgresql
CAU_SERVICE_DEVELOPMENT_DB_JDBC_URLComplete JDBC URL through the private relay
CAU_SERVICE_DEVELOPMENT_DB_HOSTHost name an application in the environment must use
CAU_SERVICE_DEVELOPMENT_DB_PORTRelay port
CAU_SERVICE_DEVELOPMENT_DB_DATABASERegistered database name
CAU_SERVICE_DEVELOPMENT_DB_USERRegistered database user
CAU_SERVICE_DEVELOPMENT_DB_PASSWORD_FILEPath to the private read-only password file
CAU_SERVICE_DEVELOPMENT_DB_PASSWORDPassword value for tools that cannot read a file
CAU_SERVICE_DEVELOPMENT_DB_TLS_MODERegistered TLS policy
CAU_SERVICE_DEVELOPMENT_DB_PGSERVICEFILEPath to the generated pg_service.conf
CAU_SERVICE_DEVELOPMENT_DB_PGPASSFILEPath to the generated pgpass
CAU_SERVICE_DEVELOPMENT_DB_BINDING_DIRPrivate directory containing the generated files

Replace CAU_SERVICE_DEVELOPMENT_DB with the prefix shown in the Usage dialog.

Use PostgreSQL from an application

The same binding is available to every terminal and program in the environment. For Java, open Usage… and choose Copy Java example, or use:

String jdbcUrl = System.getenv("CAU_SERVICE_DEVELOPMENT_DB_JDBC_URL");
String user = System.getenv("CAU_SERVICE_DEVELOPMENT_DB_USER");
String passwordFile = System.getenv("CAU_SERVICE_DEVELOPMENT_DB_PASSWORD_FILE");
String password = passwordFile != null
        ? Files.readString(Path.of(passwordFile))
        : System.getenv("CAU_SERVICE_DEVELOPMENT_DB_PASSWORD");

Pass jdbcUrl, user and password to the application’s PostgreSQL driver. The application must still include its own JDBC driver; the external service provides the connection, not Java dependencies.

The generated values point to the environment’s private relay. Do not save resolved values in source code, project configuration or Git. A running environment created before a service was selected does not change silently; create a new environment from the updated project profile. If an application release adds these variables to an already attached environment, stop and resume that environment once so its runtime can be rebuilt with the binding.

Security boundary

  • The environment gets no direct mount of the database host filesystem.
  • The relay can reach only the registered server and port.
  • The environment sees a relay address, while TLS still verifies the original registered server name.
  • Credentials are not shown in the UI, logs or audit messages.
  • _PASSWORD is present only inside an authorized environment for compatibility; _PASSWORD_FILE points to the same credential in a private read-only file.
  • A program running inside an authorized environment can read and use the credential. The relay is a network boundary, not a claim that credentials can be hidden from the client program that must authenticate.
  • Deleting a draft is allowed. Published or historically attached services are retained for audit and safe environment resume.

The installation’s external-service encryption key is part of the private application configuration and must be included in backup and restore. Losing that key makes stored service credentials unreadable.