attachInstancesToLoadBalancer method
Attaches one or more Lightsail instances to a load balancer.
After some time, the instances are attached to the load balancer and the health check status is available.
The attach instances to load balancer
operation supports
tag-based access control via resource tags applied to the resource
identified by load balancer name
. For more information, see
the Lightsail
Dev Guide.
May throw ServiceException. May throw InvalidInputException. May throw NotFoundException. May throw OperationFailureException. May throw AccessDeniedException. May throw AccountSetupInProgressException. May throw UnauthenticatedException.
Parameter instanceNames
:
An array of strings representing the instance name(s) you want to attach
to your load balancer.
An instance must be running
before you can attach it to your
load balancer.
There are no additional limits on the number of instances you can attach to your load balancer, aside from the limit of Lightsail instances you can create in your account (20).
Parameter loadBalancerName
:
The name of the load balancer.
Implementation
Future<AttachInstancesToLoadBalancerResult> attachInstancesToLoadBalancer({
required List<String> instanceNames,
required String loadBalancerName,
}) async {
ArgumentError.checkNotNull(instanceNames, 'instanceNames');
ArgumentError.checkNotNull(loadBalancerName, 'loadBalancerName');
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'Lightsail_20161128.AttachInstancesToLoadBalancer'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'instanceNames': instanceNames,
'loadBalancerName': loadBalancerName,
},
);
return AttachInstancesToLoadBalancerResult.fromJson(jsonResponse.body);
}