# PortMap

PortMap ValueObjectClass having by ContainerDefinition.

- Source: [`aws-ecs/lib/container-definition.ts`](https://github.com/aws/aws-cdk/blob/v2.274.0/packages/aws-cdk-lib/aws-ecs/lib/container-definition.ts#L1330)
- 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 portMap = new ecs.PortMap(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 PortMap(networkmode: NetworkMode, pm: PortMapping)
```

## Properties

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

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

## Methods

- `validate(): void` — validate invalid portmapping and networkmode parameters.

  throw Error when invalid parameters.
