# ServiceConnect

ServiceConnect ValueObjectClass having by ContainerDefinition.

- Source: [`aws-ecs/lib/container-definition.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-ecs/lib/container-definition.ts#L1400)
- Type last changed: v2.67.0 · 2 Mar 2023

## Example

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_ecs as ecs } from 'aws-cdk-lib';

declare const appProtocol: ecs.AppProtocol;
const serviceConnect = new ecs.ServiceConnect(ecs.NetworkMode.NONE, {
  containerPort: 123,

  // the properties below are optional
  appProtocol: appProtocol,
  containerPortRange: 'containerPortRange',
  hostPort: 123,
  name: 'name',
  protocol: ecs.Protocol.TCP,
});
```

## Initializer

```ts
new ServiceConnect(networkmode: NetworkMode, pm: PortMapping)
```

## Properties

- `networkmode`: [NetworkMode](/cdk/api/v2/docs/aws-cdk-lib.aws_ecs.NetworkMode.html) — The networking mode to use for the containers in the task.

- `portmapping`: [PortMapping](/cdk/api/v2/docs/aws-cdk-lib.aws_ecs.PortMapping.html) — Port mappings allow containers to access ports on the host container instance to send or receive traffic.

## Methods

- `isServiceConnect(): boolean` — Judge parameters can be serviceconnect logick.

  If parameters can be serviceConnect return true.

- `validate(): void` — Judge serviceconnect parametes are valid.

  If invalid, throw Error.
