Skip to content

modify_load_balancer_attributes

modify_load_balancer_attributes(
    load_balancer_name: AccessPointName,
    load_balancer_attributes: LoadBalancerAttributes,
    *,
    config_overrides: Optional[ElasticLoadBalancingClientConfig] = None,
) -> ModifyLoadBalancerAttributesOutput

Modifies the attributes of the specified load balancer.

You can modify the load balancer attributes, such as AccessLogs, ConnectionDraining, and CrossZoneLoadBalancing by either enabling or disabling them. Or, you can modify the load balancer attribute ConnectionSettings by specifying an idle connection timeout value for your load balancer.

For more information, see the following in the Classic Load Balancers Guide:

Parameters:

Raises:

Examples:

To enable cross-zone load balancing This example enables cross-zone load balancing for the specified load balancer.

>>> client.modify_load_balancer_attributes(load_balancer_name='my-load-balancer', load_balancer_attributes={'CrossZoneLoadBalancing': {'Enabled': True}})
To enable connection draining
This example enables connection draining for the specified load balancer.
>>> client.modify_load_balancer_attributes(load_balancer_name='my-load-balancer', load_balancer_attributes={'ConnectionDraining': {'Enabled': True, 'Timeout': 300}})
Source code in docs_src/capo_elastic_load_balancing/_services/elastic_load_balancing.py
def modify_load_balancer_attributes(
    self,
    load_balancer_name: "capo_elastic_load_balancing.types.access_point_name.AccessPointName",
    load_balancer_attributes: "capo_elastic_load_balancing.types.load_balancer_attributes.LoadBalancerAttributes",
    *,
    config_overrides: Optional[ElasticLoadBalancingClientConfig] = None,
) -> "capo_elastic_load_balancing.types.modify_load_balancer_attributes_output.ModifyLoadBalancerAttributesOutput":
    """<p>Modifies the attributes of the specified load balancer.</p> <p>You can modify the load balancer attributes, such as <code>AccessLogs</code>, <code>ConnectionDraining</code>, and <code>CrossZoneLoadBalancing</code> by either enabling or disabling them. Or, you can modify the load balancer attribute <code>ConnectionSettings</code> by specifying an idle connection timeout value for your load balancer.</p> <p>For more information, see the following in the <i>Classic Load Balancers Guide</i>:</p> <ul> <li> <p> <a href="https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/enable-disable-crosszone-lb.html">Cross-Zone Load Balancing</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/config-conn-drain.html">Connection Draining</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/access-log-collection.html">Access Logs</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/config-idle-timeout.html">Idle Connection Timeout</a> </p> </li> </ul>

    Args:
        load_balancer_name: <p>The name of the load balancer.</p>
        load_balancer_attributes: <p>The attributes for the load balancer.</p>

    Raises:
        capo_elastic_load_balancing.errors.access_point_not_found_exception.AccessPointNotFoundException: <p>The specified load balancer does not exist.</p>
        capo_elastic_load_balancing.errors.invalid_configuration_request_exception.InvalidConfigurationRequestException: <p>The requested configuration change is not valid.</p>
        capo_elastic_load_balancing.errors.load_balancer_attribute_not_found_exception.LoadBalancerAttributeNotFoundException: <p>The specified load balancer attribute does not exist.</p>
        capo_elastic_load_balancing.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To enable cross-zone load balancing
        This example enables cross-zone load balancing for the specified load balancer.

        >>> client.modify_load_balancer_attributes(load_balancer_name='my-load-balancer', load_balancer_attributes={'CrossZoneLoadBalancing': {'Enabled': True}})
        To enable connection draining
        This example enables connection draining for the specified load balancer.

        >>> client.modify_load_balancer_attributes(load_balancer_name='my-load-balancer', load_balancer_attributes={'ConnectionDraining': {'Enabled': True, 'Timeout': 300}})
    """

    def _handler(
        req: "OperationRequest[capo_elastic_load_balancing.types.modify_load_balancer_attributes_input.ModifyLoadBalancerAttributesInput]",
    ) -> OperationResponse[
        "capo_elastic_load_balancing.types.modify_load_balancer_attributes_output.ModifyLoadBalancerAttributesOutput"
    ]:
        import capo_elastic_load_balancing._operations.elastic_load_balancing_v7.modify_load_balancer_attributes

        output, http_response = (
            capo_elastic_load_balancing._operations.elastic_load_balancing_v7.modify_load_balancer_attributes.modify_load_balancer_attributes(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ModifyLoadBalancerAttributes")
    )
    input_: capo_elastic_load_balancing.types.modify_load_balancer_attributes_input.ModifyLoadBalancerAttributesInput = {
        "load_balancer_name": load_balancer_name,
        "load_balancer_attributes": load_balancer_attributes,
    }

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output