Adds one or more subnets to the set of configured subnets for the specified load balancer.
The load balancer evenly distributes requests across all registered subnets. For more information, see Add or Remove Subnets for Your Load Balancer in a VPC in the Classic Load Balancers Guide.
Parameters:
-
load_balancer_name
(AccessPointName)
–
The name of the load balancer.
-
subnets
(Subnets)
–
The IDs of the subnets to add. You can add only one subnet per Availability Zone.
Raises:
Examples:
To attach subnets to a load balancer
This example adds the specified subnet to the set of configured subnets for the specified load balancer.
>>> await client.attach_load_balancer_to_subnets(load_balancer_name='my-load-balancer', subnets=['subnet-0ecac448'])
Source code in docs_src/capo_elastic_load_balancing/_services/async_elastic_load_balancing.py
| async def attach_load_balancer_to_subnets(
self,
load_balancer_name: "capo_elastic_load_balancing.types.access_point_name.AccessPointName",
subnets: "capo_elastic_load_balancing.types.subnets.Subnets",
*,
config_overrides: Optional[AsyncElasticLoadBalancingClientConfig] = None,
) -> "capo_elastic_load_balancing.types.attach_load_balancer_to_subnets_output.AttachLoadBalancerToSubnetsOutput":
"""<p>Adds one or more subnets to the set of configured subnets for the specified load balancer.</p> <p>The load balancer evenly distributes requests across all registered subnets. For more information, see <a href="https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-manage-subnets.html">Add or Remove Subnets for Your Load Balancer in a VPC</a> in the <i>Classic Load Balancers Guide</i>.</p>
Args:
load_balancer_name: <p>The name of the load balancer.</p>
subnets: <p>The IDs of the subnets to add. You can add only one subnet per Availability Zone.</p>
Raises:
capo_elastic_load_balancing.errors.access_point_not_found_exception.AccessPointNotFoundException: <p>The specified load balancer does not exist.</p>
capo_elastic_load_balancing.errors.invalid_configuration_request_exception.InvalidConfigurationRequestException: <p>The requested configuration change is not valid.</p>
capo_elastic_load_balancing.errors.invalid_subnet_exception.InvalidSubnetException: <p>The specified VPC has no associated Internet gateway.</p>
capo_elastic_load_balancing.errors.subnet_not_found_exception.SubnetNotFoundException: <p>One or more of the specified subnets do not exist.</p>
capo_elastic_load_balancing.errors.UnknownServiceError: The service returned an error code this client does not model.
Examples:
To attach subnets to a load balancer
This example adds the specified subnet to the set of configured subnets for the specified load balancer.
>>> await client.attach_load_balancer_to_subnets(load_balancer_name='my-load-balancer', subnets=['subnet-0ecac448'])
"""
async def _handler(
req: "AsyncOperationRequest[capo_elastic_load_balancing.types.attach_load_balancer_to_subnets_input.AttachLoadBalancerToSubnetsInput]",
) -> AsyncOperationResponse[
"capo_elastic_load_balancing.types.attach_load_balancer_to_subnets_output.AttachLoadBalancerToSubnetsOutput"
]:
import capo_elastic_load_balancing._operations.elastic_load_balancing_v7.attach_load_balancer_to_subnets
(
output,
http_response,
) = await capo_elastic_load_balancing._operations.elastic_load_balancing_v7.attach_load_balancer_to_subnets.async_attach_load_balancer_to_subnets(
req.options, req.input
)
return AsyncOperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("AttachLoadBalancerToSubnets")
)
input_: capo_elastic_load_balancing.types.attach_load_balancer_to_subnets_input.AttachLoadBalancerToSubnetsInput = {
"load_balancer_name": load_balancer_name,
"subnets": subnets,
}
response = await aexecute_pipeline(
AsyncOperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
await response.response.aclose()
return response.output
|