ListenerOptions

class aws_cdk.aws_globalaccelerator.ListenerOptions(*, client_affinity=None, listener_name=None, port_ranges, protocol=None)

Bases: object

Construct options for Listener.

Parameters
  • client_affinity (Optional[ClientAffinity]) – 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. Default: ClientAffinity.NONE

  • listener_name (Optional[str]) – Name of the listener. Default: - logical ID of the resource

  • port_ranges (Sequence[PortRange]) – The list of port ranges for the connections from clients to the accelerator.

  • protocol (Optional[ConnectionProtocol]) – The protocol for the connections from clients to the accelerator. Default: ConnectionProtocol.TCP

Example:

# Example automatically generated from non-compiling source. May contain errors.
import aws_cdk.aws_globalaccelerator as globalaccelerator
import aws_cdk.aws_globalaccelerator_endpoints as ga_endpoints
import aws_cdk.aws_elasticloadbalancingv2 as elbv2

# Create an Accelerator
accelerator = globalaccelerator.Accelerator(stack, "Accelerator")

# Create a Listener
listener = accelerator.add_listener("Listener",
    port_ranges=[globalaccelerator.PortRange(from_port=80), globalaccelerator.PortRange(from_port=443)
    ]
)

# Import the Load Balancers
nlb1 = elbv2.NetworkLoadBalancer.from_network_load_balancer_attributes(stack, "NLB1",
    load_balancer_arn="arn:aws:elasticloadbalancing:us-west-2:111111111111:loadbalancer/app/my-load-balancer1/e16bef66805b"
)
nlb2 = elbv2.NetworkLoadBalancer.from_network_load_balancer_attributes(stack, "NLB2",
    load_balancer_arn="arn:aws:elasticloadbalancing:ap-south-1:111111111111:loadbalancer/app/my-load-balancer2/5513dc2ea8a1"
)

# Add one EndpointGroup for each Region we are targeting
listener.add_endpoint_group("Group1",
    endpoints=[ga_endpoints.NetworkLoadBalancerEndpoint(nlb1)]
)
listener.add_endpoint_group("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=[ga_endpoints.NetworkLoadBalancerEndpoint(nlb2)]
)

Attributes

client_affinity

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.

Default

ClientAffinity.NONE

Return type

Optional[ClientAffinity]

listener_name

Name of the listener.

Default
  • logical ID of the resource

Return type

Optional[str]

port_ranges

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

Return type

List[PortRange]

protocol

The protocol for the connections from clients to the accelerator.

Default

ConnectionProtocol.TCP

Return type

Optional[ConnectionProtocol]