Skip to content
v2.277.0

ApplicationListenerProps Struct ​

Properties for defining a standalone ApplicationListener.

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_elasticloadbalancingv2 as elbv2 } from 'aws-cdk-lib';
import { aws_elasticloadbalancingv2 as interfaces_elasticloadbalancingv2 } from 'aws-cdk-lib/interfaces';

declare const applicationLoadBalancer: elbv2.ApplicationLoadBalancer;
declare const applicationTargetGroup: elbv2.ApplicationTargetGroup;
declare const listenerAction: elbv2.ListenerAction;
declare const listenerCertificate: elbv2.ListenerCertificate;
declare const trustStoreRef: interfaces_elasticloadbalancingv2.ITrustStoreRef;
const applicationListenerProps: elbv2.ApplicationListenerProps = {
  loadBalancer: applicationLoadBalancer,

  // the properties below are optional
  certificates: [listenerCertificate],
  defaultAction: listenerAction,
  defaultTargetGroups: [applicationTargetGroup],
  mutualAuthentication: {
    advertiseTrustStoreCaNames: false,
    ignoreClientCertificateExpiry: false,
    mutualAuthenticationMode: elbv2.MutualAuthenticationMode.OFF,
    trustStore: trustStoreRef,
  },
  open: false,
  port: 123,
  protocol: elbv2.ApplicationProtocol.HTTP,
  sslPolicy: elbv2.SslPolicy.RECOMMENDED_TLS,
};
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_elasticloadbalancingv2 as elbv2
from aws_cdk.interfaces import aws_elasticloadbalancingv2 as interfaces_elasticloadbalancingv2

# application_load_balancer: elbv2.ApplicationLoadBalancer
# application_target_group: elbv2.ApplicationTargetGroup
# listener_action: elbv2.ListenerAction
# listener_certificate: elbv2.ListenerCertificate
# trust_store_ref: interfaces_elasticloadbalancingv2.ITrustStoreRef

application_listener_props = elbv2.ApplicationListenerProps(
    load_balancer=application_load_balancer,

    # the properties below are optional
    certificates=[listener_certificate],
    default_action=listener_action,
    default_target_groups=[application_target_group],
    mutual_authentication=elbv2.MutualAuthentication(
        advertise_trust_store_ca_names=False,
        ignore_client_certificate_expiry=False,
        mutual_authentication_mode=elbv2.MutualAuthenticationMode.OFF,
        trust_store=trust_store_ref
    ),
    open=False,
    port=123,
    protocol=elbv2.ApplicationProtocol.HTTP,
    ssl_policy=elbv2.SslPolicy.RECOMMENDED_TLS
)
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.elasticloadbalancingv2.*;
import software.amazon.awscdk.interfaces.elasticloadbalancingv2.*;

ApplicationLoadBalancer applicationLoadBalancer;
ApplicationTargetGroup applicationTargetGroup;
ListenerAction listenerAction;
ListenerCertificate listenerCertificate;
ITrustStoreRef trustStoreRef;

ApplicationListenerProps applicationListenerProps = ApplicationListenerProps.builder()
        .loadBalancer(applicationLoadBalancer)

        // the properties below are optional
        .certificates(List.of(listenerCertificate))
        .defaultAction(listenerAction)
        .defaultTargetGroups(List.of(applicationTargetGroup))
        .mutualAuthentication(MutualAuthentication.builder()
                .advertiseTrustStoreCaNames(false)
                .ignoreClientCertificateExpiry(false)
                .mutualAuthenticationMode(MutualAuthenticationMode.OFF)
                .trustStore(trustStoreRef)
                .build())
        .open(false)
        .port(123)
        .protocol(ApplicationProtocol.HTTP)
        .sslPolicy(SslPolicy.RECOMMENDED_TLS)
        .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.ElasticLoadBalancingV2;
using Amazon.CDK.Interfaces.ElasticLoadBalancingV2;

ApplicationLoadBalancer applicationLoadBalancer;
ApplicationTargetGroup applicationTargetGroup;
ListenerAction listenerAction;
ListenerCertificate listenerCertificate;
ITrustStoreRef trustStoreRef;

var applicationListenerProps = new ApplicationListenerProps {
    LoadBalancer = applicationLoadBalancer,

    // the properties below are optional
    Certificates = new [] { listenerCertificate },
    DefaultAction = listenerAction,
    DefaultTargetGroups = new [] { applicationTargetGroup },
    MutualAuthentication = new MutualAuthentication {
        AdvertiseTrustStoreCaNames = false,
        IgnoreClientCertificateExpiry = false,
        MutualAuthenticationMode = MutualAuthenticationMode.OFF,
        TrustStore = trustStoreRef
    },
    Open = false,
    Port = 123,
    Protocol = ApplicationProtocol.HTTP,
    SslPolicy = SslPolicy.RECOMMENDED_TLS
};
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"
import "github.com/aws/aws-cdk-go/awscdk"

var applicationLoadBalancer ApplicationLoadBalancer
var applicationTargetGroup ApplicationTargetGroup
var listenerAction ListenerAction
var listenerCertificate ListenerCertificate
var trustStoreRef ITrustStoreRef

applicationListenerProps := &ApplicationListenerProps{
	LoadBalancer: applicationLoadBalancer,

	// the properties below are optional
	Certificates: []IListenerCertificate{
		listenerCertificate,
	},
	DefaultAction: listenerAction,
	DefaultTargetGroups: []IApplicationTargetGroup{
		applicationTargetGroup,
	},
	MutualAuthentication: &MutualAuthentication{
		AdvertiseTrustStoreCaNames: jsii.Boolean(false),
		IgnoreClientCertificateExpiry: jsii.Boolean(false),
		MutualAuthenticationMode: awscdk.Aws_elasticloadbalancingv2.MutualAuthenticationMode_OFF,
		TrustStore: trustStoreRef,
	},
	Open: jsii.Boolean(false),
	Port: jsii.Number(123),
	Protocol: awscdk.*Aws_elasticloadbalancingv2.ApplicationProtocol_HTTP,
	SslPolicy: awscdk.*Aws_elasticloadbalancingv2.SslPolicy_RECOMMENDED_TLS,
}

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.

The load balancer to attach this listener to.
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.