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',
]
)
[REQUIRED]
The name of the load balancer.
[REQUIRED]
The IDs of the security groups to associate with the load balancer. Note that you cannot specify the name of the security group.
dict
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.
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': {
'...': '...',
},
}