---
description: This article explains how you can set up and use on-premise VCS Agent Pools.
---

# VCS Agent Pools

By default, Spacelift communicates with your VCS provider directly. This is usually sufficient, but some users may have special requirements regarding infrastructure, security or compliance, and need to host their VCS system in a way that's only accessible internally, where Spacelift can't reach it. This is where VCS Agent Pools come into play.

A single VCS Agent Pool is a way for Spacelift to communicate with a single VCS system on your side. You run VCS Agents inside of your infrastructure and configure them with your internal VCS system endpoint. They will then connect to a gateway on our backend, and we will be able to access your VCS system through them.

On the Agent there are very conservative checks on what requests are let through and which ones are denied, with an explicit allowlist of paths that are necessary for Spacelift to work. All requests will be logged to standard output with a description about what they were used for.

## Setting Up

Navigate to VCS Agent Pools using the Spacelift navigation sidebar. Click **Add VCS Agent Pool.**

![](https://3862190545-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LshwwDZmA4HXN0k9e8O%2Fuploads%2Ft1khjPefFZifF0UAhD1x%2FScreen%20Shot%202022-06-21%20at%2011.31.39%20AM.png?alt=media\&token=35d1c4e0-6b82-426f-83c1-c8cfcb63ee32)

Give your VCS Agent Pool a name and description, and you're done! A configuration token will be downloaded.

![Creation of VCS Agent Pool](https://3862190545-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LshwwDZmA4HXN0k9e8O%2Fuploads%2FXY2M0VXB2ezlczBH3VdQ%2FScreen%20Shot%202022-06-21%20at%2011.29.22%20AM.png?alt=media\&token=e8dcbdfa-83a0-47ff-b1c7-bb93c7c0e988)

You can now run the launcher binary (downloaded from [here](https://downloads.spacelift.io/spacelift-vcs-agent)) by setting three environment variables:

* `SPACELIFT_VCS_AGENT_POOL_TOKEN` - the token you’ve received from Spacelift during VCS Agent Pool creation.
* `SPACELIFT_VCS_AGENT_TARGET_BASE_ENDPOINT` - internal endpoint of your VCS system, including the protocol, as well as port, if applicable. i.e. `http://169.254.0.10:7990`
* `SPACELIFT_VCS_AGENT_VENDOR` - the vendor of your VCS system, currently available options are **gitlab**, **bitbucket\_datacenter** and **github\_enterprise**.

Congrats! Your VCS Agent should now connect to the Spacelift backend and start handling connections.

![Running the VCS Agent](https://3862190545-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LshwwDZmA4HXN0k9e8O%2F-MV1YczUQXIQP4mVvqta%2F-MV1YeIlt9emi7XD3EHU%2Fimage.png?alt=media\&token=1d0b1d64-2e44-41bf-a135-20b80f1a0361)

Within the VCS Agent Pools page, you will be able to see the number of active connections used by your pool.

![VCS Agent Pool Connections](https://3862190545-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LshwwDZmA4HXN0k9e8O%2F-MV0fauE-5sFlpWVYjhC%2F-MV0pJVBt_UdXuE7m_ce%2Fimage.png?alt=media\&token=05f16869-93a8-4095-9904-0026f4e9d6ad)

{% hint style="warning" %}
Whenever you need to specify an endpoint inside of Spacelift which should use your VCS Agent Pool, you should write it this way: `private://my-vcs-agent-pool-name/possible/path`
{% endhint %}

![](https://3862190545-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LshwwDZmA4HXN0k9e8O%2Fuploads%2Ff0XgPcXIJp3kPnHJEOrx%2FScreen%20Shot%202022-06-21%20at%2011.34.18%20AM.png?alt=media\&token=cf7ae77a-0603-48c1-910d-e1cb68bc04de)

When trying to use this integration, i.e. by opening the Stack creation form, you'll get a detailed log of the requests:

![Access Log example](https://3862190545-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LshwwDZmA4HXN0k9e8O%2F-MV0fauE-5sFlpWVYjhC%2F-MV0rIippNRGwMruyDPI%2Fimage.png?alt=media\&token=acef6934-b513-4b05-a85b-4b7b3b56369b)

### Configuration Options

A number of configuration variables is available to customize how your VCS Agent behaves:

* `SPACELIFT_VCS_AGENT_ALLOWED_PROJECTS` - regular expression matching allowed projects for API calls. Projects are in the form: 'group/repository';
* `SPACELIFT_VCS_AGENT_PARALLELISM`- number of streams to create. Each stream can handle one request simultaneously;

### Passing Metadata Tags

When the VCS Agent from a VCS Agent Pool is connecting to the gateway, you can send along some tags that will allow you to uniquely identify the process / machine for the purpose of debugging. Any environment variables using `SPACELIFT_METADATA_` prefix will be passed on. As an example, if you're running Spacelift VCS Agents in EC2, you can do the following just before you execute the VCS Agent binary:

```bash
export SPACELIFT_METADATA_instance_id=$(ec2-metadata --instance-id | cut -d ' ' -f2)
```

Doing so will set your EC2 instance ID as _instance\_id_ tag in your VCS Agent connections.

### Private Workers

VCS agents are only supported when using private worker pools. Because your source code is downloaded directly by Spacelift workers, you need to configure your workers to know how to reach your VCS instance. Information on how to do this is provided on the [worker pools](../worker-pools#vcs-agents) page.
