# How-to: reuse existing Orchestrator resources when deploying

> Reuse an existing Orchestrator connection, asset, or queue when deploying a Solution from a CI/CD pipeline, instead of provisioning a new one.

When you deploy a Solution, every resource it declares — queues, assets, processes, connections — is provisioned fresh in the deployment folder. Often you already have a shared resource in the target environment, such as a connection to an external system, and you want the deployment to reuse it instead of creating a new one.

In the Orchestrator UI you do this by choosing **Customize** when deploying and linking the resource by hand. That manual step does not translate to an unattended pipeline. The CLI equivalent is to fetch the deployment configuration, link the resource inside that file, then pass the file to [`deploy run`](./uip-solution-deploy.md#uip-solution-deploy-run).

:::note
`config link` binds one declared resource to an existing one. To make **every** resource reuse an existing counterpart instead, see [Reuse every resource](#reuse-every-resource) below.
:::

## Prerequisites

- A **published** solution package in the tenant. See [Pack and publish a Solution](./howto-pack-publish-solution.md).
- An **External Application** configured for client-credentials authentication, with these scopes: `AutomationSolutions`, `Solutions.Deployments`, `Solutions.Packages`, `OR.Folders`, `RCS.FolderAuthorization`. See [Authentication — Flow 2](./authentication.md#flow-2-external-application-client-credentials). `OR.Folders` and `RCS.FolderAuthorization` are required so the CLI can resolve and bind resources that live in Orchestrator folders.
- The External Application assigned to the Orchestrator folder that holds the existing resource.

## Steps

1. Authenticate with the External Application.

   ```bash
   uip login \
     --client-id env.UIPATH_CLIENT_ID \
     --client-secret env.UIPATH_CLIENT_SECRET \
     --tenant "$UIPATH_TENANT"
   ```

2. Download the deployment configuration for the package.

   ```bash
   uip solution deploy config get "my-package" \
     --package-version 1.0.0 \
     -d ./deploy-config.json
   ```

3. Link the solution resource to the existing Orchestrator resource. Use the resource name as it appears in the config file, and point `--folder-path` at the folder where the existing resource lives.

   ```bash
   uip solution deploy config link ./deploy-config.json "MyConnection" \
     --name "SharedCrmConnection" \
     --folder-path "Shared"
   ```

4. Deploy the package with the edited configuration.

   ```bash
   uip solution deploy run \
     --name "my-deployment" \
     --package-name "my-package" \
     --package-version 1.0.0 \
     --folder-name "MySolution" \
     --parent-folder-path "Shared" \
     --config-file ./deploy-config.json
   ```

The deployment reuses the linked resource and does not create a new one in the deployment folder.

:::note
On `config link`, `--folder-path` is where the **existing** resource lives. On `deploy run`, `--parent-folder-path` is where the deployment folder is **created**. They are separate flags on separate subcommands.
:::

## Connections: defer selection to runtime

For connection resources, linking an existing connection is not the only option. If you set the connection's `authenticationType` to `ConfigurableByUsers` in the deployment configuration, you can leave the connection unbound and defer its selection and authentication to execution time — users choose and authenticate the connection when the automation runs. This is also a valid configuration for activation.

`authenticationType` accepts two values: `ConfigurableByUsers` (defer to the user at runtime) and `AuthenticateAfterDeployment` (the connection must be authenticated after deployment). With `AuthenticateAfterDeployment`, if the connection is not authenticated by the time activation runs, the activation is reported as failed.

## Reuse every resource

When you want the whole deployment to reuse existing resources rather than create new ones, set the conflict policy across all resources in one call before deploying.

1. Set the conflict policy on every resource in the configuration file.

   ```bash
   uip solution deploy config set ./deploy-config.json --all conflictFixingAction UseExisting
   ```

2. Pass the same file to `deploy run --config-file`, as shown in [step 4](#steps).

## See also

- [`uip solution deploy`](./uip-solution-deploy.md) — the reference for `config get`, `config link`, `config set`, and `deploy run`.
- [Manage Orchestrator assets and queues](./howto-manage-resources.md) — create the resources you later link to.
- [Deploy to Orchestrator from CI](./howto-deploy-from-ci.md) — auth, caching, and version pinning for the pipeline this fits into.
- [Authentication](./authentication.md) — the External Application flow used here.
