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

# Connections in porter.yaml

> Connect services to external cloud resources like AWS IAM roles, Google Cloud SQL instances, and persistent disks using porter.yaml connections

Connect your services to external cloud resources like AWS IAM roles, Google Cloud SQL instances, and persistent disks.

## Connection Types

| Type       | Description                           | Cloud Provider |
| ---------- | ------------------------------------- | -------------- |
| `awsRole`  | Attach an IAM role for AWS API access | AWS            |
| `cloudSql` | Connect to Google Cloud SQL instances | GCP            |
| `disk`     | Attach persistent storage             | All            |

***

## AWS Role Connection

Attach an IAM role to your service for secure AWS API access without managing credentials.

### Field Reference

| Field  | Type   | Required | Description       |
| ------ | ------ | -------- | ----------------- |
| `type` | string | Yes      | Must be `awsRole` |
| `role` | string | Yes      | IAM role name     |

### Example

```yaml theme={null}
services:
  - name: api
    # ...
    connections:
      - type: awsRole
        role: my-app-s3-access
```

***

## Cloud SQL Connection (GCP)

Connect to Google Cloud SQL instances using the Cloud SQL Auth Proxy for secure database access.

<Info>
  Your GCP Service account must be configured in the Connections tab of your cluster settings before it can be used in `porter.yaml`.
</Info>

### Field Reference

| Field                           | Type    | Required | Description                               |
| ------------------------------- | ------- | -------- | ----------------------------------------- |
| `type`                          | string  | Yes      | Must be `cloudSql`                        |
| `config.cloudSqlConnectionName` | string  | Yes      | Cloud SQL instance connection name        |
| `config.cloudSqlDatabasePort`   | integer | Yes      | Database port (e.g., 5432 for PostgreSQL) |
| `config.cloudSqlServiceAccount` | string  | Yes      | GCP service account name                  |

### Example

```yaml theme={null}
services:
  - name: api
    # ...
    connections:
      - type: cloudSql
        config:
          cloudSqlConnectionName: my-project-123456:us-east1:my-instance
          cloudSqlDatabasePort: 5432
          cloudSqlServiceAccount: my-service-account
```

<Info>
  The connection name follows the format `project-id:region:instance-name`. You can find this in the Google Cloud Console under your Cloud SQL instance details.
</Info>

***

## Persistent Disk Connection

Attach persistent storage to your service for data that needs to survive pod restarts.

<Info>
  Your persistent disk must be created in the Add-Ons tab of Porter before it can be used in `porter.yaml`.
</Info>

### Field Reference

| Field             | Type   | Required | Description                 |
| ----------------- | ------ | -------- | --------------------------- |
| `type`            | string | Yes      | Must be `disk`              |
| `config.diskName` | string | Yes      | Name of the persistent disk |

### Example

```yaml theme={null}
services:
  - name: api
    # ...
    connections:
      - type: disk
        config:
          diskName: my-persistent-data
```

<Warning>
  Persistent disks are tied to specific availability zones. Services using persistent disks cannot be scheduled across multiple zones.
</Warning>

***

## Multiple Connections

You can attach multiple connections to a single service (but only one of each type of connection):

```yaml theme={null}
services:
  - name: api
    # ...
    connections:
      - type: awsRole
        role: api-s3-access
      - type: disk
        config:
          diskName: cache-storage
```

***

## Related Documentation

* [Web Services](/applications/configuration-as-code/services/web-service) - Web service configuration
* [Worker Services](/applications/configuration-as-code/services/worker-service) - Worker service configuration
* [Job Services](/applications/configuration-as-code/services/job-service) - Job service configuration
* [porter.yaml Reference](/applications/configuration-as-code/reference) - Complete configuration reference
