AWS CLI version 2, the latest major version of AWS CLI, is now stable and recommended for general use. To view this page for the AWS CLI version 2, click here. For more information see the AWS CLI version 2 installation instructions and migration guide.
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.
See also: AWS API Documentation
create-load-balancer
--name <value>
[--subnets <value>]
[--subnet-mappings <value>]
[--security-groups <value>]
[--scheme <value>]
[--tags <value>]
[--type <value>]
[--ip-address-type <value>]
[--customer-owned-ipv4-pool <value>]
[--cli-input-json <value>]
[--generate-cli-skeleton <value>]
[--debug]
[--endpoint-url <value>]
[--no-verify-ssl]
[--no-paginate]
[--output <value>]
[--query <value>]
[--profile <value>]
[--region <value>]
[--version <value>]
[--color <value>]
[--no-sign-request]
[--ca-bundle <value>]
[--cli-read-timeout <value>]
[--cli-connect-timeout <value>]
--name
(string)
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
(list)
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] You can specify subnets from one or more Availability Zones.
[Gateway Load Balancers] You can specify subnets from one or more Availability Zones.
(string)
Syntax:
"string" "string" ...
--subnet-mappings
(list)
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 cannot 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 cannot specify Elastic IP addresses for your subnets.
(structure)
Information about a subnet mapping.
SubnetId -> (string)
The ID of the subnet.AllocationId -> (string)
[Network Load Balancers] The allocation ID of the Elastic IP address for an internet-facing load balancer.PrivateIPv4Address -> (string)
[Network Load Balancers] The private IPv4 address for an internal load balancer.IPv6Address -> (string)
[Network Load Balancers] The IPv6 address.
Shorthand Syntax:
SubnetId=string,AllocationId=string,PrivateIPv4Address=string,IPv6Address=string ...
JSON Syntax:
[
{
"SubnetId": "string",
"AllocationId": "string",
"PrivateIPv4Address": "string",
"IPv6Address": "string"
}
...
]
--security-groups
(list)
[Application Load Balancers and Network Load Balancers] The IDs of the security groups for the load balancer.
(string)
Syntax:
"string" "string" ...
--scheme
(string)
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 cannot specify a scheme for a Gateway Load Balancer.
Possible values:
internet-facing
internal
--tags
(list)
The tags to assign to the load balancer.
(structure)
Information about a tag.
Key -> (string)
The key of the tag.Value -> (string)
The value of the tag.
Shorthand Syntax:
Key=string,Value=string ...
JSON Syntax:
[
{
"Key": "string",
"Value": "string"
}
...
]
--type
(string)
The type of load balancer. The default is
application
.Possible values:
application
network
gateway
--ip-address-type
(string)
Note: Internal load balancers must use the
ipv4
IP address type.[Application Load Balancers] The IP address type. The possible values are
ipv4
(for only IPv4 addresses),dualstack
(for IPv4 and IPv6 addresses), anddualstack-without-public-ipv4
(for IPv6 only public addresses, with private IPv4 and IPv6 addresses).[Network Load Balancers] The IP address type. The possible values are
ipv4
(for only IPv4 addresses) anddualstack
(for IPv4 and IPv6 addresses). You can’t specifydualstack
for a load balancer with a UDP or TCP_UDP listener.[Gateway Load Balancers] The IP address type. The possible values are
ipv4
(for only IPv4 addresses) anddualstack
(for IPv4 and IPv6 addresses).Possible values:
ipv4
dualstack
dualstack-without-public-ipv4
--customer-owned-ipv4-pool
(string)
[Application Load Balancers on Outposts] The ID of the customer-owned address pool (CoIP pool).
--cli-input-json
(string)
Performs service operation based on the JSON string provided. The JSON string follows the format provided by --generate-cli-skeleton
. If other arguments are provided on the command line, the CLI values will override the JSON-provided values. It is not possible to pass arbitrary binary values using a JSON-provided value as the string will be taken literally.
--generate-cli-skeleton
(string)
Prints a JSON skeleton to standard output without sending an API request. If provided with no value or the value input
, prints a sample input JSON that can be used as an argument for --cli-input-json
. If provided with the value output
, it validates the command inputs and returns a sample output JSON for that command.
--debug
(boolean)
Turn on debug logging.
--endpoint-url
(string)
Override command's default URL with the given URL.
--no-verify-ssl
(boolean)
By default, the AWS CLI uses SSL when communicating with AWS services. For each SSL connection, the AWS CLI will verify SSL certificates. This option overrides the default behavior of verifying SSL certificates.
--no-paginate
(boolean)
Disable automatic pagination. If automatic pagination is disabled, the AWS CLI will only make one call, for the first page of results.
--output
(string)
The formatting style for command output.
--query
(string)
A JMESPath query to use in filtering the response data.
--profile
(string)
Use a specific profile from your credential file.
--region
(string)
The region to use. Overrides config/env settings.
--version
(string)
Display the version of this tool.
--color
(string)
Turn on/off color output.
--no-sign-request
(boolean)
Do not sign requests. Credentials will not be loaded if this argument is provided.
--ca-bundle
(string)
The CA certificate bundle to use when verifying SSL certificates. Overrides config/env settings.
--cli-read-timeout
(int)
The maximum socket read time in seconds. If the value is set to 0, the socket read will be blocking and not timeout. The default value is 60 seconds.
--cli-connect-timeout
(int)
The maximum socket connect time in seconds. If the value is set to 0, the socket connect will be blocking and not timeout. The default value is 60 seconds.
To use the following examples, you must have the AWS CLI installed and configured. See the Getting started guide in the AWS CLI User Guide for more information.
Unless otherwise stated, all examples have unix-like quotation rules. These examples will need to be adapted to your terminal's quoting rules. See Using quotation marks with strings in the AWS CLI User Guide .
Example 1: To create an Internet-facing load balancer
The following create-load-balancer
example creates an Internet-facing Application Load Balancer and enables the Availability Zones for the specified subnets.
aws elbv2 create-load-balancer \
--name my-load-balancer \
--subnets subnet-b7d581c0 subnet-8360a9e7
Output:
{
"LoadBalancers": [
{
"Type": "application",
"Scheme": "internet-facing",
"IpAddressType": "ipv4",
"VpcId": "vpc-3ac0fb5f",
"AvailabilityZones": [
{
"ZoneName": "us-west-2a",
"SubnetId": "subnet-8360a9e7"
},
{
"ZoneName": "us-west-2b",
"SubnetId": "subnet-b7d581c0"
}
],
"CreatedTime": "2017-08-25T21:26:12.920Z",
"CanonicalHostedZoneId": "Z2P70J7EXAMPLE",
"DNSName": "my-load-balancer-424835706.us-west-2.elb.amazonaws.com",
"SecurityGroups": [
"sg-5943793c"
],
"LoadBalancerName": "my-load-balancer",
"State": {
"Code": "provisioning"
},
"LoadBalancerArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188"
}
]
}
For more information, see Tutorial: Create an Application Load Balancer using the AWS CLI in the User Guide for Application Load Balancers.
Example 2: To create an internal load balancer
The following create-load-balancer
example creates an internal Application Load Balancer and enables the Availability Zones for the specified subnets.
aws elbv2 create-load-balancer \
--name my-internal-load-balancer \
--scheme internal \
--subnets subnet-b7d581c0 subnet-8360a9e7
Output:
{
"LoadBalancers": [
{
"Type": "application",
"Scheme": "internal",
"IpAddressType": "ipv4",
"VpcId": "vpc-3ac0fb5f",
"AvailabilityZones": [
{
"ZoneName": "us-west-2a",
"SubnetId": "subnet-8360a9e7"
},
{
"ZoneName": "us-west-2b",
"SubnetId": "subnet-b7d581c0"
}
],
"CreatedTime": "2016-03-25T21:29:48.850Z",
"CanonicalHostedZoneId": "Z2P70J7EXAMPLE",
"DNSName": "internal-my-internal-load-balancer-1529930873.us-west-2.elb.amazonaws.com",
"SecurityGroups": [
"sg-5943793c"
],
"LoadBalancerName": "my-internal-load-balancer",
"State": {
"Code": "provisioning"
},
"LoadBalancerArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-internal-load-balancer/5b49b8d4303115c2"
}
]
}
For more information, see Tutorial: Create an Application Load Balancer using the AWS CLI in the User Guide for Application Load Balancers.
Example 3: To create a Network Load Balancer
The following create-load-balancer
example creates an Internet-facing Network Load Balancer and enables the Availability Zone for the specified subnet. It uses a subnet mapping to associate the specified Elastic IP address with the network interface used by the load balancer nodes for the Availability Zone.
aws elbv2 create-load-balancer \
--name my-network-load-balancer \
--type network \
--subnet-mappings SubnetId=subnet-b7d581c0,AllocationId=eipalloc-64d5890a
Output:
{
"LoadBalancers": [
{
"Type": "network",
"Scheme": "internet-facing",
"IpAddressType": "ipv4",
"VpcId": "vpc-3ac0fb5f",
"AvailabilityZones": [
{
"LoadBalancerAddresses": [
{
"IpAddress": "35.161.207.171",
"AllocationId": "eipalloc-64d5890a"
}
],
"ZoneName": "us-west-2b",
"SubnetId": "subnet-5264e837"
}
],
"CreatedTime": "2017-10-15T22:41:25.657Z",
"CanonicalHostedZoneId": "Z2P70J7EXAMPLE",
"DNSName": "my-network-load-balancer-5d1b75f4f1cee11e.elb.us-west-2.amazonaws.com",
"LoadBalancerName": "my-network-load-balancer",
"State": {
"Code": "provisioning"
},
"LoadBalancerArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/net/my-network-load-balancer/5d1b75f4f1cee11e"
}
]
}
For more information, see Tutorial: Create a Network Load Balancer using the AWS CLI in the User Guide for Network Load Balancers.
Example 4: To create a Gateway Load Balancer
The following create-load-balancer
example creates a Gateway Load Balancer and enables the Availability Zones for the specified subnets.
aws elbv2 create-load-balancer \
--name my-gateway-load-balancer \
--type gateway \
--subnets subnet-dc83f691 subnet-a62583f9
Output:
{
"LoadBalancers": [
{
"Type": "gateway",
"VpcId": "vpc-838475fe",
"AvailabilityZones": [
{
"ZoneName": "us-east-1b",
"SubnetId": "subnet-a62583f9"
},
{
"ZoneName": "us-east-1a",
"SubnetId": "subnet-dc83f691"
}
],
"CreatedTime": "2021-07-14T19:33:43.324000+00:00",
"LoadBalancerName": "my-gateway-load-balancer",
"State": {
"Code": "provisioning"
},
"LoadBalancerArn": "arn:aws:elasticloadbalancing:us-east-1:850631746142:loadbalancer/gwy/my-gateway-load-balancer/dfbb5a7d32cdee79"
}
]
}
For more information, see Getting started with Gateway Load Balancers using the AWS CLI in the User Guide for Gateway Load Balancers.
LoadBalancers -> (list)
Information about the load balancer.
(structure)
Information about a load balancer.
LoadBalancerArn -> (string)
The Amazon Resource Name (ARN) of the load balancer.DNSName -> (string)
The public DNS name of the load balancer.CanonicalHostedZoneId -> (string)
The ID of the Amazon Route 53 hosted zone associated with the load balancer.CreatedTime -> (timestamp)
The date and time the load balancer was created.LoadBalancerName -> (string)
The name of the load balancer.Scheme -> (string)
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.
VpcId -> (string)
The ID of the VPC for the load balancer.State -> (structure)
The state of the load balancer.
Code -> (string)
The state code. The initial state of the load balancer isprovisioning
. After the load balancer is fully set up and ready to route traffic, its state isactive
. If load balancer is routing traffic but does not have the resources it needs to scale, its state is``active_impaired`` . If the load balancer could not be set up, its state isfailed
.Reason -> (string)
A description of the state.Type -> (string)
The type of load balancer.AvailabilityZones -> (list)
The subnets for the load balancer.
(structure)
Information about an Availability Zone.
ZoneName -> (string)
The name of the Availability Zone.SubnetId -> (string)
The ID of the subnet. You can specify one subnet per Availability Zone.OutpostId -> (string)
[Application Load Balancers on Outposts] The ID of the Outpost.LoadBalancerAddresses -> (list)
[Network Load Balancers] If you need static IP addresses for your load balancer, you can specify one Elastic IP address per Availability Zone when you create an internal-facing load balancer. For internal load balancers, you can specify a private IP address from the IPv4 range of the subnet.
(structure)
Information about a static IP address for a load balancer.
IpAddress -> (string)
The static IP address.AllocationId -> (string)
[Network Load Balancers] The allocation ID of the Elastic IP address for an internal-facing load balancer.PrivateIPv4Address -> (string)
[Network Load Balancers] The private IPv4 address for an internal load balancer.IPv6Address -> (string)
[Network Load Balancers] The IPv6 address.SecurityGroups -> (list)
The IDs of the security groups for the load balancer.
(string)
IpAddressType -> (string)
[Application Load Balancers] The type of IP addresses used for public or private connections by the subnets attached to your load balancer. The possible values are
ipv4
(for only IPv4 addresses),dualstack
(for IPv4 and IPv6 addresses), anddualstack-without-public-ipv4
(for IPv6 only public addresses, with private IPv4 and IPv6 addresses).[Network Load Balancers and Gateway Load Balancers] The type of IP addresses used for public or private connections by the subnets attached to your load balancer. The possible values are
ipv4
(for only IPv4 addresses) anddualstack
(for IPv4 and IPv6 addresses).CustomerOwnedIpv4Pool -> (string)
[Application Load Balancers on Outposts] The ID of the customer-owned address pool.EnforceSecurityGroupInboundRulesOnPrivateLinkTraffic -> (string)
Indicates whether to evaluate inbound security group rules for traffic sent to a Network Load Balancer through Amazon Web Services PrivateLink.