Skip to content
v2.277.0

BaseApplicationListenerProps Struct ​

Basic properties for an ApplicationListener.

Example ​

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

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
    }),
  },
);
python
# cluster: ecs.Cluster
# task_definition: ecs.TaskDefinition
# vpc: ec2.Vpc

service = ecs.FargateService(self, "Service", cluster=cluster, task_definition=task_definition, min_healthy_percent=100)

lb = elbv2.ApplicationLoadBalancer(self, "LB", vpc=vpc, internet_facing=True)
listener = lb.add_listener("Listener", port=80)
service.register_load_balancer_targets(
    container_name="web",
    container_port=80,
    new_target_group_id="ECS",
    listener=ecs.ListenerConfig.application_listener(listener,
        protocol=elbv2.ApplicationProtocol.HTTPS
    )
)
java
Cluster cluster;
TaskDefinition taskDefinition;
Vpc vpc;

FargateService service = FargateService.Builder.create(this, "Service").cluster(cluster).taskDefinition(taskDefinition).minHealthyPercent(100).build();

ApplicationLoadBalancer lb = ApplicationLoadBalancer.Builder.create(this, "LB").vpc(vpc).internetFacing(true).build();
ApplicationListener listener = lb.addListener("Listener", BaseApplicationListenerProps.builder().port(80).build());
service.registerLoadBalancerTargets(EcsTarget.builder()
        .containerName("web")
        .containerPort(80)
        .newTargetGroupId("ECS")
        .listener(ListenerConfig.applicationListener(listener, AddApplicationTargetsProps.builder()
                .protocol(ApplicationProtocol.HTTPS)
                .build()))
        .build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
Cluster cluster;
TaskDefinition taskDefinition;
Vpc vpc;

var service = new FargateService(this, "Service", new FargateServiceProps { Cluster = cluster, TaskDefinition = taskDefinition, MinHealthyPercent = 100 });

var lb = new ApplicationLoadBalancer(this, "LB", new ApplicationLoadBalancerProps { Vpc = vpc, InternetFacing = true });
var listener = lb.AddListener("Listener", new BaseApplicationListenerProps { Port = 80 });
service.RegisterLoadBalancerTargets(new EcsTarget {
    ContainerName = "web",
    ContainerPort = 80,
    NewTargetGroupId = "ECS",
    Listener = ListenerConfig.ApplicationListener(listener, new AddApplicationTargetsProps {
        Protocol = ApplicationProtocol.HTTPS
    })
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var cluster Cluster
var taskDefinition TaskDefinition
var vpc Vpc

service := ecs.NewFargateService(this, jsii.String("Service"), &FargateServiceProps{
	Cluster: Cluster,
	TaskDefinition: TaskDefinition,
	MinHealthyPercent: jsii.Number(100),
})

lb := elbv2.NewApplicationLoadBalancer(this, jsii.String("LB"), &ApplicationLoadBalancerProps{
	Vpc: Vpc,
	InternetFacing: jsii.Boolean(true),
})
listener := lb.AddListener(jsii.String("Listener"), &BaseApplicationListenerProps{
	Port: jsii.Number(80),
})
service.RegisterLoadBalancerTargets(&EcsTarget{
	ContainerName: jsii.String("web"),
	ContainerPort: jsii.Number(80),
	NewTargetGroupId: jsii.String("ECS"),
	Listener: ecs.ListenerConfig_ApplicationListener(listener, &AddApplicationTargetsProps{
		Protocol: elbv2.ApplicationProtocol_HTTPS,
	}),
})

Properties ​

certificatesoptionalIListenerCertificate[]certificatesoptionaltyping.List[IListenerCertificate]certificatesoptionalList<IListenerCertificate>CertificatesoptionalIListenerCertificate[]Certificatesoptional*[]IListenerCertificate #
Certificate list of ACM cert ARNs.

Default: No certificates.

You must provide exactly one certificate if the listener protocol is HTTPS or TLS.

defaultActionoptionalListenerActiondefault_actionoptionalListenerActiondefaultActionoptionalListenerActionDefaultActionoptionalListenerActionDefaultActionoptionalListenerAction = None. #
Default action to take for requests to this listener.
notes

This allows full control of the default action of the load balancer, including Action chaining, fixed responses and redirect responses.

See the ListenerAction class for all options.

Cannot be specified together with defaultTargetGroups.

defaultTargetGroupsoptionalIApplicationTargetGroup[]default_target_groupsoptionaltyping.List[IApplicationTargetGroup]defaultTargetGroupsoptionalList<IApplicationTargetGroup>DefaultTargetGroupsoptionalIApplicationTargetGroup[]DefaultTargetGroupsoptional*[]IApplicationTargetGroup = None. #
Default target groups to load balance to.

All target groups will be load balanced to with equal weight and without stickiness. For a more complex configuration than that, use either defaultAction or addAction().

Cannot be specified together with defaultAction.

mutualAuthenticationoptionalMutualAuthenticationmutual_authenticationoptionalMutualAuthenticationmutualAuthenticationoptionalMutualAuthenticationMutualAuthenticationoptionalMutualAuthenticationMutualAuthenticationoptionalMutualAuthentication #
The mutual authentication configuration information.

Default: No mutual authentication configuration

openoptionalbooleanopenoptionalboolopenoptionalBooleanOpenoptionalboolOpenoptional*bool = true #
Allow anyone to connect to the load balancer on the listener port.
notes

If this is specified, the load balancer will be opened up to anyone who can reach it. For internal load balancers this is anyone in the same VPC. For public load balancers, this is anyone on the internet.

If you want to be more selective about who can access this load balancer, set this to false and use the listener's connections object to selectively grant access to the load balancer on the listener port.

portoptionalnumberportoptionalint | floatportoptionalNumberPortoptionaldoublePortoptional*float64 #
The port on which the listener listens for requests.

Default: Determined from protocol if known.

protocoloptionalApplicationProtocolprotocoloptionalApplicationProtocolprotocoloptionalApplicationProtocolProtocoloptionalApplicationProtocolProtocoloptionalApplicationProtocol #
The protocol to use.

Default: Determined from port if known.

sslPolicyoptionalSslPolicyssl_policyoptionalSslPolicysslPolicyoptionalSslPolicySslPolicyoptionalSslPolicySslPolicyoptionalSslPolicy #
The security policy that defines which ciphers and protocols are supported.

Default: The current predefined security policy.