Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

createLoadBalancer

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.

Samples

import aws.sdk.kotlin.services.elasticloadbalancingv2.model.LoadBalancerSchemeEnum

fun main() { 
   //sampleStart 
   // This example creates an Internet facing load balancer and enables the Availability Zones for the
// specified subnets.
val resp = elasticLoadBalancingV2Client.createLoadBalancer {
    name = "my-load-balancer"
    subnets = listOf<String>(
        "subnet-b7d581c0",
        "subnet-8360a9e7"
    )
} 
   //sampleEnd
}
import aws.sdk.kotlin.services.elasticloadbalancingv2.model.LoadBalancerSchemeEnum

fun main() { 
   //sampleStart 
   // This example creates an internal load balancer and enables the Availability Zones for the specified
// subnets.
val resp = elasticLoadBalancingV2Client.createLoadBalancer {
    name = "my-internal-load-balancer"
    subnets = listOf<String>(
        "subnet-b7d581c0",
        "subnet-8360a9e7"
    )
    securityGroups = listOf<String>(
    )
    scheme = LoadBalancerSchemeEnum.fromValue("internal")
} 
   //sampleEnd
}