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

**************************************
apply_security_groups_to_load_balancer
**************************************



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

  

  Associates one or more security groups with your load balancer in a virtual private cloud (VPC). The specified security groups override the previously associated security groups.

   

  For more information, see `Security Groups for Load Balancers in a VPC <https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-security-groups.html#elb-vpc-security-groups>`__ in the *Classic Load Balancers Guide*.

  

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


  **Request Syntax**
  ::

    response = client.apply_security_groups_to_load_balancer(
        LoadBalancerName='string',
        SecurityGroups=[
            'string',
        ]
    )
    
  :type LoadBalancerName: string
  :param LoadBalancerName: **[REQUIRED]** 

    The name of the load balancer.

    

  
  :type SecurityGroups: list
  :param SecurityGroups: **[REQUIRED]** 

    The IDs of the security groups to associate with the load balancer. Note that you cannot specify the name of the security group.

    

  
    - *(string) --* 

    

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

    
    ::

      {
          'SecurityGroups': [
              'string',
          ]
      }
      
    **Response Structure**

    

    - *(dict) --* 

      Contains the output of ApplySecurityGroupsToLoadBalancer.

      
      

      - **SecurityGroups** *(list) --* 

        The IDs of the security groups associated with the load balancer.

        
        

        - *(string) --* 
    
  
  **Exceptions**
  
  *   :py:class:`ElasticLoadBalancing.Client.exceptions.AccessPointNotFoundException`

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

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

  

  **Examples**

  This example associates a security group with the specified load balancer in a VPC.
  ::

    response = client.apply_security_groups_to_load_balancer(
        LoadBalancerName='my-load-balancer',
        SecurityGroups=[
            'sg-fc448899',
        ],
    )
    
    print(response)

  
  Expected Output:
  ::

    {
        'SecurityGroups': [
            'sg-fc448899',
        ],
        'ResponseMetadata': {
            '...': '...',
        },
    }

  