Show / Hide Table of Contents

Class Listener

The construct for the Listener.

Inheritance
object
Resource
Listener
Implements
IListener
IResource
IConstruct
IDependable
Inherited Members
Resource.IsOwnedResource(IConstruct)
Resource.IsResource(IConstruct)
Resource.ApplyRemovalPolicy(RemovalPolicy)
Resource.GeneratePhysicalName()
Resource.GetResourceArnAttribute(string, IArnComponents)
Resource.GetResourceNameAttribute(string)
Resource.Env
Resource.PhysicalName
Resource.Stack
Namespace: Amazon.CDK.AWS.GlobalAccelerator
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class Listener : Resource, IListener, IResource, IConstruct, IDependable
Syntax (vb)
Public Class Listener Inherits Resource Implements IListener, IResource, IConstruct, IDependable
Remarks

ExampleMetadata: infused

Examples
// Create an Accelerator
            var accelerator = new Accelerator(this, "Accelerator");

            // Create a Listener
            var listener = accelerator.AddListener("Listener", new ListenerOptions {
                PortRanges = new [] { new PortRange { FromPort = 80 }, new PortRange { FromPort = 443 } }
            });

            // Import the Load Balancers
            var nlb1 = NetworkLoadBalancer.FromNetworkLoadBalancerAttributes(this, "NLB1", new NetworkLoadBalancerAttributes {
                LoadBalancerArn = "arn:aws:elasticloadbalancing:us-west-2:111111111111:loadbalancer/app/my-load-balancer1/e16bef66805b"
            });
            var nlb2 = NetworkLoadBalancer.FromNetworkLoadBalancerAttributes(this, "NLB2", new NetworkLoadBalancerAttributes {
                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", new EndpointGroupOptions {
                Endpoints = new [] { new NetworkLoadBalancerEndpoint(nlb1) }
            });
            listener.AddEndpointGroup("Group2", new EndpointGroupOptions {
                // 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 [] { new NetworkLoadBalancerEndpoint(nlb2) }
            });

Synopsis

Constructors

Listener(Construct, string, IListenerProps)

The construct for the Listener.

Properties

ListenerArn

The ARN of the listener.

ListenerName

The name of the listener.

PROPERTY_INJECTION_ID

Uniquely identifies this class.

Methods

AddEndpointGroup(string, IEndpointGroupOptions?)

Add a new endpoint group to this listener.

FromListenerArn(Construct, string, string)

import from ARN.

Constructors

Listener(Construct, string, IListenerProps)

The construct for the Listener.

public Listener(Construct scope, string id, IListenerProps props)
Parameters
scope Construct
id string
props IListenerProps
Remarks

ExampleMetadata: infused

Examples
// Create an Accelerator
            var accelerator = new Accelerator(this, "Accelerator");

            // Create a Listener
            var listener = accelerator.AddListener("Listener", new ListenerOptions {
                PortRanges = new [] { new PortRange { FromPort = 80 }, new PortRange { FromPort = 443 } }
            });

            // Import the Load Balancers
            var nlb1 = NetworkLoadBalancer.FromNetworkLoadBalancerAttributes(this, "NLB1", new NetworkLoadBalancerAttributes {
                LoadBalancerArn = "arn:aws:elasticloadbalancing:us-west-2:111111111111:loadbalancer/app/my-load-balancer1/e16bef66805b"
            });
            var nlb2 = NetworkLoadBalancer.FromNetworkLoadBalancerAttributes(this, "NLB2", new NetworkLoadBalancerAttributes {
                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", new EndpointGroupOptions {
                Endpoints = new [] { new NetworkLoadBalancerEndpoint(nlb1) }
            });
            listener.AddEndpointGroup("Group2", new EndpointGroupOptions {
                // 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 [] { new NetworkLoadBalancerEndpoint(nlb2) }
            });

Properties

ListenerArn

The ARN of the listener.

public virtual string ListenerArn { get; }
Property Value

string

Remarks

ExampleMetadata: infused

ListenerName

The name of the listener.

public virtual string ListenerName { get; }
Property Value

string

Remarks

Attribute: true

PROPERTY_INJECTION_ID

Uniquely identifies this class.

public static string PROPERTY_INJECTION_ID { get; }
Property Value

string

Remarks

ExampleMetadata: infused

Methods

AddEndpointGroup(string, IEndpointGroupOptions?)

Add a new endpoint group to this listener.

public virtual EndpointGroup AddEndpointGroup(string id, IEndpointGroupOptions? options = null)
Parameters
id string
options IEndpointGroupOptions
Returns

EndpointGroup

Remarks

ExampleMetadata: infused

FromListenerArn(Construct, string, string)

import from ARN.

public static IListener FromListenerArn(Construct scope, string id, string listenerArn)
Parameters
scope Construct
id string
listenerArn string
Returns

IListener

Remarks

ExampleMetadata: infused

Implements

IListener
IResource
Constructs.IConstruct
Constructs.IDependable
Back to top Generated by DocFX