Table Of Contents

Feedback

User Guide

First time using the AWS CLI? See the User Guide for help getting started.

[ aws . elbv2 ]

create-listener

Description

Creates a listener for the specified Application Load Balancer or Network Load Balancer.

To update a listener, use modify-listener . When you are finished with a listener, you can delete it using delete-listener . If you are finished with both the listener and the load balancer, you can delete them both using delete-load-balancer .

This operation is idempotent, which means that it completes at most one time. If you attempt to create multiple listeners with the same settings, each call succeeds.

For more information, see Listeners for Your Application Load Balancers in the Application Load Balancers Guide and Listeners for Your Network Load Balancers in the Network Load Balancers Guide .

See also: AWS API Documentation

Synopsis

  create-listener
--load-balancer-arn <value>
--protocol <value>
--port <value>
[--ssl-policy <value>]
[--certificates <value>]
--default-actions <value>
[--cli-input-json <value>]
[--generate-cli-skeleton <value>]

Options

--load-balancer-arn (string)

The Amazon Resource Name (ARN) of the load balancer.

--protocol (string)

The protocol for connections from clients to the load balancer. For Application Load Balancers, the supported protocols are HTTP and HTTPS. For Network Load Balancers, the supported protocol is TCP.

Possible values:

  • HTTP
  • HTTPS
  • TCP

--port (integer)

The port on which the load balancer is listening.

--ssl-policy (string)

[HTTPS listeners] The security policy that defines which ciphers and protocols are supported. The default is the current predefined security policy.

--certificates (list)

[HTTPS listeners] The SSL server certificate. You must provide exactly one certificate.

Shorthand Syntax:

CertificateArn=string,IsDefault=boolean ...

JSON Syntax:

[
  {
    "CertificateArn": "string",
    "IsDefault": true|false
  }
  ...
]

--default-actions (list)

The default action for the listener. For Application Load Balancers, the protocol of the specified target group must be HTTP or HTTPS. For Network Load Balancers, the protocol of the specified target group must be TCP.

Shorthand Syntax:

Type=string,TargetGroupArn=string ...

JSON Syntax:

[
  {
    "Type": "forward",
    "TargetGroupArn": "string"
  }
  ...
]

--cli-input-json (string) Performs service operation based on the JSON string provided. The JSON string follows the format provided by --generate-cli-skeleton. If other arguments are provided on the command line, the CLI values will override the JSON-provided values.

--generate-cli-skeleton (string) Prints a JSON skeleton to standard output without sending an API request. If provided with no value or the value input, prints a sample input JSON that can be used as an argument for --cli-input-json. If provided with the value output, it validates the command inputs and returns a sample output JSON for that command.

Examples

To create an HTTP listener

This example creates an HTTP listener for the specified Application Load Balancer that forwards requests to the specified target group.

Command:

aws elbv2 create-listener --load-balancer-arn arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188 --protocol HTTP --port 80 --default-actions Type=forward,TargetGroupArn=arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067

Output:

{
  "Listeners": [
      {
          "Protocol": "HTTP",
          "Port": 80,
          "DefaultActions": [
              {
                  "TargetGroupArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067",
                  "Type": "forward"
              }
          ],
          "LoadBalancerArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188",
          "ListenerArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2"
      }
  ]
}

To create an HTTPS listener

This example creates an HTTPS listener for the specified Application Load Balancer that forwards requests to the specified target group. Note that you must specify an SSL certificate for an HTTPS listener. You can create and manage certificates using AWS Certificate Manager (ACM). Alternatively, you can create a certificate using SSL/TLS tools, get the certificate signed by a certificate authority (CA), and upload the certificate to AWS Identity and Access Management (IAM).

Command:

aws elbv2 create-listener --load-balancer-arn arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188 --protocol HTTPS --port 443 --certificates CertificateArn=arn:aws:acm:us-west-2:123456789012:certificate/3dcb0a41-bd72-4774-9ad9-756919c40557 --ssl-policy ELBSecurityPolicy-2016-08 --default-actions Type=forward,TargetGroupArn=arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067

Output:

{
  "Listeners": [
      {
          "Protocol": "HTTPS",
          "Port": 443,
          "DefaultActions": [
              {
                  "TargetGroupArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067",
                  "Type": "forward"
              }
          ],
          "SslPolicy": "ELBSecurityPolicy-2016-08",
          "Certificates": [
              {
                  "CertificateArn": "arn:aws:acm:us-west-2:123456789012:certificate/3dcb0a41-bd72-4774-9ad9-756919c40557"
              }
          ],
          "LoadBalancerArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188",
          "ListenerArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2"
      }
  ]
}

To create a TCP listener

This example creates a TCP listener for the specified Network Load Balancer that forwards requests to the specified target group.

Command:

aws elbv2 create-listener --load-balancer-arn arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/net/my-network-load-balancer/5d1b75f4f1cee11e --protocol TCP --port 80 --default-actions Type=forward,TargetGroupArn=arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-tcp-targets/b6bba954d1361c78

Output:

{
  "Listeners": [
      {
          "Protocol": "TCP",
          "Port": 80,
          "DefaultActions": [
              {
                  "TargetGroupArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-tcp-targets/b6bba954d1361c78",
                  "Type": "forward"
              }
          ],
          "LoadBalancerArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/net/my-network-load-balancer/5d1b75f4f1cee11e",
          "ListenerArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:listener/net/my-network-load-balancer/5d1b75f4f1cee11e/08f101851e4bca2c"
      }
  ]
}

Output

Listeners -> (list)

Information about the listener.

(structure)

Information about a listener.

ListenerArn -> (string)

The Amazon Resource Name (ARN) of the listener.

LoadBalancerArn -> (string)

The Amazon Resource Name (ARN) of the load balancer.

Port -> (integer)

The port on which the load balancer is listening.

Protocol -> (string)

The protocol for connections from clients to the load balancer.

Certificates -> (list)

The SSL server certificate. You must provide a certificate if the protocol is HTTPS.

(structure)

Information about an SSL server certificate.

CertificateArn -> (string)

The Amazon Resource Name (ARN) of the certificate.

IsDefault -> (boolean)

Indicates whether the certificate is the default certificate.

SslPolicy -> (string)

The security policy that defines which ciphers and protocols are supported. The default is the current predefined security policy.

DefaultActions -> (list)

The default actions for the listener.

(structure)

Information about an action.

Type -> (string)

The type of action.

TargetGroupArn -> (string)

The Amazon Resource Name (ARN) of the target group.