createLoadBalancer method

Future<CreateAccessPointOutput> createLoadBalancer({
  1. required List<Listener> listeners,
  2. required String loadBalancerName,
  3. List<String>? availabilityZones,
  4. String? scheme,
  5. List<String>? securityGroups,
  6. List<String>? subnets,
  7. List<Tag>? tags,
})

Creates a Classic Load Balancer.

You can add listeners, security groups, subnets, and tags when you create your load balancer, or you can add them later using CreateLoadBalancerListeners, ApplySecurityGroupsToLoadBalancer, AttachLoadBalancerToSubnets, and AddTags.

To describe your current load balancers, see DescribeLoadBalancers. When you are finished with a load balancer, you can delete it using DeleteLoadBalancer.

You can create up to 20 load balancers per region per account. You can request an increase for the number of load balancers for your account. For more information, see Limits for Your Classic Load Balancer in the Classic Load Balancers Guide.

May throw DuplicateAccessPointNameException. May throw TooManyAccessPointsException. May throw CertificateNotFoundException. May throw InvalidConfigurationRequestException. May throw SubnetNotFoundException. May throw InvalidSubnetException. May throw InvalidSecurityGroupException. May throw InvalidSchemeException. May throw TooManyTagsException. May throw DuplicateTagKeysException. May throw UnsupportedProtocolException. May throw OperationNotPermittedException.

Parameter listeners : The listeners.

For more information, see Listeners for Your Classic Load Balancer in the Classic Load Balancers Guide.

Parameter loadBalancerName : The name of the load balancer.

This name must be unique within your set of load balancers for the region, must have a maximum of 32 characters, must contain only alphanumeric characters or hyphens, and cannot begin or end with a hyphen.

Parameter availabilityZones : One or more Availability Zones from the same region as the load balancer.

You must specify at least one Availability Zone.

You can add more Availability Zones after you create the load balancer using EnableAvailabilityZonesForLoadBalancer.

Parameter scheme : The type of a load balancer. Valid only for load balancers in a VPC.

By default, Elastic Load Balancing creates an Internet-facing load balancer with a DNS name that resolves to public IP addresses. For more information about Internet-facing and Internal load balancers, see Load Balancer Scheme in the Elastic Load Balancing User Guide.

Specify internal to create a load balancer with a DNS name that resolves to private IP addresses.

Parameter securityGroups : The IDs of the security groups to assign to the load balancer.

Parameter subnets : The IDs of the subnets in your VPC to attach to the load balancer. Specify one subnet per Availability Zone specified in AvailabilityZones.

Parameter tags : A list of tags to assign to the load balancer.

For more information about tagging your load balancer, see Tag Your Classic Load Balancer in the Classic Load Balancers Guide.

Implementation

Future<CreateAccessPointOutput> createLoadBalancer({
  required List<Listener> listeners,
  required String loadBalancerName,
  List<String>? availabilityZones,
  String? scheme,
  List<String>? securityGroups,
  List<String>? subnets,
  List<Tag>? tags,
}) async {
  ArgumentError.checkNotNull(listeners, 'listeners');
  ArgumentError.checkNotNull(loadBalancerName, 'loadBalancerName');
  final $request = <String, dynamic>{};
  $request['Listeners'] = listeners;
  $request['LoadBalancerName'] = loadBalancerName;
  availabilityZones?.also((arg) => $request['AvailabilityZones'] = arg);
  scheme?.also((arg) => $request['Scheme'] = arg);
  securityGroups?.also((arg) => $request['SecurityGroups'] = arg);
  subnets?.also((arg) => $request['Subnets'] = arg);
  tags?.also((arg) => $request['Tags'] = arg);
  final $result = await _protocol.send(
    $request,
    action: 'CreateLoadBalancer',
    version: '2012-06-01',
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    shape: shapes['CreateAccessPointInput'],
    shapes: shapes,
    resultWrapper: 'CreateLoadBalancerResult',
  );
  return CreateAccessPointOutput.fromXml($result);
}