aws-cdk-lib.aws_ecs.LoadBalancerTargetOptions

interface LoadBalancerTargetOptions

LanguageType name
.NETAmazon.CDK.AWS.ECS.LoadBalancerTargetOptions
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsecs#LoadBalancerTargetOptions
Javasoftware.amazon.awscdk.services.ecs.LoadBalancerTargetOptions
Pythonaws_cdk.aws_ecs.LoadBalancerTargetOptions
TypeScript (source)aws-cdk-lib » aws_ecs » LoadBalancerTargetOptions

Properties for defining an ECS target.

The port mapping for it must already have been created through addPortMapping().

Example

declare const cluster: ecs.Cluster;
declare const taskDefinition: ecs.TaskDefinition;
declare const vpc: ec2.Vpc;
const service = new ecs.Ec2Service(this, 'Service', { cluster, taskDefinition });

const lb = new elb.LoadBalancer(this, 'LB', { vpc });
lb.addListener({ externalPort: 80 });
lb.addTarget(service.loadBalancerTarget({
  containerName: 'MyContainer',
  containerPort: 80,
}));

Properties

NameTypeDescription
containerNamestringThe name of the container.
containerPort?numberThe port number of the container.
protocol?ProtocolThe protocol used for the port mapping.

containerName

Type: string

The name of the container.


containerPort?

Type: number (optional, default: Container port of the first added port mapping.)

The port number of the container.

Only applicable when using application/network load balancers.


protocol?

Type: Protocol (optional, default: Protocol.TCP)

The protocol used for the port mapping.

Only applicable when using application load balancers.