Adding or Deleting Listeners

You can add one or more listeners to a load balancer and remove them at any time if you no longer need them. Adding a listener to a load balancer enables it to listen to inbound flows on a specified port and in a specified protocol, and to send the traffic load to backend virtual machines (VMs) using a specified port and protocol.

As you can configure only one health check type per load balancer specifying the backend VMs port and protocol to check, we strongly recommend to create one load balancer per service to avoid any undetected failure, meaning that your listeners should all send the traffic load to backend VMs using the same port and protocol.

You cannot modify an existing listener. The only way to modify the port and protocol on the load balancer’s side or on the backend VMs' side is to add a listener with the corresponding configuration, and remove the former one if needed.

Adding or Deleting Listeners Using OSC CLI

Adding a Listener to a Load Balancer

The CreateLoadBalancerListeners command creates one or more listeners for a specified load balancer.

For more information, see About Load Balancers.

Request sample
$ osc-cli api CreateLoadBalancerListeners --profile "default" \
    --LoadBalancerName "example-lbu" \
    --Listeners '[
        {
          "BackendPort": 58,
          "BackendProtocol": "TCP",
          "LoadBalancerPort": 62,
          "LoadBalancerProtocol": "TCP",
        },
      ]'

This command contains the following attributes that you need to specify:

  • DryRun: (optional) If true, checks whether you have the required permissions to perform the action.

  • Listeners: One or more listeners for the load balancer.

  • LoadBalancerName: The name of the load balancer for which you want to create listeners.

The CreateLoadBalancerListeners command returns the following elements:

  • LoadBalancer: Information about the load balancer.

  • ResponseContext: Information about the context of the response.

Result sample
{
  "ResponseContext": {
    "RequestId": "0475ca1e-d0c5-441d-712a-da55a4175157"
  },
  "LoadBalancer": {
    "Tags": [],
    "SourceSecurityGroup": {
      "SecurityGroupName": "security-group-example",
      "SecurityGroupAccountId": "123456789012"
    },
    "SecuredCookies": false,
    "Subnets": [
      "subnet-12345678"
    ],
    "NetId": "vpc-12345678",
    "BackendVmIds": [],
    "ApplicationStickyCookiePolicies": [],
    "SecurityGroups": [
      "sg-12345678"
    ],
    "LoadBalancerType": "internal",
    "AccessLog": {
      "PublicationInterval": 60,
      "IsEnabled": false
    },
    "DnsName": "internal-example-lbu.123456789.eu-west-2.lbu.outscale.com",
    "HealthCheck": {
      "UnhealthyThreshold": 2,
      "Timeout": 5,
      "CheckInterval": 30,
      "Protocol": "TCP",
      "HealthyThreshold": 10,
      "Port": 80
    },
    "LoadBalancerStickyCookiePolicies": [],
    "SubregionNames": [
      "eu-west-2a"
    ],
    "Listeners": [
      {
        "BackendPort": 58,
        "BackendProtocol": "TCP",
        "LoadBalancerPort": 62,
        "LoadBalancerProtocol": "TCP"
      },
      {
        "BackendPort": 80,
        "BackendProtocol": "TCP",
        "LoadBalancerPort": 80,
        "LoadBalancerProtocol": "TCP"
      }
    ],
    "LoadBalancerName": "example-lbu"
  }
}

Deleting a Listener from a Load Balancer

The DeleteLoadBalancerListeners command deletes listeners of a specified load balancer.

Request sample
$ osc-cli api DeleteLoadBalancerListeners --profile "default" \
    --LoadBalancerName "example-lbu" \
    --LoadBalancerPorts '[80]'

This command contains the following attributes that you need to specify:

  • DryRun: (optional) If true, checks whether you have the required permissions to perform the action.

  • LoadBalancerName: The name of the load balancer for which you want to delete listeners.

  • LoadBalancerPorts: One or more port numbers of the listeners you want to delete.

The DeleteLoadBalancerListeners command returns the following elements:

  • LoadBalancer: Information about the load balancer.

  • ResponseContext: Information about the context of the response.

Result sample
{
  "ResponseContext": {
    "RequestId": "0475ca1e-d0c5-441d-712a-da55a4175157"
  },
  "LoadBalancer": {
    "Tags": [],
    "SourceSecurityGroup": {
      "SecurityGroupName": "security-group-example",
      "SecurityGroupAccountId": "123456789012"
    },
    "SecuredCookies": false,
    "Subnets": [
      "subnet-12345678"
    ],
    "NetId": "vpc-12345678",
    "BackendVmIds": [],
    "ApplicationStickyCookiePolicies": [],
    "SecurityGroups": [
      "sg-12345678"
    ],
    "LoadBalancerType": "internal",
    "AccessLog": {
      "PublicationInterval": 60,
      "IsEnabled": false
    },
    "DnsName": "internal-example-lbu.123456789.eu-west-2.lbu.outscale.com",
    "HealthCheck": {
      "UnhealthyThreshold": 2,
      "Timeout": 5,
      "CheckInterval": 30,
      "Protocol": "TCP",
      "HealthyThreshold": 10,
      "Port": 80
    },
    "LoadBalancerStickyCookiePolicies": [],
    "SubregionNames": [
      "eu-west-2a"
    ],
    "Listeners": [],
    "LoadBalancerName": "example-lbu"
  }
}

Adding or Deleting Listeners Using AWS CLI

Adding a Listener to a Load Balancer

To add one or more listeners to a load balancer, use the create-load-balancer-listeners command following this syntax:

Request sample
$ aws elb create-load-balancer-listeners \
    --profile YOUR_PROFILE \
     --load-balancer-name my-load-balancer \
    --listeners Protocol=TCP,LoadBalancerPort=62,InstanceProtocol=TCP,InstancePort=58 \
    --endpoint https://lbu.eu-west-2.outscale.com

This command contains the following attributes that you need to specify:

  • (optional) profile: The named profile you want to use, created when configuring AWS CLI. For more information, see Installing and Configuring AWS CLI.

  • load-balancer-name: The name of the load balancer.

  • listeners: One or more listeners for the load balancer. This attribute requires the following elements for each listener:

    To add several listeners, separate each of them with a space.

    • Protocol: The routing protocol of the load balancer (HTTP, HTTPS, TCP ou SSL).

    • LoadBalancerPort: The port on which the load balancer is listening (between 1 and 65535, both included).

    • InstancePort: The port on which the backend instances are listening (between 1 and 65535, both included).

    • (optional) InstanceProtocol: The protocol for routing traffic to backend instances (HTTP, HTTPS, TCP or SSL).

    • (optional) SSLCertificateId: The OUTSCALE Resource Name (ORN) of an SSL certificate. For more information, see Getting Information About a Server Certificate.

      An SSL certificate is required only if the load balancer protocol is HTTPS or SSL.

      For more information about how to configure your listener when using SSL certificates, see Configuring a Load Balancer for SSL Termination or SSL Passthrough.

  • endpoint: The endpoint corresponding to the Region you want to send the request to.

The specified listeners are added to the specified load balancer.

Deleting a Listener from a Load Balancer

To remove one or more listeners from a load balancer, use the delete-load-balancer-listeners command following this syntax:

Request sample
$ aws elb delete-load-balancer-listeners \
    --profile YOUR_PROFILE \
    --load-balancer-name LOAD_BALANCER-NAME \
    --load-balancer-ports 80 44 \
    --endpoint https://lbu.eu-west-2.outscale.com

This command contains the following attributes that you need to specify:

  • (optional) profile: The named profile you want to use, created when configuring AWS CLI. For more information, see Installing and Configuring AWS CLI.

  • load-balancer-name: The name of the load balancer.

  • load-balancer-ports: One or more load balancer ports corresponding to the listeners you want to remove.

    To remove several listeners from the load balancer, separate them with a space.

  • endpoint: The endpoint corresponding to the Region you want to send the request to.

The specified listeners are removed from the specified load balancer.

Related Pages

Corresponding API Methods

AWS™ and Amazon Web Services™ are trademarks of Amazon Technologies, Inc or its affiliates in the United States and/or other countries.