AWS SDK Version 3 for .NET
API Reference

AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

Creates one or more listeners for the specified load balancer. If a listener with the specified port does not already exist, it is created; otherwise, the properties of the new listener must match the properties of the existing listener.

For more information, see Listeners for Your Classic Load Balancer in the Classic Load Balancers Guide.

Note:

For .NET Core this operation is only available in asynchronous form. Please refer to CreateLoadBalancerListenersAsync.

Namespace: Amazon.ElasticLoadBalancing
Assembly: AWSSDK.ElasticLoadBalancing.dll
Version: 3.x.y.z

Syntax

C#
public abstract CreateLoadBalancerListenersResponse CreateLoadBalancerListeners(
         CreateLoadBalancerListenersRequest request
)

Parameters

request
Type: Amazon.ElasticLoadBalancing.Model.CreateLoadBalancerListenersRequest

Container for the necessary parameters to execute the CreateLoadBalancerListeners service method.

Return Value


The response from the CreateLoadBalancerListeners service method, as returned by ElasticLoadBalancing.

Exceptions

ExceptionCondition
AccessPointNotFoundException The specified load balancer does not exist.
CertificateNotFoundException The specified ARN does not refer to a valid SSL certificate in AWS Identity and Access Management (IAM) or AWS Certificate Manager (ACM). Note that if you recently uploaded the certificate to IAM, this error might indicate that the certificate is not fully available yet.
DuplicateListenerException A listener already exists for the specified load balancer name and port, but with a different instance port, protocol, or SSL certificate.
InvalidConfigurationRequestException The requested configuration change is not valid.
UnsupportedProtocolException The specified protocol or signature version is not supported.

Examples

This example creates a listener for your load balancer at port 80 using the HTTP protocol.

To create an HTTP listener for a load balancer


var client = new AmazonElasticLoadBalancingClient();
var response = client.CreateLoadBalancerListeners(new CreateLoadBalancerListenersRequest 
{
    Listeners = new List<Listener> {
        new Listener {
            InstancePort = 80,
            InstanceProtocol = "HTTP",
            LoadBalancerPort = 80,
            Protocol = "HTTP"
        }
    },
    LoadBalancerName = "my-load-balancer"
});


            

This example creates a listener for your load balancer at port 443 using the HTTPS protocol.

To create an HTTPS listener for a load balancer


var client = new AmazonElasticLoadBalancingClient();
var response = client.CreateLoadBalancerListeners(new CreateLoadBalancerListenersRequest 
{
    Listeners = new List<Listener> {
        new Listener {
            InstancePort = 80,
            InstanceProtocol = "HTTP",
            LoadBalancerPort = 443,
            Protocol = "HTTPS",
            SSLCertificateId = "arn:aws:iam::123456789012:server-certificate/my-server-cert"
        }
    },
    LoadBalancerName = "my-load-balancer"
});


            

Version Information

.NET Framework:
Supported in: 4.5 and newer, 3.5

See Also