# End-to-End Walkthrough: Connections with Rudder CLI


This tutorial shows you how to use [Rudder CLI]({{< ref "dev-tools/rudder-cli/" >}}) to:

- Enable experimental destination and connection support
- Put an Event Stream source, a destination, and a connection in one project
- Validate the graph locally, then apply it so Rudder CLI creates resources in dependency order

For replace behavior and current limits, see [Manage Connections using Rudder CLI]({{< ref "dev-tools/rudder-cli/connections.md" >}}).

## Prerequisites

- Rudder CLI tool (`rudder-cli`) [installed locally]({{< ref "dev-tools/rudder-cli/installation.md" >}})
- A [workspace-level Service Access Token]({{< ref "access-management/service-access-tokens.md#workspace-sat" >}}) with the following [permissions]({{< ref "access-management/policies-overview.md#resource-permissions" >}}):

| Resource | Permissions |
| :----| :-----|
| Event Stream Sources | **Create & Delete**, **Edit**, **Connect** |
| Destinations | **Create & Delete**, **Edit**, **Connect** |

{{< customreadfile "/includes/rudder-cli/token-auth-footer-admin.md" >}}

## 1. Authenticate the CLI tool

{{< customreadfile "/includes/rudder-cli/auth-login-step.md" >}}

## 2. Enable destination and connection support

```shell
export RUDDERSTACK_X_DESTINATION_SUPPORT=true
export RUDDERSTACK_X_CONNECTION_SUPPORT=true
```

## 3. Create a project directory

```shell
mkdir ~/tutorial-connections
```

## 4. Define the source and destination

Create `~/tutorial-connections/android-source.yaml`:

```yaml
version: rudder/v1
kind: event-stream-source
metadata:
  name: android-source
spec:
  id: my-android-source
  type: android
  name: "Android Source"
  enabled: true
```

Create `~/tutorial-connections/s3.yaml`:

```yaml
version: rudder/v1
kind: destination
metadata:
  name: s3
spec:
  id: s3
  display_name: "S3 Destination"
  type: s3
  definition_version: 1
  enabled: true
  config:
    bucket_name: "my-rudder-bucket"
    role_based_auth: true
    iam_role_arn: "arn:aws:iam::<AWS_ACCOUNT_ID>:role/<ROLE_NAME>"
```

See [Event Stream Source YAML Reference]({{< ref "dev-tools/rudder-cli/yaml-event-stream-sources.md" >}}) and [Destination YAML Reference]({{< ref "dev-tools/rudder-cli/yaml-destinations.md" >}}) for field details.

## 5. Define the connection

Create `~/tutorial-connections/app-connections.yaml`:

```yaml
version: rudder/v1
kind: event-stream-connections
metadata:
  name: app-connections
spec:
  connections:
    - id: android-to-s3
      source: "#event-stream-source:my-android-source"
      destination: "#destination:s3"
      enabled: true
```

The `source` and `destination` values must be valid references to resources in this project. Event Stream connections have no `config` field — adding one is a parse error.

## 6. Validate and deploy

```shell
rudder-cli validate -l ~/tutorial-connections
rudder-cli apply -l ~/tutorial-connections --dry-run
rudder-cli apply -l ~/tutorial-connections
```

Apply creates the source and destination first, then the connection. Removing the connection entry (or the file) and applying again disconnects the pair without deleting either endpoint.

## See more

- [Manage Connections using Rudder CLI]({{< ref "dev-tools/rudder-cli/connections.md" >}})
- [Connection YAML Reference]({{< ref "dev-tools/rudder-cli/yaml-connections.md" >}})
- [Manage Destinations using Rudder CLI]({{< ref "dev-tools/rudder-cli/destinations.md" >}})
- [GitHub Actions for Rudder CLI]({{< ref "dev-tools/rudder-cli/github-actions" >}})

