> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/continuous-delivery/use-continuous-delivery/cd-building-blocks/environments/scope-infra-to-services.md).

# Scope infrastructures to specific services

Limit an infrastructure definition so that only specific Harness services can be deployed to it

When you add a CD stage to a pipeline, you select the Harness service to deploy and the target infrastructure where the service is deployed. In some cases, you do not want to allow any service to be deployed to a specific infrastructure. Instead, you want to place a limitation on the infrastructure so that only specific services may be deployed to it.

To limit an infrastructure to specific services, use the **Scope to Specific Services** option in the infrastructure definition. In **Scope to Specific Services**, you specify the services that the infrastructure may accept. The services can still be deployed to other infrastructures, but the infrastructure using **Scope to Specific Services** accepts only the services you select in that option.

The services and infrastructure combinations you select are enforced when a pipeline runs. If you select the infrastructure definition and a service that is not in **Scope to Specific Services** for that infrastructure, then the pipeline fails with this error:

```
Invalid request: Infrastructure: [NAME] inside PROJECT level Environment: [NAME] can't be scoped to PROJECT level Service: [NAME]
```

{% hint style="info" %}
When **Scope to Specific Services** is not used, the infrastructure definition is available to all services that match the infrastructure definition **Deployment Type**.
{% endhint %}

***

## What you will learn from this topic

* How to [scope an infrastructure definition to specific services](#scoping-an-infrastructure-to-specific-services) using **Scope to Specific Services**.
* How to [create a stage using services scoped to an infrastructure](#creating-a-stage-using-services-scoped-to-an-infrastructure) and correct a service that does not match.

***

## Scope an infrastructure to specific services <a href="#scoping-an-infrastructure-to-specific-services" id="scoping-an-infrastructure-to-specific-services"></a>

Perform the following steps to scope an infrastructure definition to specific services:

1. In an infrastructure definition, select **Scope to Specific Services**.
2. In **Select Services**, use **Select**.
3. In **Create or Select an Existing Service**, select the service(s) that may be deployed to this infrastructure.

   **Deployment types must match**: When you select services using **Scope to Specific Services**, the service **Deployment Type** must match the infrastructure definition **Deployment Type**.

   For example, if you are using **Scope to Specific Services** in an infrastructure definition using the Kubernetes deployment type, you see only services with the same deployment type in **Create or Select an Existing Service**.
4. Select **Apply Selected**. The **Select Services** option displays the number of selected services.

***

## Create a stage using services scoped to an infrastructure <a href="#creating-a-stage-using-services-scoped-to-an-infrastructure" id="creating-a-stage-using-services-scoped-to-an-infrastructure"></a>

When you create a CD stage that uses an infrastructure with the **Scope to Specific Services** option enabled, you must select a service that is scoped to that infrastructure in **Service**.

Harness does not prevent you from selecting a service that is not scoped to that infrastructure. When you run the pipeline, if the service selected is not in the **Scope to Specific Services** list for the infrastructure selected in **Environment**, the pipeline fails.

![Pipeline execution showing the Service step failed with an Error Summary that the infrastructure cannot be scoped to the selected service](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-14734403e72eebd3eda74bdc21871cd8c135e5b2%2F022ccf0e65c8aefcaa9ba4924a9189a85ebe92c9d2bac40fc719b5d5049e94fa.png?alt=media)

Correct the service selected in the stage **Service** section to match one of services in the **Scope to Specific Services** list for the infrastructure selected in **Environment**.

{% @harness-feedback/feedback %}
