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 or Network Load Balancer. The specified security groups override the previously associated security groups.

You can’t perform this operation on a Network Load Balancer unless you specified a security group for the load balancer when you created it.

You can’t associate a security group with a Gateway Load Balancer.

See also: AWS API Documentation

Request Syntax

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

    [REQUIRED]

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

  • SecurityGroups (list) –

    [REQUIRED]

    The IDs of the security groups.

    • (string) –

  • EnforceSecurityGroupInboundRulesOnPrivateLinkTraffic (string) – Indicates whether to evaluate inbound security group rules for traffic sent to a Network Load Balancer through Amazon Web Services PrivateLink. The default is on.

Return type:

dict

Returns:

Response Syntax

{
    'SecurityGroupIds': [
        'string',
    ],
    'EnforceSecurityGroupInboundRulesOnPrivateLinkTraffic': 'on'|'off'
}

Response Structure

  • (dict) –

    • SecurityGroupIds (list) –

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

      • (string) –

    • EnforceSecurityGroupInboundRulesOnPrivateLinkTraffic (string) –

      Indicates whether to evaluate inbound security group rules for traffic sent to a Network Load Balancer through Amazon Web Services PrivateLink.

Exceptions

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': {
        '...': '...',
    },
}