ElasticLoadBalancingv2 / Client / set_security_groups

set_security_groups#

ElasticLoadBalancingv2.Client.set_security_groups(**kwargs)#

Associates the specified security groups with the specified Application Load Balancer. The specified security groups override the previously associated security groups.

You can’t specify a security group for a Network Load Balancer or Gateway Load Balancer.

See also: AWS API Documentation

Request Syntax

response = client.set_security_groups(
    LoadBalancerArn='string',
    SecurityGroups=[
        'string',
    ]
)
Parameters:
  • LoadBalancerArn (string) –

    [REQUIRED]

    The Amazon Resource Name (ARN) of the load balancer.

  • SecurityGroups (list) –

    [REQUIRED]

    The IDs of the security groups.

    • (string) –

Return type:

dict

Returns:

Response Syntax

{
    'SecurityGroupIds': [
        'string',
    ]
}

Response Structure

  • (dict) –

    • SecurityGroupIds (list) –

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

      • (string) –

Exceptions

  • ElasticLoadBalancingv2.Client.exceptions.LoadBalancerNotFoundException

  • ElasticLoadBalancingv2.Client.exceptions.InvalidConfigurationRequestException

  • ElasticLoadBalancingv2.Client.exceptions.InvalidSecurityGroupException

Examples

This example associates the specified security group with the specified load balancer.

response = client.set_security_groups(
    LoadBalancerArn='arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188',
    SecurityGroups=[
        'sg-5943793c',
    ],
)

print(response)

Expected Output:

{
    'SecurityGroupIds': [
        'sg-5943793c',
    ],
    'ResponseMetadata': {
        '...': '...',
    },
}