ElasticLoadBalancing / Client / create_load_balancer_listeners

create_load_balancer_listeners#

ElasticLoadBalancing.Client.create_load_balancer_listeners(**kwargs)#

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.

See also: AWS API Documentation

Request Syntax

response = client.create_load_balancer_listeners(
    LoadBalancerName='string',
    Listeners=[
        {
            'Protocol': 'string',
            'LoadBalancerPort': 123,
            'InstanceProtocol': 'string',
            'InstancePort': 123,
            'SSLCertificateId': 'string'
        },
    ]
)
Parameters:
  • LoadBalancerName (string) –

    [REQUIRED]

    The name of the load balancer.

  • Listeners (list) –

    [REQUIRED]

    The listeners.

    • (dict) –

      Information about a listener.

      For information about the protocols and the ports supported by Elastic Load Balancing, see Listeners for Your Classic Load Balancer in the Classic Load Balancers Guide.

      • Protocol (string) – [REQUIRED]

        The load balancer transport protocol to use for routing: HTTP, HTTPS, TCP, or SSL.

      • LoadBalancerPort (integer) – [REQUIRED]

        The port on which the load balancer is listening. On EC2-VPC, you can specify any port from the range 1-65535. On EC2-Classic, you can specify any port from the following list: 25, 80, 443, 465, 587, 1024-65535.

      • InstanceProtocol (string) –

        The protocol to use for routing traffic to instances: HTTP, HTTPS, TCP, or SSL.

        If the front-end protocol is TCP or SSL, the back-end protocol must be TCP or SSL. If the front-end protocol is HTTP or HTTPS, the back-end protocol must be HTTP or HTTPS.

        If there is another listener with the same InstancePort whose InstanceProtocol is secure, (HTTPS or SSL), the listener’s InstanceProtocol must also be secure.

        If there is another listener with the same InstancePort whose InstanceProtocol is HTTP or TCP, the listener’s InstanceProtocol must be HTTP or TCP.

      • InstancePort (integer) – [REQUIRED]

        The port on which the instance is listening.

      • SSLCertificateId (string) –

        The Amazon Resource Name (ARN) of the server certificate.

Return type:

dict

Returns:

Response Syntax

{}

Response Structure

  • (dict) –

    Contains the parameters for CreateLoadBalancerListener.

Exceptions

  • ElasticLoadBalancing.Client.exceptions.AccessPointNotFoundException

  • ElasticLoadBalancing.Client.exceptions.DuplicateListenerException

  • ElasticLoadBalancing.Client.exceptions.CertificateNotFoundException

  • ElasticLoadBalancing.Client.exceptions.InvalidConfigurationRequestException

  • ElasticLoadBalancing.Client.exceptions.UnsupportedProtocolException

Examples

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

response = client.create_load_balancer_listeners(
    Listeners=[
        {
            'InstancePort': 80,
            'InstanceProtocol': 'HTTP',
            'LoadBalancerPort': 80,
            'Protocol': 'HTTP',
        },
    ],
    LoadBalancerName='my-load-balancer',
)

print(response)

Expected Output:

{
    'ResponseMetadata': {
        '...': '...',
    },
}

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

response = client.create_load_balancer_listeners(
    Listeners=[
        {
            'InstancePort': 80,
            'InstanceProtocol': 'HTTP',
            'LoadBalancerPort': 443,
            'Protocol': 'HTTPS',
            'SSLCertificateId': 'arn:aws:iam::123456789012:server-certificate/my-server-cert',
        },
    ],
    LoadBalancerName='my-load-balancer',
)

print(response)

Expected Output:

{
    'ResponseMetadata': {
        '...': '...',
    },
}