> ## Documentation Index
> Fetch the complete documentation index at: https://inframan.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Connections

> Connect a service to another service, a database, a cache or a bucket. Inframan fills in the address and keeps it pinned to the right version.

A **connection** tells Inframan that one service depends on something else: another service, a PostgreSQL or Redis add-on, or a Storage bucket. You choose the environment variable's name, and Inframan fills in its value every time it deploys.

Use a connection, never a hard-coded value in `env`, for any address inside the platform. Addresses change between releases, and passwords rotate. Connections keep up with both.

```yaml inframan.yaml theme={null}
services:
  web:
    port: 3000
    connections:
      API_URL: service/shop/api
  api:
    port: 8080
    connections:
      DATABASE_URL: postgres/main
      REDIS_URL: redis/cache
      UPLOADS_BUCKET: storage/uploads
```

## What you can connect to

| Slug | The variable receives |
| - | - |
| `service/<application>/<service>` | The internal URL of a web service, such as `http://api-v42-00001.shop.svc.cluster.local` |
| `postgres/<instance>` | A PostgreSQL URL with credentials. See [PostgreSQL](https://inframan.mintlify.site/provision/add-ons/postgresql.md). |
| `redis/<instance>` | A Redis URL with its password. See [Redis](https://inframan.mintlify.site/provision/add-ons/redis.md). |
| `storage/<instance>` | The bucket's name. The service must be granted the bucket first. See [Storage](https://inframan.mintlify.site/provision/add-ons/storage.md). |

A service slug always names the application as well as the service, because two applications can each have a service called `api`. The target must be a web service.

## Versions stay in step

Every release deploys each service as a new version. When `web` connects to `api` in the same application, `web` receives the address of the `api` version that shipped in the same release, not whichever version happens to be getting traffic.

This matters when you [split traffic](https://inframan.mintlify.site/deploy/revisions.md) between revisions. A user's request may land on the old or the new revision at the edge, but once it's inside, every call between your services stays within that revision. Version 41 of `web` never calls version 42 of `api` by accident.

The URL has no port, because it points at port 80 of the version's internal service. If your code needs a host and port, parse them from the URL.

## Connections set the deploy order

A service is deployed after everything it connects to. In the example above, `api` is deployed before `web`, and the add-ons are ready before `api`.

Two services that connect to each other are refused, because neither could be deployed first. To fix a cycle, split out the side that's called back into its own service, built from the same image if that's simpler.

## Passwords stay out of your spec

The value of an add-on connection is read from a Kubernetes Secret when the pod starts. It's never written into the workload's spec, so someone who can read your deployment can't read your database password from it. If you set a plain variable with the same name as a connection, the connection wins and the plain variable is dropped.

## Add a connection in the console

On a service's **Environment** tab, add a connection and pick its target from the services and add-ons on the infrastructure. Like other environment edits, it's proposed as a pull request to `inframan.yaml`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.