

Ada lebih banyak contoh AWS SDK yang tersedia di repo Contoh [SDK AWS Doc](https://github.com/awsdocs/aws-doc-sdk-examples). GitHub 

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

# Gunakan `CreateLoadBalancer` dengan CLI
<a name="elastic-load-balancing_example_elastic-load-balancing_CreateLoadBalancer_section"></a>

Contoh kode berikut menunjukkan cara menggunakan`CreateLoadBalancer`.

------
#### [ CLI ]

**AWS CLI**  
**Untuk membuat penyeimbang beban HTTP**  
Contoh ini membuat penyeimbang beban dengan pendengar HTTP di VPC.  
Perintah:  

```
aws elb 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}}
```
Output:  

```
{
    "DNSName": "my-load-balancer-1234567890.us-west-2.elb.amazonaws.com"
}
```
Contoh ini membuat penyeimbang beban dengan pendengar HTTP di EC2-Classic.  
Perintah:  

```
aws elb create-load-balancer --load-balancer-name {{my-load-balancer}} --listeners {{"Protocol=HTTP,LoadBalancerPort=80,InstanceProtocol=HTTP,InstancePort=80"}} --availability-zones {{us-west-2a}} {{us-west-2b}}
```
Output:  

```
{
    "DNSName": "my-load-balancer-123456789.us-west-2.elb.amazonaws.com"
}
```
**Untuk membuat penyeimbang beban HTTPS**  
Contoh ini membuat penyeimbang beban dengan pendengar HTTPS di VPC.  
Perintah:  

```
aws elb 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}}
```
Output:  

```
{
    "DNSName": "my-load-balancer-1234567890.us-west-2.elb.amazonaws.com"
}
```
Contoh ini membuat penyeimbang beban dengan pendengar HTTPS di EC2-Classic.  
Perintah:  

```
aws elb 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}} {{us-west-2b}}
```
Output:  

```
{
    "DNSName": "my-load-balancer-123456789.us-west-2.elb.amazonaws.com"
}
```
**Untuk membuat penyeimbang beban internal**  
Contoh ini membuat penyeimbang beban internal dengan pendengar HTTP di VPC.  
Perintah:  

```
aws elb create-load-balancer --load-balancer-name {{my-load-balancer}} --listeners {{"Protocol=HTTP,LoadBalancerPort=80,InstanceProtocol=HTTP,InstancePort=80"}} --scheme {{internal}} --subnets {{subnet-a85db0df}} --security-groups {{sg-a61988c3}}
```
Output:  

```
{
    "DNSName": "internal-my-load-balancer-123456789.us-west-2.elb.amazonaws.com"
}
```
+  Untuk detail API, lihat [CreateLoadBalancer](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/elb/create-load-balancer.html)di *Referensi AWS CLI Perintah*. 

------
#### [ PowerShell ]

**Alat untuk PowerShell V4**  
**Contoh 1: Contoh ini membuat penyeimbang beban dengan pendengar HTTP di VPC.**  

```
$httpListener = New-Object Amazon.ElasticLoadBalancing.Model.Listener
$httpListener.Protocol = "http"
$httpListener.LoadBalancerPort = 80
$httpListener.InstanceProtocol = "http"
$httpListener.InstancePort = 80
New-ELBLoadBalancer -LoadBalancerName my-vpc-load-balancer -SecurityGroup sg-a61988c3 -Subnet subnet-15aaab61 -Listener $httpListener

my-vpc-load-balancer-1234567890.us-west-2.elb.amazonaws.com
```
**Contoh 2: Contoh ini membuat penyeimbang beban dengan pendengar HTTP di EC2-Classic.**  

```
New-ELBLoadBalancer -LoadBalancerName my-classic-load-balancer -AvailabilityZone us-west-2a` -Listener $httpListener
```
**Output:**  

```
my-classic-load-balancer-123456789.us-west-2.elb.amazonaws.com
```
**Contoh 3: Contoh ini membuat penyeimbang beban dengan pendengar HTTPS.**  

```
$httpsListener = New-Object Amazon.ElasticLoadBalancing.Model.Listener
$httpsListener.Protocol = "https"
$httpsListener.LoadBalancerPort = 443
$httpsListener.InstanceProtocol = "http"
$httpsListener.InstancePort = 80 
$httpsListener.SSLCertificateId="arn:aws:iam::123456789012:server-certificate/my-server-cert"
New-ELBLoadBalancer -LoadBalancerName my-load-balancer -AvailabilityZone us-west-2a -Listener $httpsListener

my-load-balancer-123456789.us-west-2.elb.amazonaws.com
```
+  Untuk detail API, lihat [CreateLoadBalancer](https://docs.aws.amazon.com/powershell/v4/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V4)*. 

**Alat untuk PowerShell V5**  
**Contoh 1: Contoh ini membuat penyeimbang beban dengan pendengar HTTP di VPC.**  

```
$httpListener = New-Object Amazon.ElasticLoadBalancing.Model.Listener
$httpListener.Protocol = "http"
$httpListener.LoadBalancerPort = 80
$httpListener.InstanceProtocol = "http"
$httpListener.InstancePort = 80
New-ELBLoadBalancer -LoadBalancerName my-vpc-load-balancer -SecurityGroup sg-a61988c3 -Subnet subnet-15aaab61 -Listener $httpListener

my-vpc-load-balancer-1234567890.us-west-2.elb.amazonaws.com
```
**Contoh 2: Contoh ini membuat penyeimbang beban dengan pendengar HTTP di EC2-Classic.**  

```
New-ELBLoadBalancer -LoadBalancerName my-classic-load-balancer -AvailabilityZone us-west-2a` -Listener $httpListener
```
**Output:**  

```
my-classic-load-balancer-123456789.us-west-2.elb.amazonaws.com
```
**Contoh 3: Contoh ini membuat penyeimbang beban dengan pendengar HTTPS.**  

```
$httpsListener = New-Object Amazon.ElasticLoadBalancing.Model.Listener
$httpsListener.Protocol = "https"
$httpsListener.LoadBalancerPort = 443
$httpsListener.InstanceProtocol = "http"
$httpsListener.InstancePort = 80 
$httpsListener.SSLCertificateId="arn:aws:iam::123456789012:server-certificate/my-server-cert"
New-ELBLoadBalancer -LoadBalancerName my-load-balancer -AvailabilityZone us-west-2a -Listener $httpsListener

my-load-balancer-123456789.us-west-2.elb.amazonaws.com
```
+  Untuk detail API, lihat [CreateLoadBalancer](https://docs.aws.amazon.com/powershell/v5/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V5)*. 

------