create_load_balancer
async
¶
create_load_balancer(
load_balancer_name: AccessPointName,
listeners: Listeners,
*,
config_overrides: Optional[AsyncElasticLoadBalancingClientConfig] = None,
availability_zones: Optional[AvailabilityZones] = None,
subnets: Optional[Subnets] = None,
security_groups: Optional[SecurityGroups] = None,
scheme: Optional[LoadBalancerScheme] = None,
tags: Optional[TagList] = None,
) -> CreateAccessPointOutput
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.
Parameters:
-
load_balancer_name(AccessPointName) –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.
-
listeners(Listeners) –The listeners.
For more information, see Listeners for Your Classic Load Balancer in the Classic Load Balancers Guide.
-
availability_zones(Optional[AvailabilityZones], default:None) –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.
-
subnets(Optional[Subnets], default:None) –The IDs of the subnets in your VPC to attach to the load balancer. Specify one subnet per Availability Zone specified in
AvailabilityZones. -
security_groups(Optional[SecurityGroups], default:None) –The IDs of the security groups to assign to the load balancer.
-
scheme(Optional[LoadBalancerScheme], default:None) –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
internalto create a load balancer with a DNS name that resolves to private IP addresses. -
tags(Optional[TagList], default:None) –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.
Raises:
-
CertificateNotFoundException–The specified ARN does not refer to a valid SSL certificate in AWS Identity and Access Management (IAM) or AWS Certificate Manager (ACM). Note that if you recently uploaded the certificate to IAM, this error might indicate that the certificate is not fully available yet.
-
DuplicateAccessPointNameException–The specified load balancer name already exists for this account.
-
DuplicateTagKeysException–A tag key was specified more than once.
-
InvalidConfigurationRequestException–The requested configuration change is not valid.
-
InvalidSchemeException–The specified value for the schema is not valid. You can only specify a scheme for load balancers in a VPC.
-
InvalidSecurityGroupException–One or more of the specified security groups do not exist.
-
InvalidSubnetException–The specified VPC has no associated Internet gateway.
-
OperationNotPermittedException–This operation is not allowed.
-
SubnetNotFoundException–One or more of the specified subnets do not exist.
-
TooManyAccessPointsException–The quota for the number of load balancers has been reached.
-
TooManyTagsException–The quota for the number of tags that can be assigned to a load balancer has been reached.
-
UnsupportedProtocolException–The specified protocol or signature version is not supported.
-
UnknownServiceError–The service returned an error code this client does not model.
Examples:
To create an HTTP load balancer in a VPC This example creates a load balancer with an HTTP listener in a VPC.
>>> await client.create_load_balancer(load_balancer_name='my-load-balancer', listeners=[{'Protocol': 'HTTP', 'LoadBalancerPort': 80, 'InstanceProtocol': 'HTTP', 'InstancePort': 80}], subnets=['subnet-15aaab61'], security_groups=['sg-a61988c3'])
To create an HTTP load balancer in EC2-Classic
This example creates a load balancer with an HTTP listener in EC2-Classic.
>>> await client.create_load_balancer(load_balancer_name='my-load-balancer', listeners=[{'Protocol': 'HTTP', 'LoadBalancerPort': 80, 'InstanceProtocol': 'HTTP', 'InstancePort': 80}], availability_zones=['us-west-2a'])
To create an HTTPS load balancer in a VPC
This example creates a load balancer with an HTTPS listener in a VPC.
>>> await client.create_load_balancer(load_balancer_name='my-load-balancer', listeners=[{'Protocol': 'HTTP', 'LoadBalancerPort': 80, 'InstanceProtocol': 'HTTP', 'InstancePort': 80}, {'Protocol': 'HTTPS', 'LoadBalancerPort': 443, 'InstanceProtocol': 'HTTP', 'InstancePort': 80, 'SSLCertificateId': 'arn:aws:iam::123456789012:server-certificate/my-server-cert'}], subnets=['subnet-15aaab61'], security_groups=['sg-a61988c3'])
To create an HTTPS load balancer in EC2-Classic
This example creates a load balancer with an HTTPS listener in EC2-Classic.
>>> await client.create_load_balancer(load_balancer_name='my-load-balancer', listeners=[{'Protocol': 'HTTP', 'LoadBalancerPort': 80, 'InstanceProtocol': 'HTTP', 'InstancePort': 80}, {'Protocol': 'HTTPS', 'LoadBalancerPort': 443, 'InstanceProtocol': 'HTTP', 'InstancePort': 80, 'SSLCertificateId': 'arn:aws:iam::123456789012:server-certificate/my-server-cert'}], availability_zones=['us-west-2a'])
To create an internal load balancer
This example creates an internal load balancer with an HTTP listener in a VPC.
>>> await client.create_load_balancer(load_balancer_name='my-load-balancer', listeners=[{'Protocol': 'HTTP', 'LoadBalancerPort': 80, 'InstanceProtocol': 'HTTP', 'InstancePort': 80}], subnets=['subnet-15aaab61'], security_groups=['sg-a61988c3'], scheme='internal')
Source code in docs_src/capo_elastic_load_balancing/_services/async_elastic_load_balancing.py
582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 | |