apply_security_groups_to_load_balancer

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 in the Classic Load Balancers Guide .

See also: AWS API Documentation

Request Syntax

response = client.apply_security_groups_to_load_balancer(
    LoadBalancerName='string',
    SecurityGroups=[
        'string',
    ]
)
Parameters
  • LoadBalancerName (string) --

    [REQUIRED]

    The name of the load balancer.

  • SecurityGroups (list) --

    [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) --
Return type

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

  • ElasticLoadBalancing.Client.exceptions.AccessPointNotFoundException
  • ElasticLoadBalancing.Client.exceptions.InvalidConfigurationRequestException
  • 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': {
        '...': '...',
    },
}