create_load_balancer
¶
create_load_balancer(
*,
config_overrides: Optional[ElasticLoadBalancingv2ClientConfig] = None,
name: Optional[LoadBalancerName] = None,
subnets: Optional[Subnets] = None,
subnet_mappings: Optional[SubnetMappings] = None,
security_groups: Optional[SecurityGroups] = None,
scheme: Optional[LoadBalancerSchemeEnum] = None,
tags: Optional[TagList] = None,
type: Optional[LoadBalancerTypeEnum] = None,
ip_address_type: Optional[IpAddressType] = None,
customer_owned_ipv4_pool: Optional[CustomerOwnedIpv4Pool] = None,
enable_prefix_for_ipv6_source_nat: Optional[
EnablePrefixForIpv6SourceNatEnum
] = None,
ipam_pools: Optional[IpamPools] = None,
) -> CreateLoadBalancerOutput
Creates an Application Load Balancer, Network Load Balancer, or Gateway Load Balancer.
For more information, see the following:
This operation is idempotent, which means that it completes at most one time. If you attempt to create multiple load balancers with the same settings, each call succeeds.
Parameters:
-
name(Optional[LoadBalancerName], default:None) –The name of the load balancer.
This name must be unique per region per account, can have a maximum of 32 characters, must contain only alphanumeric characters or hyphens, must not begin or end with a hyphen, and must not begin with "internal-".
-
subnets(Optional[Subnets], default:None) –The IDs of the subnets. You can specify only one subnet per Availability Zone. You must specify either subnets or subnet mappings, but not both. To specify an Elastic IP address, specify subnet mappings instead of subnets.
[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 and Gateway Load Balancers] You can specify subnets from one or more Availability Zones.
-
subnet_mappings(Optional[SubnetMappings], default:None) –The IDs of the subnets. You can specify only one subnet per Availability Zone. You must specify either subnets or subnet mappings, but not both.
[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. You can't specify Elastic IP addresses for your subnets.
-
security_groups(Optional[SecurityGroups], default:None) –[Application Load Balancers and Network Load Balancers] The IDs of the security groups for the load balancer.
-
scheme(Optional[LoadBalancerSchemeEnum], default:None) –The nodes of an Internet-facing load balancer have public IP addresses. The DNS name of an Internet-facing load balancer is publicly resolvable to the public IP addresses of the nodes. Therefore, Internet-facing load balancers can route requests from clients over the internet.
The nodes of an internal load balancer have only private IP addresses. The DNS name of an internal load balancer is publicly resolvable to the private IP addresses of the nodes. Therefore, internal load balancers can route requests only from clients with access to the VPC for the load balancer.
The default is an Internet-facing load balancer.
You can't specify a scheme for a Gateway Load Balancer.
-
tags(Optional[TagList], default:None) –The tags to assign to the load balancer.
-
type(Optional[LoadBalancerTypeEnum], default:None) –The type of load balancer. The default is
application. -
ip_address_type(Optional[IpAddressType], default:None) –The IP address type. Internal load balancers must use
ipv4.[Application Load Balancers] The possible values are
ipv4(IPv4 addresses),dualstack(IPv4 and IPv6 addresses), anddualstack-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) anddualstack(IPv4 and IPv6 addresses). -
customer_owned_ipv4_pool(Optional[CustomerOwnedIpv4Pool], default:None) –[Application Load Balancers on Outposts] The ID of the customer-owned address pool (CoIP pool).
-
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 isoff. -
ipam_pools(Optional[IpamPools], default:None) –[Application Load Balancers] The IPAM pools to use with the load balancer.
Raises:
-
AllocationIdNotFoundException–The specified allocation ID does not exist.
-
AvailabilityZoneNotSupportedException–The specified Availability Zone is not supported.
-
DuplicateLoadBalancerNameException–A load balancer with the specified name already exists.
-
DuplicateTagKeysException–A tag key was specified more than once.
-
InvalidConfigurationRequestException–The requested configuration is not valid.
-
InvalidSchemeException–The requested scheme is not valid.
-
InvalidSecurityGroupException–The specified security group does not exist.
-
InvalidSubnetException–The specified subnet is out of available addresses.
-
OperationNotPermittedException–This operation is not allowed.
-
ResourceInUseException–A specified resource is in use.
-
SubnetNotFoundException–The specified subnet does not exist.
-
TooManyLoadBalancersException–You've reached the limit on the number of load balancers for your Amazon Web Services account.
-
TooManyTagsException–You've reached the limit on the number of tags for this resource.
-
UnknownServiceError–The service returned an error code this client does not model.
Examples:
To create an Internet-facing load balancer This example creates an Internet-facing load balancer and enables the Availability Zones for the specified subnets.
>>> client.create_load_balancer(name='my-load-balancer', subnets=['subnet-b7d581c0', 'subnet-8360a9e7'])
To create an internal load balancer
This example creates an internal load balancer and enables the Availability Zones for the specified subnets.
>>> client.create_load_balancer(name='my-internal-load-balancer', subnets=['subnet-b7d581c0', 'subnet-8360a9e7'], security_groups=[], scheme='internal')
Source code in docs_src/capo_elastic_load_balancing_v2/_services/elastic_load_balancingv2.py
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 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 | |