Skip to content

modify_listener async

modify_listener(
    *,
    config_overrides: Optional[AsyncElasticLoadBalancingv2ClientConfig] = None,
    listener_arn: Optional[ListenerArn] = None,
    port: Optional[Port] = None,
    protocol: Optional[ProtocolEnum] = None,
    ssl_policy: Optional[SslPolicyName] = None,
    certificates: Optional[CertificateList] = None,
    default_actions: Optional[Actions] = None,
    alpn_policy: Optional[AlpnPolicyName] = None,
    mutual_authentication: Optional[MutualAuthenticationAttributes] = None,
) -> ModifyListenerOutput

Replaces the specified properties of the specified listener. Any properties that you do not specify remain unchanged.

Changing the protocol from HTTPS to HTTP, or from TLS to TCP, removes the security policy and default certificate properties. If you change the protocol from HTTP to HTTPS, or from TCP to TLS, you must add the security policy and default certificate properties.

To add an item to a list, remove an item from a list, or update an item in a list, you must provide the entire list. For example, to add an action, specify a list with the current actions plus the new action.

Parameters:

  • listener_arn (Optional[ListenerArn], default: None ) –

    The Amazon Resource Name (ARN) of the listener.

  • port (Optional[Port], default: None ) –

    The port for connections from clients to the load balancer. You can't specify a port for a Gateway Load Balancer.

  • protocol (Optional[ProtocolEnum], default: None ) –

    The protocol for connections from clients to the load balancer. Application Load Balancers support the HTTP and HTTPS protocols. Network Load Balancers support the TCP, TLS, UDP, TCP_UDP, QUIC, and TCP_QUIC protocols. You can’t change the protocol to UDP, TCP_UDP, QUIC, or TCP_QUIC if dual-stack mode is enabled. You can't specify a protocol for a Gateway Load Balancer.

  • ssl_policy (Optional[SslPolicyName], default: None ) –

    [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 or Security policies in the Network Load Balancers Guide.

  • certificates (Optional[CertificateList], default: None ) –

    [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.

  • default_actions (Optional[Actions], default: None ) –

    The actions for the default rule.

  • alpn_policy (Optional[AlpnPolicyName], default: None ) –

    [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.

  • mutual_authentication (Optional[MutualAuthenticationAttributes], default: None ) –

    [HTTPS listeners] The mutual authentication configuration information.

Raises:

Examples:

To change the default action for a listener This example changes the default action for the specified listener.

>>> await client.modify_listener(listener_arn='arn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2', default_actions=[{'Type': 'forward', 'TargetGroupArn': 'arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-new-targets/2453ed029918f21f'}])
To change the server certificate
This example changes the server certificate for the specified HTTPS listener.
>>> await client.modify_listener(listener_arn='arn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/0467ef3c8400ae65', certificates=[{'CertificateArn': 'arn:aws:iam::123456789012:server-certificate/my-new-server-cert'}])
Source code in docs_src/capo_elastic_load_balancing_v2/_services/async_elastic_load_balancingv2.py
async def modify_listener(
    self,
    *,
    config_overrides: Optional[AsyncElasticLoadBalancingv2ClientConfig] = None,
    listener_arn: Optional[
        "capo_elastic_load_balancing_v2.types.listener_arn.ListenerArn"
    ] = None,
    port: Optional["capo_elastic_load_balancing_v2.types.port.Port"] = None,
    protocol: Optional[
        "capo_elastic_load_balancing_v2.types.protocol_enum.ProtocolEnum"
    ] = None,
    ssl_policy: Optional[
        "capo_elastic_load_balancing_v2.types.ssl_policy_name.SslPolicyName"
    ] = None,
    certificates: Optional[
        "capo_elastic_load_balancing_v2.types.certificate_list.CertificateList"
    ] = None,
    default_actions: Optional[
        "capo_elastic_load_balancing_v2.types.actions.Actions"
    ] = None,
    alpn_policy: Optional[
        "capo_elastic_load_balancing_v2.types.alpn_policy_name.AlpnPolicyName"
    ] = None,
    mutual_authentication: Optional[
        "capo_elastic_load_balancing_v2.types.mutual_authentication_attributes.MutualAuthenticationAttributes"
    ] = None,
) -> "capo_elastic_load_balancing_v2.types.modify_listener_output.ModifyListenerOutput":
    """<p>Replaces the specified properties of the specified listener. Any properties that you do not specify remain unchanged.</p> <p>Changing the protocol from HTTPS to HTTP, or from TLS to TCP, removes the security policy and default certificate properties. If you change the protocol from HTTP to HTTPS, or from TCP to TLS, you must add the security policy and default certificate properties.</p> <p>To add an item to a list, remove an item from a list, or update an item in a list, you must provide the entire list. For example, to add an action, specify a list with the current actions plus the new action.</p>

    Args:
        listener_arn: <p>The Amazon Resource Name (ARN) of the listener.</p>
        port: <p>The port for connections from clients to the load balancer. You can't specify a port for a Gateway Load Balancer.</p>
        protocol: <p>The protocol for connections from clients to the load balancer. Application Load Balancers support the HTTP and HTTPS protocols. Network Load Balancers support the TCP, TLS, UDP, TCP_UDP, QUIC, and TCP_QUIC protocols. You can’t change the protocol to UDP, TCP_UDP, QUIC, or TCP_QUIC if dual-stack mode is enabled. You can't specify a protocol for a Gateway Load Balancer.</p>
        ssl_policy: <p>[HTTPS and TLS listeners] The security policy that defines which protocols and ciphers are supported.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/elasticloadbalancing/latest/application/describe-ssl-policies.html">Security policies</a> in the <i>Application Load Balancers Guide</i> or <a href="https://docs.aws.amazon.com/elasticloadbalancing/latest/network/describe-ssl-policies.html">Security policies</a> in the <i>Network Load Balancers Guide</i>.</p>
        certificates: <p>[HTTPS and TLS listeners] The default certificate for the listener. You must provide exactly one certificate. Set <code>CertificateArn</code> to the certificate ARN but do not set <code>IsDefault</code>.</p>
        default_actions: <p>The actions for the default rule.</p>
        alpn_policy: <p>[TLS listeners] The name of the Application-Layer Protocol Negotiation (ALPN) policy. You can specify one policy name. The following are the possible values:</p> <ul> <li> <p> <code>HTTP1Only</code> </p> </li> <li> <p> <code>HTTP2Only</code> </p> </li> <li> <p> <code>HTTP2Optional</code> </p> </li> <li> <p> <code>HTTP2Preferred</code> </p> </li> <li> <p> <code>None</code> </p> </li> </ul> <p>For more information, see <a href="https://docs.aws.amazon.com/elasticloadbalancing/latest/network/load-balancer-listeners.html#alpn-policies">ALPN policies</a> in the <i>Network Load Balancers Guide</i>.</p>
        mutual_authentication: <p>[HTTPS listeners] The mutual authentication configuration information.</p>

    Raises:
        capo_elastic_load_balancing_v2.errors.alpn_policy_not_supported_exception.ALPNPolicyNotSupportedException: <p>The specified ALPN policy is not supported.</p>
        capo_elastic_load_balancing_v2.errors.certificate_not_found_exception.CertificateNotFoundException: <p>The specified certificate does not exist.</p>
        capo_elastic_load_balancing_v2.errors.duplicate_listener_exception.DuplicateListenerException: <p>A listener with the specified port already exists.</p>
        capo_elastic_load_balancing_v2.errors.incompatible_protocols_exception.IncompatibleProtocolsException: <p>The specified configuration is not valid with this protocol.</p>
        capo_elastic_load_balancing_v2.errors.invalid_configuration_request_exception.InvalidConfigurationRequestException: <p>The requested configuration is not valid.</p>
        capo_elastic_load_balancing_v2.errors.invalid_load_balancer_action_exception.InvalidLoadBalancerActionException: <p>The requested action is not valid.</p>
        capo_elastic_load_balancing_v2.errors.listener_not_found_exception.ListenerNotFoundException: <p>The specified listener does not exist.</p>
        capo_elastic_load_balancing_v2.errors.ssl_policy_not_found_exception.SSLPolicyNotFoundException: <p>The specified SSL policy does not exist.</p>
        capo_elastic_load_balancing_v2.errors.target_group_association_limit_exception.TargetGroupAssociationLimitException: <p>You've reached the limit on the number of load balancers per target group.</p>
        capo_elastic_load_balancing_v2.errors.target_group_not_found_exception.TargetGroupNotFoundException: <p>The specified target group does not exist.</p>
        capo_elastic_load_balancing_v2.errors.too_many_actions_exception.TooManyActionsException: <p>You've reached the limit on the number of actions per rule.</p>
        capo_elastic_load_balancing_v2.errors.too_many_certificates_exception.TooManyCertificatesException: <p>You've reached the limit on the number of certificates per load balancer.</p>
        capo_elastic_load_balancing_v2.errors.too_many_listeners_exception.TooManyListenersException: <p>You've reached the limit on the number of listeners per load balancer.</p>
        capo_elastic_load_balancing_v2.errors.too_many_registrations_for_target_id_exception.TooManyRegistrationsForTargetIdException: <p>You've reached the limit on the number of times a target can be registered with a load balancer.</p>
        capo_elastic_load_balancing_v2.errors.too_many_targets_exception.TooManyTargetsException: <p>You've reached the limit on the number of targets.</p>
        capo_elastic_load_balancing_v2.errors.too_many_unique_target_groups_per_load_balancer_exception.TooManyUniqueTargetGroupsPerLoadBalancerException: <p>You've reached the limit on the number of unique target groups per load balancer across all listeners. If a target group is used by multiple actions for a load balancer, it is counted as only one use.</p>
        capo_elastic_load_balancing_v2.errors.trust_store_not_found_exception.TrustStoreNotFoundException: <p>The specified trust store does not exist.</p>
        capo_elastic_load_balancing_v2.errors.trust_store_not_ready_exception.TrustStoreNotReadyException: <p>The specified trust store is not active.</p>
        capo_elastic_load_balancing_v2.errors.unsupported_protocol_exception.UnsupportedProtocolException: <p>The specified protocol is not supported.</p>
        capo_elastic_load_balancing_v2.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To change the default action for a listener
        This example changes the default action for the specified listener.

        >>> await client.modify_listener(listener_arn='arn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2', default_actions=[{'Type': 'forward', 'TargetGroupArn': 'arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-new-targets/2453ed029918f21f'}])
        To change the server certificate
        This example changes the server certificate for the specified HTTPS listener.

        >>> await client.modify_listener(listener_arn='arn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/0467ef3c8400ae65', certificates=[{'CertificateArn': 'arn:aws:iam::123456789012:server-certificate/my-new-server-cert'}])
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_elastic_load_balancing_v2.types.modify_listener_input.ModifyListenerInput]",
    ) -> AsyncOperationResponse[
        "capo_elastic_load_balancing_v2.types.modify_listener_output.ModifyListenerOutput"
    ]:
        import capo_elastic_load_balancing_v2._operations.elastic_load_balancing_v10.modify_listener

        (
            output,
            http_response,
        ) = await capo_elastic_load_balancing_v2._operations.elastic_load_balancing_v10.modify_listener.async_modify_listener(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ModifyListener")
    )
    input_: capo_elastic_load_balancing_v2.types.modify_listener_input.ModifyListenerInput = {}
    if listener_arn is not None:
        input_["listener_arn"] = listener_arn
    if port is not None:
        input_["port"] = port
    if protocol is not None:
        input_["protocol"] = protocol
    if ssl_policy is not None:
        input_["ssl_policy"] = ssl_policy
    if certificates is not None:
        input_["certificates"] = certificates
    if default_actions is not None:
        input_["default_actions"] = default_actions
    if alpn_policy is not None:
        input_["alpn_policy"] = alpn_policy
    if mutual_authentication is not None:
        input_["mutual_authentication"] = mutual_authentication

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output