# BaseApplicationListenerProps

Basic properties for an ApplicationListener.

Used as argument in: [IApplicationLoadBalancer.addListener](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_elasticloadbalancingv2.IApplicationLoadBalancer.html#addlistener)

- Source: [`aws-elasticloadbalancingv2/lib/alb/application-listener.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-elasticloadbalancingv2/lib/alb/application-listener.ts#L36)
- Type last changed: v2.154.0 · 22 Aug 2024

## Example

TypeScript:

```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:

```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:

```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());
```

C# / .NET:

```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
    })
});
```

Golang:

```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

- `certificates`: [IListenerCertificate](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_elasticloadbalancingv2.IListenerCertificate.html)[] — Certificate list of ACM cert ARNs.

  **Default:** No certificates.

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

- `defaultAction`: [ListenerAction](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_elasticloadbalancingv2.ListenerAction.html) = None. — Default action to take for requests to this listener.

  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`.

- `defaultTargetGroups`: [IApplicationTargetGroup](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_elasticloadbalancingv2.IApplicationTargetGroup.html)[] = 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`.

- `mutualAuthentication`: [MutualAuthentication](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_elasticloadbalancingv2.MutualAuthentication.html) — The mutual authentication configuration information.

  **Default:** No mutual authentication configuration

- `open`: boolean = true — Allow anyone to connect to the load balancer on the listener port.

  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.

- `port`: number — The port on which the listener listens for requests.

  **Default:** Determined from protocol if known.

- `protocol`: [ApplicationProtocol](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_elasticloadbalancingv2.ApplicationProtocol.html) — The protocol to use.

  **Default:** Determined from port if known.

- `sslPolicy`: [SslPolicy](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_elasticloadbalancingv2.SslPolicy.html) — The security policy that defines which ciphers and protocols are supported.

  **Default:** The current predefined security policy.
