createListener method

Future<CreateListenerOutput> createListener({
  1. required List<Action> defaultActions,
  2. required String loadBalancerArn,
  3. List<String>? alpnPolicy,
  4. List<Certificate>? certificates,
  5. int? port,
  6. ProtocolEnum? protocol,
  7. String? sslPolicy,
  8. List<Tag>? tags,
})

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

For more information, see the following:

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.

May throw DuplicateListenerException. May throw TooManyListenersException. May throw TooManyCertificatesException. May throw LoadBalancerNotFoundException. May throw TargetGroupNotFoundException. May throw TargetGroupAssociationLimitException. May throw InvalidConfigurationRequestException. May throw IncompatibleProtocolsException. May throw SSLPolicyNotFoundException. May throw CertificateNotFoundException. May throw UnsupportedProtocolException. May throw TooManyRegistrationsForTargetIdException. May throw TooManyTargetsException. May throw TooManyActionsException. May throw InvalidLoadBalancerActionException. May throw TooManyUniqueTargetGroupsPerLoadBalancerException. May throw ALPNPolicyNotSupportedException. May throw TooManyTagsException.

Parameter defaultActions : The actions for the default rule.

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

Parameter alpnPolicy : TLS listeners The name of the Application-Layer Protocol Negotiation (ALPN) policy. You can specify one policy name. The following are the possible values:

  • HTTP1Only
  • HTTP2Only
  • HTTP2Optional
  • HTTP2Preferred
  • None
For more information, see ALPN policies in the Network Load Balancers Guide.

Parameter certificates : HTTPS and TLS listeners The default certificate for the listener. You must provide exactly one certificate. Set CertificateArn to the certificate ARN but do not set IsDefault.

Parameter port : The port on which the load balancer is listening. You cannot specify a port for a Gateway Load Balancer.

Parameter protocol : 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 protocols are TCP, TLS, UDP, and TCP_UDP. You can’t specify the UDP or TCP_UDP protocol if dual-stack mode is enabled. You cannot specify a protocol for a Gateway Load Balancer.

Parameter sslPolicy : HTTPS and TLS listeners The security policy that defines which protocols and ciphers are supported.

For more information, see Security policies in the Application Load Balancers Guide and Security policies in the Network Load Balancers Guide.

Parameter tags : The tags to assign to the listener.

Implementation

Future<CreateListenerOutput> createListener({
  required List<Action> defaultActions,
  required String loadBalancerArn,
  List<String>? alpnPolicy,
  List<Certificate>? certificates,
  int? port,
  ProtocolEnum? protocol,
  String? sslPolicy,
  List<Tag>? tags,
}) async {
  ArgumentError.checkNotNull(defaultActions, 'defaultActions');
  ArgumentError.checkNotNull(loadBalancerArn, 'loadBalancerArn');
  _s.validateNumRange(
    'port',
    port,
    1,
    65535,
  );
  final $request = <String, dynamic>{};
  $request['DefaultActions'] = defaultActions;
  $request['LoadBalancerArn'] = loadBalancerArn;
  alpnPolicy?.also((arg) => $request['AlpnPolicy'] = arg);
  certificates?.also((arg) => $request['Certificates'] = arg);
  port?.also((arg) => $request['Port'] = arg);
  protocol?.also((arg) => $request['Protocol'] = arg.toValue());
  sslPolicy?.also((arg) => $request['SslPolicy'] = arg);
  tags?.also((arg) => $request['Tags'] = arg);
  final $result = await _protocol.send(
    $request,
    action: 'CreateListener',
    version: '2015-12-01',
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    shape: shapes['CreateListenerInput'],
    shapes: shapes,
    resultWrapper: 'CreateListenerResult',
  );
  return CreateListenerOutput.fromXml($result);
}