Skip to content

set_subnets

set_subnets(
    *,
    config_overrides: Optional[ElasticLoadBalancingv2ClientConfig] = None,
    load_balancer_arn: Optional[LoadBalancerArn] = None,
    subnets: Optional[Subnets] = None,
    subnet_mappings: Optional[SubnetMappings] = None,
    ip_address_type: Optional[IpAddressType] = None,
    enable_prefix_for_ipv6_source_nat: Optional[
        EnablePrefixForIpv6SourceNatEnum
    ] = None,
) -> SetSubnetsOutput

Enables the Availability Zones for the specified public subnets for the specified Application Load Balancer, Network Load Balancer or Gateway Load Balancer. The specified subnets replace the previously enabled subnets.

Parameters:

  • load_balancer_arn (Optional[LoadBalancerArn], default: None ) –

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

  • subnets (Optional[Subnets], default: None ) –

    The IDs of the public subnets. You can specify only one subnet per Availability Zone. You must specify either subnets or subnet mappings.

    [Application Load Balancers] You must specify subnets from at least two Availability Zones.

    [Application Load Balancers on Outposts] You must specify one Outpost subnet.

    [Application Load Balancers on Local Zones] You can specify subnets from one or more Local Zones.

    [Network Load Balancers] You can specify subnets from one or more Availability Zones.

    [Gateway Load Balancers] You can specify subnets from one or more Availability Zones. You must include all subnets that were enabled previously, with their existing configurations, plus any additional subnets.

  • subnet_mappings (Optional[SubnetMappings], default: None ) –

    The IDs of the public subnets. You can specify only one subnet per Availability Zone. You must specify either subnets or subnet mappings.

    [Application Load Balancers] You must specify subnets from at least two Availability Zones. You can't specify Elastic IP addresses for your subnets.

    [Application Load Balancers on Outposts] You must specify one Outpost subnet.

    [Application Load Balancers on Local Zones] You can specify subnets from one or more Local Zones.

    [Network Load Balancers] You can specify subnets from one or more Availability Zones. You can specify one Elastic IP address per subnet if you need static IP addresses for your internet-facing load balancer. For internal load balancers, you can specify one private IP address per subnet from the IPv4 range of the subnet. For internet-facing load balancer, you can specify one IPv6 address per subnet.

    [Gateway Load Balancers] You can specify subnets from one or more Availability Zones.

  • ip_address_type (Optional[IpAddressType], default: None ) –

    The IP address type.

    [Application Load Balancers] The possible values are ipv4 (IPv4 addresses), dualstack (IPv4 and IPv6 addresses), and dualstack-without-public-ipv4 (public IPv6 addresses and private IPv4 and IPv6 addresses).

    [Network Load Balancers and Gateway Load Balancers] The possible values are ipv4 (IPv4 addresses) and dualstack (IPv4 and IPv6 addresses).

  • enable_prefix_for_ipv6_source_nat (Optional[EnablePrefixForIpv6SourceNatEnum], default: None ) –

    [Network Load Balancers with UDP listeners] Indicates whether to use an IPv6 prefix from each subnet for source NAT. The IP address type must be dualstack. The default value is off.

Raises:

Examples:

To enable Availability Zones for a load balancer This example enables the Availability Zones for the specified subnets for the specified load balancer.

>>> client.set_subnets(load_balancer_arn='arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188', subnets=['subnet-8360a9e7', 'subnet-b7d581c0'])
Source code in docs_src/capo_elastic_load_balancing_v2/_services/elastic_load_balancingv2.py
def set_subnets(
    self,
    *,
    config_overrides: Optional[ElasticLoadBalancingv2ClientConfig] = None,
    load_balancer_arn: Optional[
        "capo_elastic_load_balancing_v2.types.load_balancer_arn.LoadBalancerArn"
    ] = None,
    subnets: Optional[
        "capo_elastic_load_balancing_v2.types.subnets.Subnets"
    ] = None,
    subnet_mappings: Optional[
        "capo_elastic_load_balancing_v2.types.subnet_mappings.SubnetMappings"
    ] = None,
    ip_address_type: Optional[
        "capo_elastic_load_balancing_v2.types.ip_address_type.IpAddressType"
    ] = None,
    enable_prefix_for_ipv6_source_nat: Optional[
        "capo_elastic_load_balancing_v2.types.enable_prefix_for_ipv6_source_nat_enum.EnablePrefixForIpv6SourceNatEnum"
    ] = None,
) -> "capo_elastic_load_balancing_v2.types.set_subnets_output.SetSubnetsOutput":
    """<p>Enables the Availability Zones for the specified public subnets for the specified Application Load Balancer, Network Load Balancer or Gateway Load Balancer. The specified subnets replace the previously enabled subnets.</p>

    Args:
        load_balancer_arn: <p>The Amazon Resource Name (ARN) of the load balancer.</p>
        subnets: <p>The IDs of the public subnets. You can specify only one subnet per Availability Zone. You must specify either subnets or subnet mappings.</p> <p>[Application Load Balancers] You must specify subnets from at least two Availability Zones.</p> <p>[Application Load Balancers on Outposts] You must specify one Outpost subnet.</p> <p>[Application Load Balancers on Local Zones] You can specify subnets from one or more Local Zones.</p> <p>[Network Load Balancers] You can specify subnets from one or more Availability Zones.</p> <p>[Gateway Load Balancers] You can specify subnets from one or more Availability Zones. You must include all subnets that were enabled previously, with their existing configurations, plus any additional subnets.</p>
        subnet_mappings: <p>The IDs of the public subnets. You can specify only one subnet per Availability Zone. You must specify either subnets or subnet mappings.</p> <p>[Application Load Balancers] You must specify subnets from at least two Availability Zones. You can't specify Elastic IP addresses for your subnets.</p> <p>[Application Load Balancers on Outposts] You must specify one Outpost subnet.</p> <p>[Application Load Balancers on Local Zones] You can specify subnets from one or more Local Zones.</p> <p>[Network Load Balancers] You can specify subnets from one or more Availability Zones. You can specify one Elastic IP address per subnet if you need static IP addresses for your internet-facing load balancer. For internal load balancers, you can specify one private IP address per subnet from the IPv4 range of the subnet. For internet-facing load balancer, you can specify one IPv6 address per subnet.</p> <p>[Gateway Load Balancers] You can specify subnets from one or more Availability Zones.</p>
        ip_address_type: <p>The IP address type.</p> <p>[Application Load Balancers] The possible values are <code>ipv4</code> (IPv4 addresses), <code>dualstack</code> (IPv4 and IPv6 addresses), and <code>dualstack-without-public-ipv4</code> (public IPv6 addresses and private IPv4 and IPv6 addresses).</p> <p>[Network Load Balancers and Gateway Load Balancers] The possible values are <code>ipv4</code> (IPv4 addresses) and <code>dualstack</code> (IPv4 and IPv6 addresses).</p>
        enable_prefix_for_ipv6_source_nat: <p>[Network Load Balancers with UDP listeners] Indicates whether to use an IPv6 prefix from each subnet for source NAT. The IP address type must be <code>dualstack</code>. The default value is <code>off</code>.</p>

    Raises:
        capo_elastic_load_balancing_v2.errors.allocation_id_not_found_exception.AllocationIdNotFoundException: <p>The specified allocation ID does not exist.</p>
        capo_elastic_load_balancing_v2.errors.availability_zone_not_supported_exception.AvailabilityZoneNotSupportedException: <p>The specified Availability Zone is not supported.</p>
        capo_elastic_load_balancing_v2.errors.capacity_reservation_pending_exception.CapacityReservationPendingException: <p>There is a pending capacity reservation.</p>
        capo_elastic_load_balancing_v2.errors.invalid_configuration_request_exception.InvalidConfigurationRequestException: <p>The requested configuration is not valid.</p>
        capo_elastic_load_balancing_v2.errors.invalid_subnet_exception.InvalidSubnetException: <p>The specified subnet is out of available addresses.</p>
        capo_elastic_load_balancing_v2.errors.load_balancer_not_found_exception.LoadBalancerNotFoundException: <p>The specified load balancer does not exist.</p>
        capo_elastic_load_balancing_v2.errors.subnet_not_found_exception.SubnetNotFoundException: <p>The specified subnet does not exist.</p>
        capo_elastic_load_balancing_v2.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To enable Availability Zones for a load balancer
        This example enables the Availability Zones for the specified subnets for the specified load balancer.

        >>> client.set_subnets(load_balancer_arn='arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188', subnets=['subnet-8360a9e7', 'subnet-b7d581c0'])
    """

    def _handler(
        req: "OperationRequest[capo_elastic_load_balancing_v2.types.set_subnets_input.SetSubnetsInput]",
    ) -> OperationResponse[
        "capo_elastic_load_balancing_v2.types.set_subnets_output.SetSubnetsOutput"
    ]:
        import capo_elastic_load_balancing_v2._operations.elastic_load_balancing_v10.set_subnets

        output, http_response = (
            capo_elastic_load_balancing_v2._operations.elastic_load_balancing_v10.set_subnets.set_subnets(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("SetSubnets")
    )
    input_: capo_elastic_load_balancing_v2.types.set_subnets_input.SetSubnetsInput = {}
    if load_balancer_arn is not None:
        input_["load_balancer_arn"] = load_balancer_arn
    if subnets is not None:
        input_["subnets"] = subnets
    if subnet_mappings is not None:
        input_["subnet_mappings"] = subnet_mappings
    if ip_address_type is not None:
        input_["ip_address_type"] = ip_address_type
    if enable_prefix_for_ipv6_source_nat is not None:
        input_["enable_prefix_for_ipv6_source_nat"] = (
            enable_prefix_for_ipv6_source_nat
        )

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output