aws-cdk-lib.aws_globalaccelerator.ListenerOptions

interface ListenerOptions

LanguageType name
.NETAmazon.CDK.AWS.GlobalAccelerator.ListenerOptions
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsglobalaccelerator#ListenerOptions
Javasoftware.amazon.awscdk.services.globalaccelerator.ListenerOptions
Pythonaws_cdk.aws_globalaccelerator.ListenerOptions
TypeScript (source)aws-cdk-lib » aws_globalaccelerator » ListenerOptions

Construct options for Listener.

Example

// Create an Accelerator
const accelerator = new globalaccelerator.Accelerator(this, 'Accelerator');

// Create a Listener
const listener = accelerator.addListener('Listener', {
  portRanges: [
    { fromPort: 80 },
    { fromPort: 443 },
  ],
});

// Import the Load Balancers
const nlb1 = elbv2.NetworkLoadBalancer.fromNetworkLoadBalancerAttributes(this, 'NLB1', {
  loadBalancerArn: 'arn:aws:elasticloadbalancing:us-west-2:111111111111:loadbalancer/app/my-load-balancer1/e16bef66805b',
});
const nlb2 = elbv2.NetworkLoadBalancer.fromNetworkLoadBalancerAttributes(this, 'NLB2', {
  loadBalancerArn: 'arn:aws:elasticloadbalancing:ap-south-1:111111111111:loadbalancer/app/my-load-balancer2/5513dc2ea8a1',
});

// Add one EndpointGroup for each Region we are targeting
listener.addEndpointGroup('Group1', {
  endpoints: [new ga_endpoints.NetworkLoadBalancerEndpoint(nlb1)],
});
listener.addEndpointGroup('Group2', {
  // Imported load balancers automatically calculate their Region from the ARN.
  // If you are load balancing to other resources, you must also pass a `region`
  // parameter here.
  endpoints: [new ga_endpoints.NetworkLoadBalancerEndpoint(nlb2)],
});

Properties

NameTypeDescription
portRangesPortRange[]The list of port ranges for the connections from clients to the accelerator.
clientAffinity?ClientAffinityClient affinity to direct all requests from a user to the same endpoint.
listenerName?stringName of the listener.
protocol?ConnectionProtocolThe protocol for the connections from clients to the accelerator.

portRanges

Type: PortRange[]

The list of port ranges for the connections from clients to the accelerator.


clientAffinity?

Type: ClientAffinity (optional, default: ClientAffinity.NONE)

Client affinity to direct all requests from a user to the same endpoint.

If you have stateful applications, client affinity lets you direct all requests from a user to the same endpoint.

By default, each connection from each client is routed to seperate endpoints. Set client affinity to SOURCE_IP to route all connections from a single client to the same endpoint.


listenerName?

Type: string (optional, default: logical ID of the resource)

Name of the listener.


protocol?

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

The protocol for the connections from clients to the accelerator.