PortMap Class
PortMap ValueObjectClass having by ContainerDefinition.
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,
});
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_ecs as ecs
# app_protocol: ecs.AppProtocol
port_map = ecs.PortMap(ecs.NetworkMode.NONE,
container_port=123,
# the properties below are optional
app_protocol=app_protocol,
container_port_range="containerPortRange",
host_port=123,
name="name",
protocol=ecs.Protocol.TCP
)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.ecs.*;
AppProtocol appProtocol;
PortMap portMap = PortMap.Builder.create(NetworkMode.NONE)
.containerPort(123)
// the properties below are optional
.appProtocol(appProtocol)
.containerPortRange("containerPortRange")
.hostPort(123)
.name("name")
.protocol(Protocol.TCP)
.build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.ECS;
AppProtocol appProtocol;
var portMap = new PortMap(NetworkMode.NONE, new PortMapping {
ContainerPort = 123,
// the properties below are optional
AppProtocol = appProtocol,
ContainerPortRange = "containerPortRange",
HostPort = 123,
Name = "name",
Protocol = Protocol.TCP
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"
var appProtocol AppProtocol
portMap := awscdk.Aws_ecs.NewPortMap(awscdk.Aws_ecs.NetworkMode_NONE, &PortMapping{
ContainerPort: jsii.Number(123),
// the properties below are optional
AppProtocol: appProtocol,
ContainerPortRange: jsii.String("containerPortRange"),
HostPort: jsii.Number(123),
Name: jsii.String("name"),
Protocol: awscdk.*Aws_ecs.Protocol_TCP,
})
Initializer
ts
new PortMap(networkmode: NetworkMode, pm: PortMapping)
python
PortMap(networkmode: NetworkMode, pm: PortMapping)
java
new PortMap(NetworkMode networkmode, PortMapping pm)
csharp
new PortMap(NetworkMode networkmode, PortMapping pm)
go
NewPortMap(Networkmode NetworkMode, Pm PortMapping)
Properties
networkmodeNetworkModenetworkmodeNetworkModenetworkmodeNetworkModeNetworkmodeNetworkModeNetworkmodeNetworkModerequired#The networking mode to use for the containers in the task.
portmappingPortMappingportmappingPortMappingportmappingPortMappingPortmappingPortMappingPortmappingPortMappingrequired#Port mappings allow containers to access ports on the host container instance to send or receive traffic.
Methods
validate(): voiddef validate(self, ) -> Nonepublic void validate()public void Validate()func Validate()#validate invalid portmapping and networkmode parameters.
throw Error when invalid parameters.