# AddClusterFromResource

- Module: [Aspire.Hosting.Yarp](/reference/api/go/aspire.hosting.yarp.md)
- Version: `17.0.0`
- Kind: `method`
- Defined on: [`YarpConfigurationBuilder`](/reference/api/go/aspire.hosting.yarp/yarpconfigurationbuilder.md)
- Source: [GitHub](https://github.com/microsoft/aspire/tree/2d325b13709752ba6d9a943635c5e2940a2530c0)

Adds a cluster for a resource that supports service discovery.

## Definition

```go
func (YarpConfigurationBuilder) AddClusterFromResource(resource ResourceWithServiceDiscovery) YarpCluster
```

## Parameters

- `resource` ([`ResourceWithServiceDiscovery`](/reference/api/go/aspire.hosting.yarp/resourcewithservicediscovery.md)) -- The resource target for this cluster.

## Returns

[`YarpCluster`](/reference/api/go/aspire.hosting.yarp/yarpcluster.md) -- The created cluster.

Returns a handle; failures surface later via `Err()`.

## Applies to

- [`YarpConfigurationBuilder`](/reference/api/go/aspire.hosting.yarp/yarpconfigurationbuilder.md)
