class ListenerConfig
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.ECS.ListenerConfig |
Java | software.amazon.awscdk.services.ecs.ListenerConfig |
Python | aws_cdk.aws_ecs.ListenerConfig |
TypeScript (source) | @aws-cdk/aws-ecs » ListenerConfig |
Base class for configuring listener when registering targets.
Example
declare const cluster: ecs.Cluster;
declare const taskDefinition: ecs.TaskDefinition;
declare const vpc: ec2.Vpc;
const service = new ecs.FargateService(this, 'Service', { cluster, taskDefinition });
const lb = new elbv2.ApplicationLoadBalancer(this, 'LB', { vpc, internetFacing: true });
const listener = lb.addListener('Listener', { port: 80 });
service.registerLoadBalancerTargets(
{
containerName: 'web',
containerPort: 80,
newTargetGroupId: 'ECS',
listener: ecs.ListenerConfig.applicationListener(listener, {
protocol: elbv2.ApplicationProtocol.HTTPS
}),
},
);
Initializer
new ListenerConfig()
Methods
Name | Description |
---|---|
add | Create and attach a target group to listener. |
static application | Create a config for adding target group to ALB listener. |
static network | Create a config for adding target group to NLB listener. |
Targets(id, target, service)
addpublic addTargets(id: string, target: LoadBalancerTargetOptions, service: BaseService): void
Parameters
- id
string
- target
Load
Balancer Target Options - service
Base
Service
Create and attach a target group to listener.
Listener(listener, props?)
static applicationpublic static applicationListener(listener: ApplicationListener, props?: AddApplicationTargetsProps): ListenerConfig
Parameters
- listener
Application
Listener - props
Add
Application Targets Props
Returns
Create a config for adding target group to ALB listener.
Listener(listener, props?)
static networkpublic static networkListener(listener: NetworkListener, props?: AddNetworkTargetsProps): ListenerConfig
Parameters
- listener
Network
Listener - props
Add
Network Targets Props
Returns
Create a config for adding target group to NLB listener.