# WithMember

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

Adds a MongoDB server resource as a member of the replica set.

## Remarks

Internally calls the following methods on the member's builder:
- Configures the member's replica set name and command-line arguments without initializing a separate single-member set. Do not call `WithReplicaSet` on these members.
- `WithKeyFile` to set the key file parameter on the member resource, which is required for internal authentication between replica set members.
- `WithTlsAllowInvalidCertificates` because members authenticate to each other with the same certificate they serve to clients, which does not carry a `clientAuth` extended key usage.
- `WithHttpsDeveloperCertificate`, unless the member already has certificate configuration of its own. TLS is required for members of a replica set, because the split-horizon member hostname advertisement performed by the server operates on top of SNI.

## Definition

```go
func (MongoDBReplicaSetResource) WithMember(member MongoDBServerResource) MongoDBReplicaSetResource
```

## Parameters

- `member` ([`MongoDBServerResource`](/reference/api/go/aspire.hosting.mongodb/mongodbserverresource.md)) -- The MongoDB server resource that represents the member to add to this replica set.

## Returns

[`MongoDBReplicaSetResource`](/reference/api/go/aspire.hosting.mongodb/mongodbreplicasetresource.md) -- A reference to the `IResourceBuilder`.

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

## Applies to

- [`MongoDBReplicaSetResource`](/reference/api/go/aspire.hosting.mongodb/mongodbreplicasetresource.md)
