:doc:`ElasticLoadBalancing <../../elb>` / Client / modify_load_balancer_attributes

*******************************
modify_load_balancer_attributes
*******************************



.. py:method:: ElasticLoadBalancing.Client.modify_load_balancer_attributes(**kwargs)

  

  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*:

   

  
  * `Cross-Zone Load Balancing <https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/enable-disable-crosszone-lb.html>`__
   
  * `Connection Draining <https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/config-conn-drain.html>`__
   
  * `Access Logs <https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/access-log-collection.html>`__
   
  * `Idle Connection Timeout <https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/config-idle-timeout.html>`__
  

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/elasticloadbalancing-2012-06-01/ModifyLoadBalancerAttributes>`_  


  **Request Syntax**
  ::

    response = client.modify_load_balancer_attributes(
        LoadBalancerName='string',
        LoadBalancerAttributes={
            'CrossZoneLoadBalancing': {
                'Enabled': True|False
            },
            'AccessLog': {
                'Enabled': True|False,
                'S3BucketName': 'string',
                'EmitInterval': 123,
                'S3BucketPrefix': 'string'
            },
            'ConnectionDraining': {
                'Enabled': True|False,
                'Timeout': 123
            },
            'ConnectionSettings': {
                'IdleTimeout': 123
            },
            'AdditionalAttributes': [
                {
                    'Key': 'string',
                    'Value': 'string'
                },
            ]
        }
    )
    
  :type LoadBalancerName: string
  :param LoadBalancerName: **[REQUIRED]** 

    The name of the load balancer.

    

  
  :type LoadBalancerAttributes: dict
  :param LoadBalancerAttributes: **[REQUIRED]** 

    The attributes for the load balancer.

    

  
    - **CrossZoneLoadBalancing** *(dict) --* 

      If enabled, the load balancer routes the request traffic evenly across all instances regardless of the Availability Zones.

       

      For more information, see `Configure Cross-Zone Load Balancing <https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/enable-disable-crosszone-lb.html>`__ in the *Classic Load Balancers Guide*.

      

    
      - **Enabled** *(boolean) --* **[REQUIRED]** 

        Specifies whether cross-zone load balancing is enabled for the load balancer.

        

      
    
    - **AccessLog** *(dict) --* 

      If enabled, the load balancer captures detailed information of all requests and delivers the information to the Amazon S3 bucket that you specify.

       

      For more information, see `Enable Access Logs <https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/enable-access-logs.html>`__ in the *Classic Load Balancers Guide*.

      

    
      - **Enabled** *(boolean) --* **[REQUIRED]** 

        Specifies whether access logs are enabled for the load balancer.

        

      
      - **S3BucketName** *(string) --* 

        The name of the Amazon S3 bucket where the access logs are stored.

        

      
      - **EmitInterval** *(integer) --* 

        The interval for publishing the access logs. You can specify an interval of either 5 minutes or 60 minutes.

         

        Default: 60 minutes

        

      
      - **S3BucketPrefix** *(string) --* 

        The logical hierarchy you created for your Amazon S3 bucket, for example ``my-bucket-prefix/prod``. If the prefix is not provided, the log is placed at the root level of the bucket.

        

      
    
    - **ConnectionDraining** *(dict) --* 

      If enabled, the load balancer allows existing requests to complete before the load balancer shifts traffic away from a deregistered or unhealthy instance.

       

      For more information, see `Configure Connection Draining <https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/config-conn-drain.html>`__ in the *Classic Load Balancers Guide*.

      

    
      - **Enabled** *(boolean) --* **[REQUIRED]** 

        Specifies whether connection draining is enabled for the load balancer.

        

      
      - **Timeout** *(integer) --* 

        The maximum time, in seconds, to keep the existing connections open before deregistering the instances.

        

      
    
    - **ConnectionSettings** *(dict) --* 

      If enabled, the load balancer allows the connections to remain idle (no data is sent over the connection) for the specified duration.

       

      By default, Elastic Load Balancing maintains a 60-second idle connection timeout for both front-end and back-end connections of your load balancer. For more information, see `Configure Idle Connection Timeout <https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/config-idle-timeout.html>`__ in the *Classic Load Balancers Guide*.

      

    
      - **IdleTimeout** *(integer) --* **[REQUIRED]** 

        The time, in seconds, that the connection is allowed to be idle (no data has been sent over the connection) before it is closed by the load balancer.

        

      
    
    - **AdditionalAttributes** *(list) --* 

      Any additional attributes.

      

    
      - *(dict) --* 

        Information about additional load balancer attributes.

        

      
        - **Key** *(string) --* 

          The name of the attribute.

           

          The following attribute is supported.

           

          
          * ``elb.http.desyncmitigationmode`` - Determines how the load balancer handles requests that might pose a security risk to your application. The possible values are ``monitor``, ``defensive``, and ``strictest``. The default is ``defensive``.
          

          

        
        - **Value** *(string) --* 

          This value of the attribute.

          

        
      
  
  
  
  :rtype: dict
  :returns: 
    
    **Response Syntax**

    
    ::

      {
          'LoadBalancerName': 'string',
          'LoadBalancerAttributes': {
              'CrossZoneLoadBalancing': {
                  'Enabled': True|False
              },
              'AccessLog': {
                  'Enabled': True|False,
                  'S3BucketName': 'string',
                  'EmitInterval': 123,
                  'S3BucketPrefix': 'string'
              },
              'ConnectionDraining': {
                  'Enabled': True|False,
                  'Timeout': 123
              },
              'ConnectionSettings': {
                  'IdleTimeout': 123
              },
              'AdditionalAttributes': [
                  {
                      'Key': 'string',
                      'Value': 'string'
                  },
              ]
          }
      }
      
    **Response Structure**

    

    - *(dict) --* 

      Contains the output of ModifyLoadBalancerAttributes.

      
      

      - **LoadBalancerName** *(string) --* 

        The name of the load balancer.

        
      

      - **LoadBalancerAttributes** *(dict) --* 

        Information about the load balancer attributes.

        
        

        - **CrossZoneLoadBalancing** *(dict) --* 

          If enabled, the load balancer routes the request traffic evenly across all instances regardless of the Availability Zones.

           

          For more information, see `Configure Cross-Zone Load Balancing <https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/enable-disable-crosszone-lb.html>`__ in the *Classic Load Balancers Guide*.

          
          

          - **Enabled** *(boolean) --* 

            Specifies whether cross-zone load balancing is enabled for the load balancer.

            
      
        

        - **AccessLog** *(dict) --* 

          If enabled, the load balancer captures detailed information of all requests and delivers the information to the Amazon S3 bucket that you specify.

           

          For more information, see `Enable Access Logs <https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/enable-access-logs.html>`__ in the *Classic Load Balancers Guide*.

          
          

          - **Enabled** *(boolean) --* 

            Specifies whether access logs are enabled for the load balancer.

            
          

          - **S3BucketName** *(string) --* 

            The name of the Amazon S3 bucket where the access logs are stored.

            
          

          - **EmitInterval** *(integer) --* 

            The interval for publishing the access logs. You can specify an interval of either 5 minutes or 60 minutes.

             

            Default: 60 minutes

            
          

          - **S3BucketPrefix** *(string) --* 

            The logical hierarchy you created for your Amazon S3 bucket, for example ``my-bucket-prefix/prod``. If the prefix is not provided, the log is placed at the root level of the bucket.

            
      
        

        - **ConnectionDraining** *(dict) --* 

          If enabled, the load balancer allows existing requests to complete before the load balancer shifts traffic away from a deregistered or unhealthy instance.

           

          For more information, see `Configure Connection Draining <https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/config-conn-drain.html>`__ in the *Classic Load Balancers Guide*.

          
          

          - **Enabled** *(boolean) --* 

            Specifies whether connection draining is enabled for the load balancer.

            
          

          - **Timeout** *(integer) --* 

            The maximum time, in seconds, to keep the existing connections open before deregistering the instances.

            
      
        

        - **ConnectionSettings** *(dict) --* 

          If enabled, the load balancer allows the connections to remain idle (no data is sent over the connection) for the specified duration.

           

          By default, Elastic Load Balancing maintains a 60-second idle connection timeout for both front-end and back-end connections of your load balancer. For more information, see `Configure Idle Connection Timeout <https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/config-idle-timeout.html>`__ in the *Classic Load Balancers Guide*.

          
          

          - **IdleTimeout** *(integer) --* 

            The time, in seconds, that the connection is allowed to be idle (no data has been sent over the connection) before it is closed by the load balancer.

            
      
        

        - **AdditionalAttributes** *(list) --* 

          Any additional attributes.

          
          

          - *(dict) --* 

            Information about additional load balancer attributes.

            
            

            - **Key** *(string) --* 

              The name of the attribute.

               

              The following attribute is supported.

               

              
              * ``elb.http.desyncmitigationmode`` - Determines how the load balancer handles requests that might pose a security risk to your application. The possible values are ``monitor``, ``defensive``, and ``strictest``. The default is ``defensive``.
              

              
            

            - **Value** *(string) --* 

              This value of the attribute.

              
        
      
    
  
  **Exceptions**
  
  *   :py:class:`ElasticLoadBalancing.Client.exceptions.AccessPointNotFoundException`

  
  *   :py:class:`ElasticLoadBalancing.Client.exceptions.LoadBalancerAttributeNotFoundException`

  
  *   :py:class:`ElasticLoadBalancing.Client.exceptions.InvalidConfigurationRequestException`

  

  **Examples**

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

    response = client.modify_load_balancer_attributes(
        LoadBalancerAttributes={
            'CrossZoneLoadBalancing': {
                'Enabled': True,
            },
        },
        LoadBalancerName='my-load-balancer',
    )
    
    print(response)

  
  Expected Output:
  ::

    {
        'LoadBalancerAttributes': {
            'CrossZoneLoadBalancing': {
                'Enabled': True,
            },
        },
        'LoadBalancerName': 'my-load-balancer',
        'ResponseMetadata': {
            '...': '...',
        },
    }

  

  This example enables connection draining for the specified load balancer.
  ::

    response = client.modify_load_balancer_attributes(
        LoadBalancerAttributes={
            'ConnectionDraining': {
                'Enabled': True,
                'Timeout': 300,
            },
        },
        LoadBalancerName='my-load-balancer',
    )
    
    print(response)

  
  Expected Output:
  ::

    {
        'LoadBalancerAttributes': {
            'ConnectionDraining': {
                'Enabled': True,
                'Timeout': 300,
            },
        },
        'LoadBalancerName': 'my-load-balancer',
        'ResponseMetadata': {
            '...': '...',
        },
    }

  