Ada lebih banyak contoh AWS SDK yang tersedia di repo Contoh SDK AWS Doc
Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.
Elastic Load Balancing - Contoh versi 2 menggunakan AWS CLI
Contoh kode berikut menunjukkan cara melakukan tindakan dan mengimplementasikan skenario umum dengan menggunakan AWS Command Line Interface with Elastic Load Balancing - Versi 2.
Tindakan merupakan kutipan kode dari program yang lebih besar dan harus dijalankan dalam konteks. Sementara tindakan menunjukkan cara memanggil fungsi layanan individual, Anda dapat melihat tindakan dalam konteks dalam skenario terkait.
Setiap contoh menyertakan tautan ke kode sumber lengkap, di mana Anda dapat menemukan instruksi tentang cara mengatur dan menjalankan kode dalam konteks.
Topik
Tindakan
Contoh kode berikut menunjukkan cara menggunakanadd-listener-certificates.
- AWS CLI
-
Untuk menambahkan sertifikat ke pendengar yang aman
Contoh ini menambahkan sertifikat yang ditentukan ke pendengar aman yang ditentukan.
Perintah:
aws elbv2 add-listener-certificates --listener-arnarn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2--certificatesCertificateArn=arn:aws:acm:us-west-2:123456789012:certificate/5cc54884-f4a3-4072-80be-05b9ba72f705Output:
{ "Certificates": [ { "CertificateArn": "arn:aws:acm:us-west-2:123456789012:certificate/5cc54884-f4a3-4072-80be-05b9ba72f705", "IsDefault": false } ] }-
Untuk detail API, lihat AddListenerCertificates
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanadd-tags.
- AWS CLI
-
Untuk menambahkan tag ke penyeimbang beban
add-tagsContoh berikut menambahkanprojectdandepartmenttag ke penyeimbang beban tertentu.aws elbv2 add-tags \ --resource-arnsarn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188\ --tags"Key=project,Value=lima""Key=department,Value=digital-media"-
Untuk detail API, lihat AddTags
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakancreate-listener.
- AWS CLI
-
Contoh 1: Untuk membuat pendengar HTTP
create-listenerContoh berikut membuat listener HTTP untuk Application Load Balancer tertentu yang meneruskan permintaan ke grup target yang ditentukan.aws elbv2 create-listener \ --load-balancer-arnarn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188\ --protocolHTTP\ --port80\ --default-actionsType=forward,TargetGroupArn=arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067Untuk informasi selengkapnya, lihat Tutorial: Membuat Application Load Balancer menggunakan AWS CLI di Panduan Pengguna untuk Application Load Balancers.
Contoh 2: Untuk membuat pendengar HTTPS
create-listenerContoh berikut membuat listener HTTPS untuk Application Load Balancer tertentu yang meneruskan permintaan ke grup target yang ditentukan. Anda harus menentukan sertifikat SSL untuk pendengar HTTPS. Anda dapat membuat dan mengelola sertifikat menggunakan AWS Certificate Manager (ACM). Atau, Anda dapat membuat sertifikat menggunakan SSL/TLS alat, mendapatkan sertifikat yang ditandatangani oleh otoritas sertifikat (CA), dan mengunggah sertifikat ke AWS Identity and Access Management (IAM).aws elbv2 create-listener \ --load-balancer-arnarn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188\ --protocolHTTPS\ --port443\ --certificatesCertificateArn=arn:aws:acm:us-west-2:123456789012:certificate/3dcb0a41-bd72-4774-9ad9-756919c40557\ --ssl-policyELBSecurityPolicy-2016-08\ --default-actionsType=forward,TargetGroupArn=arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067Untuk informasi selengkapnya, lihat Menambahkan pendengar HTTPS di Panduan Pengguna untuk Penyeimbang Beban Aplikasi.
Contoh 3: Untuk membuat pendengar TCP
create-listenerContoh berikut membuat pendengar TCP untuk Network Load Balancer tertentu yang meneruskan permintaan ke grup target yang ditentukan.aws elbv2 create-listener \ --load-balancer-arnarn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/net/my-network-load-balancer/5d1b75f4f1cee11e\ --protocolTCP\ --port80\ --default-actionsType=forward,TargetGroupArn=arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-tcp-targets/b6bba954d1361c78Untuk informasi selengkapnya, lihat Tutorial: Membuat Network Load Balancer menggunakan AWS CLI di Panduan Pengguna untuk Network Load Balancers.
Contoh 4: Untuk membuat pendengar TLS
create-listenerContoh berikut membuat pendengar TLS untuk Network Load Balancer tertentu yang meneruskan permintaan ke grup target yang ditentukan. Anda harus menentukan sertifikat SSL untuk pendengar TLS.aws elbv2 create-listener \ --load-balancer-arnarn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188\ --protocolTLS\ --port443\ --certificatesCertificateArn=arn:aws:acm:us-west-2:123456789012:certificate/3dcb0a41-bd72-4774-9ad9-756919c40557\ --ssl-policyELBSecurityPolicy-2016-08\ --default-actionsType=forward,TargetGroupArn=arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067Untuk informasi selengkapnya, lihat pendengar TLS untuk Network Load Balancer Anda di Panduan Pengguna untuk Network Load Balancers.
Contoh 5: Untuk membuat pendengar UDP
create-listenerContoh berikut membuat pendengar UDP untuk Network Load Balancer tertentu yang meneruskan permintaan ke grup target yang ditentukan.aws elbv2 create-listener \ --load-balancer-arnarn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/net/my-network-load-balancer/5d1b75f4f1cee11e\ --protocolUDP\ --port53\ --default-actionsType=forward,TargetGroupArn=arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-tcp-targets/b6bba954d1361c78Untuk informasi selengkapnya, lihat Tutorial: Membuat Network Load Balancer menggunakan AWS CLI di Panduan Pengguna untuk Network Load Balancers.
Contoh 6: Untuk membuat pendengar untuk gateway dan penerusan yang ditentukan
create-listenerContoh berikut membuat listener untuk Load Balancer Gateway tertentu yang meneruskan permintaan ke grup target yang ditentukan.aws elbv2 create-listener \ --load-balancer-arnarn:aws:elasticloadbalancing:us-east-1:850631746142:loadbalancer/gwy/my-gateway-load-balancer/e0f9b3d5c7f7d3d6\ --default-actionsType=forward,TargetGroupArn=arn:aws:elasticloadbalancing:us-east-1:850631746142:targetgroup/my-glb-targets/007ca469fae3bb1615Output:
{ "Listeners": [ { "ListenerArn": "arn:aws:elasticloadbalancing:us-east-1:850631746142:listener/gwy/my-agw-lb-example2/e0f9b3d5c7f7d3d6/afc127db15f925de", "LoadBalancerArn": "arn:aws:elasticloadbalancing:us-east-1:850631746142:loadbalancer/gwy/my-agw-lb-example2/e0f9b3d5c7f7d3d6", "DefaultActions": [ { "Type": "forward", "TargetGroupArn": "arn:aws:elasticloadbalancing:us-east-1:850631746142:targetgroup/test-tg-agw-2/007ca469fae3bb1615", "ForwardConfig": { "TargetGroups": [ { "TargetGroupArn": "arn:aws:elasticloadbalancing:us-east-1:850631746142:targetgroup/test-tg-agw-2/007ca469fae3bb1615" } ] } } ] } ] }Untuk informasi selengkapnya, lihat Memulai Gateway Load Balancers menggunakan AWS CLI di Panduan Pengguna untuk Penyeimbang Beban Gateway.
-
Untuk detail API, lihat CreateListener
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakancreate-load-balancer.
- AWS CLI
-
Contoh 1: Untuk membuat penyeimbang beban yang menghadap ke Internet
create-load-balancerContoh berikut membuat Application Load Balancer yang menghadap ke Internet dan mengaktifkan Availability Zones untuk subnet yang ditentukan.aws elbv2 create-load-balancer \ --namemy-load-balancer\ --subnetssubnet-b7d581c0subnet-8360a9e7Output:
{ "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" } ] }Untuk informasi selengkapnya, lihat Tutorial: Membuat Application Load Balancer menggunakan AWS CLI di Panduan Pengguna untuk Application Load Balancers.
Contoh 2: Untuk membuat penyeimbang beban internal
create-load-balancerContoh berikut membuat Application Load Balancer internal dan mengaktifkan Availability Zones untuk subnet yang ditentukan.aws elbv2 create-load-balancer \ --namemy-internal-load-balancer\ --schemeinternal\ --subnetssubnet-b7d581c0subnet-8360a9e7Output:
{ "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" } ] }Untuk informasi selengkapnya, lihat Tutorial: Membuat Application Load Balancer menggunakan AWS CLI di Panduan Pengguna untuk Application Load Balancers.
Contoh 3: Untuk membuat Network Load Balancer
create-load-balancerContoh berikut membuat Network Load Balancer yang menghadap Internet dan mengaktifkan Availability Zone untuk subnet yang ditentukan. Ini menggunakan pemetaan subnet untuk mengaitkan alamat IP Elastis yang ditentukan dengan antarmuka jaringan yang digunakan oleh node penyeimbang beban untuk Availability Zone.aws elbv2 create-load-balancer \ --namemy-network-load-balancer\ --typenetwork\ --subnet-mappingsSubnetId=subnet-b7d581c0,AllocationId=eipalloc-64d5890aOutput:
{ "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" } ] }Untuk informasi selengkapnya, lihat Tutorial: Membuat Network Load Balancer menggunakan AWS CLI di Panduan Pengguna untuk Network Load Balancers.
Contoh 4: Untuk membuat Load Balancer Gateway
create-load-balancerContoh berikut membuat Load Balancer Gateway dan mengaktifkan Availability Zones untuk subnet yang ditentukan.aws elbv2 create-load-balancer \ --namemy-gateway-load-balancer\ --typegateway\ --subnetssubnet-dc83f691subnet-a62583f9Output:
{ "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" } ] }Untuk informasi selengkapnya, lihat Memulai Gateway Load Balancers menggunakan AWS CLI di Panduan Pengguna untuk Penyeimbang Beban Gateway.
-
Untuk detail API, lihat CreateLoadBalancer
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakancreate-rule.
- AWS CLI
-
Contoh 1: Untuk membuat aturan menggunakan kondisi jalur dan tindakan maju
create-ruleContoh berikut membuat aturan yang meneruskan permintaan ke grup target yang ditentukan jika URL berisi pola yang ditentukan.aws elbv2 create-rule \ --listener-arnarn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2\ --priority5\ --conditionsfile://conditions-pattern.json--actionsType=forward,TargetGroupArn=arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067Isi dari
conditions-pattern.json:[ { "Field": "path-pattern", "PathPatternConfig": { "Values": ["/images/*"] } } ]Contoh 2: Untuk membuat aturan menggunakan kondisi host dan respons tetap
create-ruleContoh berikut membuat aturan yang memberikan respons tetap jika nama host di header host cocok dengan nama host yang ditentukan.aws elbv2 create-rule \ --listener-arnarn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2\ --priority10\ --conditionsfile://conditions-host.json\ --actionsfile://actions-fixed-response.jsonIsi dari
conditions-host.json[ { "Field": "host-header", "HostHeaderConfig": { "Values": ["*.example.com"] } } ]Isi dari
actions-fixed-response.json[ { "Type": "fixed-response", "FixedResponseConfig": { "MessageBody": "Hello world", "StatusCode": "200", "ContentType": "text/plain" } } ]Contoh 3: Untuk membuat aturan menggunakan kondisi alamat IP sumber, tindakan otentikasi, dan tindakan maju
create-ruleContoh berikut membuat aturan yang mengautentikasi pengguna jika alamat IP sumber cocok dengan alamat IP yang ditentukan, dan meneruskan permintaan ke grup target yang ditentukan jika otentikasi berhasil.aws elbv2 create-rule \ --listener-arnarn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2\ --priority20\ --conditionsfile://conditions-source-ip.json\ --actionsfile://actions-authenticate.jsonIsi dari
conditions-source-ip.json[ { "Field": "source-ip", "SourceIpConfig": { "Values": ["192.0.2.0/24", "198.51.100.10/32"] } } ]Isi dari
actions-authenticate.json[ { "Type": "authenticate-oidc", "AuthenticateOidcConfig": { "Issuer": "https://idp-issuer.com", "AuthorizationEndpoint": "https://authorization-endpoint.com", "TokenEndpoint": "https://token-endpoint.com", "UserInfoEndpoint": "https://user-info-endpoint.com", "ClientId": "abcdefghijklmnopqrstuvwxyz123456789", "ClientSecret": "123456789012345678901234567890", "SessionCookieName": "my-cookie", "SessionTimeout": 3600, "Scope": "email", "AuthenticationRequestExtraParams": { "display": "page", "prompt": "login" }, "OnUnauthenticatedRequest": "deny" }, "Order": 1 }, { "Type": "forward", "TargetGroupArn": "arn:aws:elasticloadbalancing:us-east-1:880185128111:targetgroup/cli-test/642a97ecb0e0f26b", "Order": 2 } ]-
Untuk detail API, lihat CreateRule
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakancreate-target-group.
- AWS CLI
-
Contoh 1: Untuk membuat grup target untuk Application Load Balancer
create-target-groupContoh berikut membuat grup target untuk Application Load Balancer tempat Anda mendaftarkan target berdasarkan ID instance (tipe targetnya adalahinstance). Grup target ini menggunakan protokol HTTP, port 80, dan pengaturan pemeriksaan kesehatan default untuk grup target HTTP.aws elbv2 create-target-group \ --namemy-targets\ --protocolHTTP\ --port80\ --target-typeinstance\ --vpc-idvpc-3ac0fb5fOutput:
{ "TargetGroups": [ { "TargetGroupArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067", "TargetGroupName": "my-targets", "Protocol": "HTTP", "Port": 80, "VpcId": "vpc-3ac0fb5f", "HealthCheckProtocol": "HTTP", "HealthCheckPort": "traffic-port", "HealthCheckEnabled": true, "HealthCheckIntervalSeconds": 30, "HealthCheckTimeoutSeconds": 5, "HealthyThresholdCount": 5, "UnhealthyThresholdCount": 2, "HealthCheckPath": "/", "Matcher": { "HttpCode": "200" }, "TargetType": "instance", "ProtocolVersion": "HTTP1", "IpAddressType": "ipv4" } ] }Untuk informasi selengkapnya, lihat Membuat grup target di Panduan Pengguna untuk Penyeimbang Beban Aplikasi.
Contoh 2: Untuk membuat grup target untuk merutekan lalu lintas dari Application Load Balancer ke fungsi Lambda
create-target-groupContoh berikut membuat grup target untuk Application Load Balancer di mana targetnya adalah fungsi Lambda (tipe targetnya adalah).lambdaPemeriksaan kesehatan dinonaktifkan untuk grup target ini secara default.aws elbv2 create-target-group \ --namemy-lambda-target\ --target-typelambdaOutput:
{ "TargetGroups": [ { "TargetGroupArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-lambda-target/a3003e085dbb8ddc", "TargetGroupName": "my-lambda-target", "HealthCheckEnabled": false, "HealthCheckIntervalSeconds": 35, "HealthCheckTimeoutSeconds": 30, "HealthyThresholdCount": 5, "UnhealthyThresholdCount": 2, "HealthCheckPath": "/", "Matcher": { "HttpCode": "200" }, "TargetType": "lambda", "IpAddressType": "ipv4" } ] }Untuk informasi selengkapnya, lihat: Fungsi Lambda sebagai target di Panduan pengguna untuk Application Load Balancers.
Contoh 3: Untuk membuat grup target untuk Network Load Balancer
create-target-groupContoh berikut membuat grup target untuk Network Load Balancer tempat Anda mendaftarkan target berdasarkan alamat IP (tipe targetnya adalahip). Grup target ini menggunakan protokol TCP, port 80, dan pengaturan pemeriksaan kesehatan default untuk grup target TCP.aws elbv2 create-target-group \ --namemy-ip-targets\ --protocolTCP\ --port80\ --target-typeip\ --vpc-idvpc-3ac0fb5fOutput:
{ "TargetGroups": [ { "TargetGroupArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-ip-targets/b6bba954d1361c78", "TargetGroupName": "my-ip-targets", "Protocol": "TCP", "Port": 80, "VpcId": "vpc-3ac0fb5f", "HealthCheckEnabled": true, "HealthCheckProtocol": "TCP", "HealthCheckPort": "traffic-port", "HealthCheckIntervalSeconds": 30, "HealthCheckTimeoutSeconds": 10, "HealthyThresholdCount": 5, "UnhealthyThresholdCount": 2, "TargetType": "ip", "IpAddressType": "ipv4" } ] }Untuk informasi selengkapnya, lihat Membuat grup target di Panduan Pengguna untuk Network Load Balancers.
Contoh 4: Untuk membuat grup target untuk merutekan lalu lintas dari Network Load Balancer ke Application Load Balancer
create-target-groupContoh berikut membuat grup target untuk Network Load Balancer tempat Anda mendaftarkan Application Load Balancer sebagai target (tipe targetnya adalah).albaws elbv2 create-target-group --name my-alb-target --protocol TCP --port 80 --target-type alb --vpc-id vpc-id vpc-3ac0fb5f
Output:
{ "TargetGroups": [ { "TargetGroupArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-alb-target/a3003e085dbb8ddc", "TargetGroupName": "my-alb-target", "Protocol": "TCP", "Port": 80, "VpcId": "vpc-838475fe", "HealthCheckProtocol": "HTTP", "HealthCheckPort": "traffic-port", "HealthCheckEnabled": true, "HealthCheckIntervalSeconds": 30, "HealthCheckTimeoutSeconds": 6, "HealthyThresholdCount": 5, "UnhealthyThresholdCount": 2, "HealthCheckPath": "/", "Matcher": { "HttpCode": "200-399" }, "TargetType": "alb", "IpAddressType": "ipv4" } ] }Untuk informasi selengkapnya, lihat Membuat grup target dengan Application Load Balancer sebagai target dalam Panduan Pengguna untuk Network Load Balancers.
Contoh 5: Untuk membuat grup target untuk Load Balancer Gateway
create-target-groupContoh berikut membuat grup target untuk Load Balancer Gateway di mana target adalah sebuah instance, dan protokol grup target adalah.GENEVEaws elbv2 create-target-group \ --namemy-glb-targetgroup\ --protocolGENEVE\ --port6081\ --target-typeinstance\ --vpc-idvpc-838475feOutput:
{ "TargetGroups": [ { "TargetGroupArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-glb-targetgroup/00c3d57eacd6f40b6f", "TargetGroupName": "my-glb-targetgroup", "Protocol": "GENEVE", "Port": 6081, "VpcId": "vpc-838475fe", "HealthCheckProtocol": "TCP", "HealthCheckPort": "80", "HealthCheckEnabled": true, "HealthCheckIntervalSeconds": 10, "HealthCheckTimeoutSeconds": 5, "HealthyThresholdCount": 5, "UnhealthyThresholdCount": 2, "TargetType": "instance" } ] }Untuk informasi selengkapnya, lihat Membuat grup target < https://docs.aws.amazon.com/elasticloadbalancing/ latest/gateway/create -target-group.html>`__ di Panduan Pengguna Load Balancer Gateway.
-
Untuk detail API, lihat CreateTargetGroup
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakandelete-listener.
- AWS CLI
-
Untuk menghapus pendengar
delete-listenerContoh berikut menghapus pendengar yang ditentukan.aws elbv2 delete-listener \ --listener-arnarn:aws:elasticloadbalancing:ua-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2-
Untuk detail API, lihat DeleteListener
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakandelete-load-balancer.
- AWS CLI
-
Untuk menghapus penyeimbang beban
delete-load-balancerContoh berikut menghapus penyeimbang beban yang ditentukan.aws elbv2 delete-load-balancer \ --load-balancer-arnarn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188-
Untuk detail API, lihat DeleteLoadBalancer
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakandelete-rule.
- AWS CLI
-
Untuk menghapus aturan
delete-ruleContoh berikut menghapus aturan yang ditentukan.aws elbv2 delete-rule \ --rule-arnarn:aws:elasticloadbalancing:us-west-2:123456789012:listener-rule/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2/1291d13826f405c3-
Untuk detail API, lihat DeleteRule
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakandelete-target-group.
- AWS CLI
-
Untuk menghapus grup target
delete-target-groupContoh berikut menghapus kelompok target yang ditentukan.aws elbv2 delete-target-group \ --target-group-arnarn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067Perintah ini tidak menghasilkan output.
Untuk informasi selengkapnya, lihat Menghapus penyeimbang beban di Panduan Application Load Balancer.
-
Untuk detail API, lihat DeleteTargetGroup
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanderegister-targets.
- AWS CLI
-
Contoh 1: Untuk membatalkan pendaftaran target dari grup target
deregister-targetsContoh berikut menghapus contoh tertentu dari kelompok target yang ditentukan.aws elbv2 deregister-targets \ --target-group-arnarn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067\ --targetsId=i-1234567890abcdef0Contoh 2: Untuk membatalkan pendaftaran target yang terdaftar menggunakan penggantian port
deregister-targetsContoh berikut menghapus instance dari grup target yang terdaftar menggunakan port overrides.aws elbv2 deregister-targets \ --target-group-arnarn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-internal-targets/3bb63f11dfb0faf9\ --targetsId=i-1234567890abcdef0,Port=80Id=i-1234567890abcdef0,Port=766-
Untuk detail API, lihat DeregisterTargets
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakandescribe-account-limits.
- AWS CLI
-
Untuk menjelaskan batas Elastic Load Balancing Anda
describe-account-limitsContoh berikut menampilkan batas Elastic Load Balancing untuk AWS akun Anda di Wilayah saat ini.aws elbv2 describe-account-limitsOutput:
{ "Limits": [ { "Name": "target-groups", "Max": "3000" }, { "Name": "targets-per-application-load-balancer", "Max": "1000" }, { "Name": "listeners-per-application-load-balancer", "Max": "50" }, { "Name": "rules-per-application-load-balancer", "Max": "100" }, { "Name": "network-load-balancers", "Max": "50" }, { "Name": "targets-per-network-load-balancer", "Max": "3000" }, { "Name": "targets-per-availability-zone-per-network-load-balancer", "Max": "500" }, { "Name": "listeners-per-network-load-balancer", "Max": "50" }, { "Name": "condition-values-per-alb-rule", "Max": "5" }, { "Name": "condition-wildcards-per-alb-rule", "Max": "5" }, { "Name": "target-groups-per-application-load-balancer", "Max": "100" }, { "Name": "target-groups-per-action-on-application-load-balancer", "Max": "5" }, { "Name": "target-groups-per-action-on-network-load-balancer", "Max": "1" }, { "Name": "certificates-per-application-load-balancer", "Max": "25" }, { "Name": "certificates-per-network-load-balancer", "Max": "25" }, { "Name": "targets-per-target-group", "Max": "1000" }, { "Name": "target-id-registrations-per-application-load-balancer", "Max": "1000" }, { "Name": "network-load-balancer-enis-per-vpc", "Max": "1200" }, { "Name": "application-load-balancers", "Max": "50" }, { "Name": "gateway-load-balancers", "Max": "100" }, { "Name": "gateway-load-balancers-per-vpc", "Max": "100" }, { "Name": "geneve-target-groups", "Max": "100" }, { "Name": "targets-per-availability-zone-per-gateway-load-balancer", "Max": "300" } ] }Untuk informasi lebih lanjut, lihat Kuota di Referensi AWS Umum.
-
Untuk detail API, lihat DescribeAccountLimits
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakandescribe-listener-certificates.
- AWS CLI
-
Untuk mendeskripsikan sertifikat untuk pendengar yang aman
Contoh ini menjelaskan sertifikat untuk pendengar aman yang ditentukan.
Perintah:
aws elbv2 describe-listener-certificates --listener-arnarn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2Output:
{ "Certificates": [ { "CertificateArn": "arn:aws:acm:us-west-2:123456789012:certificate/5cc54884-f4a3-4072-80be-05b9ba72f705", "IsDefault": false }, { "CertificateArn": "arn:aws:acm:us-west-2:123456789012:certificate/3dcb0a41-bd72-4774-9ad9-756919c40557", "IsDefault": false }, { "CertificateArn": "arn:aws:acm:us-west-2:123456789012:certificate/fe59da96-6f58-4a22-8eed-6d0d50477e1d", "IsDefault": true } ] }-
Untuk detail API, lihat DescribeListenerCertificates
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakandescribe-listeners.
- AWS CLI
-
Untuk menggambarkan pendengar
Contoh ini menjelaskan pendengar yang ditentukan.
Perintah:
aws elbv2 describe-listeners --listener-arnsarn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2Output:
{ "Listeners": [ { "Port": 80, "Protocol": "HTTP", "DefaultActions": [ { "TargetGroupArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067", "Type": "forward" } ], "LoadBalancerArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188", "ListenerArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2" } ] }Untuk menggambarkan pendengar untuk penyeimbang beban
Contoh ini menjelaskan pendengar untuk penyeimbang beban yang ditentukan.
Perintah:
aws elbv2 describe-listeners --load-balancer-arnarn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188Output:
{ "Listeners": [ { "Port": 443, "Protocol": "HTTPS", "DefaultActions": [ { "TargetGroupArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067", "Type": "forward" } ], "SslPolicy": "ELBSecurityPolicy-2015-05", "Certificates": [ { "CertificateArn": "arn:aws:iam::123456789012:server-certificate/my-server-cert" } ], "LoadBalancerArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188", "ListenerArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/0467ef3c8400ae65" }, { "Port": 80, "Protocol": "HTTP", "DefaultActions": [ { "TargetGroupArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067", "Type": "forward" } ], "LoadBalancerArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188", "ListenerArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2" } ] }-
Untuk detail API, lihat DescribeListeners
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakandescribe-load-balancer-attributes.
- AWS CLI
-
Untuk menggambarkan atribut penyeimbang beban
describe-load-balancer-attributesContoh berikut menampilkan atribut penyeimbang beban tertentu.aws elbv2 describe-load-balancer-attributes \ --load-balancer-arnarn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188Contoh output berikut menunjukkan atribut untuk Application Load Balancer.
{ "Attributes": [ { "Value": "false", "Key": "access_logs.s3.enabled" }, { "Value": "", "Key": "access_logs.s3.bucket" }, { "Value": "", "Key": "access_logs.s3.prefix" }, { "Value": "60", "Key": "idle_timeout.timeout_seconds" }, { "Value": "false", "Key": "deletion_protection.enabled" }, { "Value": "true", "Key": "routing.http2.enabled" } ] }Contoh output berikut mencakup atribut untuk Network Load Balancer.
{ "Attributes": [ { "Value": "false", "Key": "access_logs.s3.enabled" }, { "Value": "", "Key": "access_logs.s3.bucket" }, { "Value": "", "Key": "access_logs.s3.prefix" }, { "Value": "false", "Key": "deletion_protection.enabled" }, { "Value": "false", "Key": "load_balancing.cross_zone.enabled" } ] }-
Untuk detail API, lihat DescribeLoadBalancerAttributes
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakandescribe-load-balancers.
- AWS CLI
-
Untuk menggambarkan penyeimbang beban
Contoh ini menjelaskan penyeimbang beban yang ditentukan.
Perintah:
aws elbv2 describe-load-balancers --load-balancer-arnsarn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188Output:
{ "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": "2016-03-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": "active" }, "LoadBalancerArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188" } ] }Untuk menggambarkan semua penyeimbang beban
Contoh ini menjelaskan semua penyeimbang beban Anda.
Perintah:
aws elbv2 describe-load-balancers-
Untuk detail API, lihat DescribeLoadBalancers
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakandescribe-rules.
- AWS CLI
-
Contoh 1: Untuk mendeskripsikan aturan
describe-rulesContoh berikut menampilkan rincian untuk aturan yang ditentukan.aws elbv2 describe-rules \ --rule-arnsarn:aws:elasticloadbalancing:us-west-2:123456789012:listener-rule/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2/9683b2d02a6cabeeContoh 2: Untuk menjelaskan aturan untuk pendengar
describe-rulesContoh berikut menampilkan rincian untuk aturan untuk listener tertentu. Outputnya mencakup aturan default dan aturan lain yang telah Anda tambahkan.aws elbv2 describe-rules \ --listener-arnarn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2-
Untuk detail API, lihat DescribeRules
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakandescribe-ssl-policies.
- AWS CLI
-
Contoh 1: Untuk membuat daftar kebijakan yang digunakan untuk negosiasi SSL berdasarkan jenis penyeimbang beban
describe-ssl-policiesContoh berikut menampilkan nama-nama kebijakan yang dapat Anda gunakan untuk negosiasi SSL dengan Application Load Balancer. Contoh menggunakan--queryparameter untuk menampilkan hanya nama-nama kebijakan.aws elbv2 describe-ssl-policies \ --load-balancer-typeapplication\ --querySslPolicies[*].NameOutput:
[ "ELBSecurityPolicy-2016-08", "ELBSecurityPolicy-TLS13-1-2-2021-06", "ELBSecurityPolicy-TLS13-1-2-Res-2021-06", "ELBSecurityPolicy-TLS13-1-2-Ext1-2021-06", "ELBSecurityPolicy-TLS13-1-2-Ext2-2021-06", "ELBSecurityPolicy-TLS13-1-1-2021-06", "ELBSecurityPolicy-TLS13-1-0-2021-06", "ELBSecurityPolicy-TLS13-1-3-2021-06", "ELBSecurityPolicy-TLS-1-2-2017-01", "ELBSecurityPolicy-TLS-1-1-2017-01", "ELBSecurityPolicy-TLS-1-2-Ext-2018-06", "ELBSecurityPolicy-FS-2018-06", "ELBSecurityPolicy-2015-05", "ELBSecurityPolicy-TLS-1-0-2015-04", "ELBSecurityPolicy-FS-1-2-Res-2019-08", "ELBSecurityPolicy-FS-1-1-2019-08", "ELBSecurityPolicy-FS-1-2-2019-08", "ELBSecurityPolicy-FS-1-2-Res-2020-10" ]Contoh 2: Untuk membuat daftar kebijakan yang mendukung protokol tertentu
describe-ssl-policiesContoh berikut menampilkan nama-nama kebijakan yang mendukung protokol TLS 1.3. Contoh menggunakan--queryparameter untuk menampilkan hanya nama-nama kebijakan.aws elbv2 describe-ssl-policies \ --load-balancer-typeapplication\ --query SslPolicies[?contains(SslProtocols,'TLSv1.3')].NameOutput:
[ "ELBSecurityPolicy-TLS13-1-2-2021-06", "ELBSecurityPolicy-TLS13-1-2-Res-2021-06", "ELBSecurityPolicy-TLS13-1-2-Ext1-2021-06", "ELBSecurityPolicy-TLS13-1-2-Ext2-2021-06", "ELBSecurityPolicy-TLS13-1-1-2021-06", "ELBSecurityPolicy-TLS13-1-0-2021-06", "ELBSecurityPolicy-TLS13-1-3-2021-06" ]Contoh 3: Untuk menampilkan cipher untuk kebijakan
describe-ssl-policiesContoh berikut menampilkan nama-nama cipher untuk kebijakan yang ditentukan. Contoh menggunakan--queryparameter untuk menampilkan hanya nama cipher. Cipher pertama dalam daftar memiliki prioritas 1, dan cipher yang tersisa berada dalam urutan prioritas.aws elbv2 describe-ssl-policies \ --namesELBSecurityPolicy-TLS13-1-2-2021-06\ --querySslPolicies[*].Ciphers[*].NameOutput:
[ "TLS_AES_128_GCM_SHA256", "TLS_AES_256_GCM_SHA384", "TLS_CHACHA20_POLY1305_SHA256", "ECDHE-ECDSA-AES128-GCM-SHA256", "ECDHE-RSA-AES128-GCM-SHA256", "ECDHE-ECDSA-AES128-SHA256", "ECDHE-RSA-AES128-SHA256", "ECDHE-ECDSA-AES256-GCM-SHA384", "ECDHE-RSA-AES256-GCM-SHA384", "ECDHE-ECDSA-AES256-SHA384", "ECDHE-RSA-AES256-SHA384" ]Untuk informasi selengkapnya, lihat Kebijakan keamanan di Panduan Pengguna untuk Penyeimbang Beban Aplikasi.
-
Untuk detail API, lihat DescribeSslPolicies
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakandescribe-tags.
- AWS CLI
-
Untuk mendeskripsikan tag yang ditetapkan ke penyeimbang beban
Contoh ini menjelaskan tag yang ditetapkan untuk penyeimbang beban yang ditentukan.
Perintah:
aws elbv2 describe-tags --resource-arnsarn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188Output:
{ "TagDescriptions": [ { "ResourceArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188", "Tags": [ { "Value": "lima", "Key": "project" }, { "Value": "digital-media", "Key": "department" } ] } ] }-
Untuk detail API, lihat DescribeTags
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakandescribe-target-group-attributes.
- AWS CLI
-
Untuk menggambarkan atribut kelompok sasaran
describe-target-group-attributesContoh berikut menampilkan atribut dari kelompok target yang ditentukan.aws elbv2 describe-target-group-attributes \ --target-group-arnarn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067Output mencakup atribut jika protokolnya HTTP atau HTTPS dan tipe targetnya adalah
instanceatauip.{ "Attributes": [ { "Value": "false", "Key": "stickiness.enabled" }, { "Value": "300", "Key": "deregistration_delay.timeout_seconds" }, { "Value": "lb_cookie", "Key": "stickiness.type" }, { "Value": "86400", "Key": "stickiness.lb_cookie.duration_seconds" }, { "Value": "0", "Key": "slow_start.duration_seconds" } ] }Output berikut mencakup atribut jika protokolnya HTTP atau HTTPS dan tipe targetnya adalah
lambda.{ "Attributes": [ { "Value": "false", "Key": "lambda.multi_value_headers.enabled" } ] }Output berikut mencakup atribut jika protokolnya adalah TCP, TLS, UDP, atau TCP_UDP.
{ "Attributes": [ { "Value": "false", "Key": "proxy_protocol_v2.enabled" }, { "Value": "300", "Key": "deregistration_delay.timeout_seconds" } ] }-
Untuk detail API, lihat DescribeTargetGroupAttributes
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakandescribe-target-groups.
- AWS CLI
-
Contoh 1: Untuk mendeskripsikan kelompok sasaran
describe-target-groupsContoh berikut menampilkan rincian untuk kelompok target yang ditentukan.aws elbv2 describe-target-groups \ --target-group-arnsarn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067Output:
{ "TargetGroups": [ { "TargetGroupArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067", "TargetGroupName": "my-targets", "Protocol": "HTTP", "Port": 80, "VpcId": "vpc-3ac0fb5f", "HealthCheckProtocol": "HTTP", "HealthCheckPort": "traffic-port", "HealthCheckEnabled": true, "HealthCheckIntervalSeconds": 30, "HealthCheckTimeoutSeconds": 5, "HealthyThresholdCount": 5, "UnhealthyThresholdCount": 2, "HealthCheckPath": "/", "Matcher": { "HttpCode": "200" }, "LoadBalancerArns": [ "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188" ], "TargetType": "instance", "ProtocolVersion": "HTTP1", "IpAddressType": "ipv4" } ] }Contoh 2: Untuk mendeskripsikan semua kelompok target untuk penyeimbang beban
describe-target-groupsContoh berikut menampilkan rincian untuk semua kelompok target untuk penyeimbang beban tertentu. Contoh menggunakan--queryparameter untuk menampilkan hanya nama grup target.aws elbv2 describe-target-groups \ --load-balancer-arnarn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188\ --queryTargetGroups[*].TargetGroupNameOutput:
[ "my-instance-targets", "my-ip-targets", "my-lambda-target" ]Untuk informasi selengkapnya, lihat Grup sasaran di Panduan Penyeimbang Beban Aplikasi.
-
Untuk detail API, lihat DescribeTargetGroups
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakandescribe-target-health.
- AWS CLI
-
Contoh 1: Untuk menggambarkan kesehatan target untuk kelompok sasaran
describe-target-healthContoh berikut menampilkan rincian kesehatan untuk target kelompok target yang ditentukan. Target ini sehat.aws elbv2 describe-target-health \ --target-group-arnarn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067Output:
{ "TargetHealthDescriptions": [ { "HealthCheckPort": "80", "Target": { "Id": "i-ceddcd4d", "Port": 80 }, "TargetHealth": { "State": "healthy" } }, { "HealthCheckPort": "80", "Target": { "Id": "i-0f76fade", "Port": 80 }, "TargetHealth": { "State": "healthy" } } ] }Contoh 2: Untuk menggambarkan kesehatan target
describe-target-healthContoh berikut menampilkan rincian kesehatan untuk target yang ditentukan. Target ini sehat.aws elbv2 describe-target-health \ --targetsId=i-0f76fade,Port=80\ --target-group-arnarn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067Output:
{ "TargetHealthDescriptions": [ { "HealthCheckPort": "80", "Target": { "Id": "i-0f76fade", "Port": 80 }, "TargetHealth": { "State": "healthy" } } ] }Contoh output berikut adalah untuk target yang kelompok targetnya tidak ditentukan dalam tindakan untuk pendengar. Target ini tidak dapat menerima lalu lintas dari penyeimbang beban.
{ "TargetHealthDescriptions": [ { "HealthCheckPort": "80", "Target": { "Id": "i-0f76fade", "Port": 80 }, "TargetHealth": { "State": "unused", "Reason": "Target.NotInUse", "Description": "Target group is not configured to receive traffic from the load balancer" } } ] }Output contoh berikut adalah untuk target yang kelompok targetnya hanya ditentukan dalam tindakan untuk pendengar. Targetnya masih didaftarkan.
{ "TargetHealthDescriptions": [ { "HealthCheckPort": "80", "Target": { "Id": "i-0f76fade", "Port": 80 }, "TargetHealth": { "State": "initial", "Reason": "Elb.RegistrationInProgress", "Description": "Target registration is in progress" } } ] }Contoh output berikut adalah untuk target yang tidak sehat.
{ "TargetHealthDescriptions": [ { "HealthCheckPort": "80", "Target": { "Id": "i-0f76fade", "Port": 80 }, "TargetHealth": { "State": "unhealthy", "Reason": "Target.Timeout", "Description": "Connection to target timed out" } } ] }Contoh output berikut adalah untuk target yang merupakan fungsi Lambda dan pemeriksaan kesehatan dinonaktifkan.
{ "TargetHealthDescriptions": [ { "Target": { "Id": "arn:aws:lambda:us-west-2:123456789012:function:my-function", "AvailabilityZone": "all", }, "TargetHealth": { "State": "unavailable", "Reason": "Target.HealthCheckDisabled", "Description": "Health checks are not enabled for this target" } } ] }-
Untuk detail API, lihat DescribeTargetHealth
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanmodify-listener.
- AWS CLI
-
Contoh 1: Untuk mengubah tindakan default menjadi tindakan maju
modify-listenerContoh berikut mengubah tindakan default menjadiforwardtindakan untuk listener tertentu.aws elbv2 modify-listener \ --listener-arnarn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2\ --default-actionsType=forward,TargetGroupArn=arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-new-targets/2453ed029918f21fOutput:
{ "Listeners": [ { "ListenerArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2", "LoadBalancerArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188", "Protocol": "HTTP", "Port": 80, "DefaultActions": [ { "Type": "forward", "TargetGroupArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-new-targets/2453ed029918f21f" } ] } ] }Contoh 2: Untuk mengubah tindakan default menjadi tindakan pengalihan
modify-listenerContoh berikut mengubah tindakan default menjadiredirecttindakan untuk listener tertentu.aws elbv2 modify-listener \ --listener-arnarn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2\ --default-actionsType=redirect,RedirectConfig='{Protocol=HTTPS,StatusCode=HTTP_302}'Output:
{ "Listeners": [ { "ListenerArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2", "LoadBalancerArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188", "Protocol": "HTTP", "Port": 80, "DefaultActions": [ { "Type": "redirect", "RedirectConfig": { "Protocol": "HTTPS", "Port": "#{port}", "Host": "#{host}", "Path": "/#{path}", "Query": "#{query}", "StatusCode": "HTTP_302", } } ] } ] }Contoh 3: Untuk mengubah sertifikat server
modify-listenerContoh berikut mengubah sertifikat server untuk listener HTTPS yang ditentukan.aws elbv2 modify-listener \ --listener-arnarn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/0467ef3c8400ae65\ --certificatesCertificateArn=arn:aws:iam::123456789012:server-certificate/my-new-server-certOutput:
{ "Listeners": [ { "ListenerArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/0467ef3c8400ae65", "LoadBalancerArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188", "Protocol": "HTTPS", "Port": 443, "DefaultActions": [ { "Type": "forward", "TargetGroupArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067" } ], "SslPolicy": "ELBSecurityPolicy-2015-05", "Certificates": [ { "CertificateArn": "arn:aws:iam::123456789012:server-certificate/my-new-server-cert" } ], } ] }Untuk informasi selengkapnya, lihat Aturan Listener di Panduan Pengguna Application Load Balancers.
-
Untuk detail API, lihat ModifyListener
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanmodify-load-balancer-attributes.
- AWS CLI
-
Untuk mengaktifkan perlindungan penghapusan
Contoh ini memungkinkan perlindungan penghapusan untuk penyeimbang beban yang ditentukan.
Perintah:
aws elbv2 modify-load-balancer-attributes --load-balancer-arnarn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188--attributesKey=deletion_protection.enabled,Value=trueOutput:
{ "Attributes": [ { "Value": "true", "Key": "deletion_protection.enabled" }, { "Value": "false", "Key": "access_logs.s3.enabled" }, { "Value": "60", "Key": "idle_timeout.timeout_seconds" }, { "Value": "", "Key": "access_logs.s3.prefix" }, { "Value": "", "Key": "access_logs.s3.bucket" } ] }Untuk mengubah batas waktu idle
Contoh ini mengubah nilai batas waktu idle untuk penyeimbang beban yang ditentukan.
Perintah:
aws elbv2 modify-load-balancer-attributes --load-balancer-arnarn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188--attributesKey=idle_timeout.timeout_seconds,Value=30Output:
{ "Attributes": [ { "Value": "30", "Key": "idle_timeout.timeout_seconds" }, { "Value": "false", "Key": "access_logs.s3.enabled" }, { "Value": "", "Key": "access_logs.s3.prefix" }, { "Value": "true", "Key": "deletion_protection.enabled" }, { "Value": "", "Key": "access_logs.s3.bucket" } ] }Untuk mengaktifkan log akses
Contoh ini memungkinkan log akses untuk penyeimbang beban yang ditentukan. Perhatikan bahwa bucket S3 harus berada di wilayah yang sama dengan penyeimbang beban dan harus memiliki kebijakan yang dilampirkan yang memberikan akses ke layanan Elastic Load Balancing.
Perintah:
aws elbv2 modify-load-balancer-attributes --load-balancer-arnarn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188--attributesKey=access_logs.s3.enabled,Value=trueKey=access_logs.s3.bucket,Value=my-loadbalancer-logsKey=access_logs.s3.prefix,Value=myappOutput:
{ "Attributes": [ { "Value": "true", "Key": "access_logs.s3.enabled" }, { "Value": "my-load-balancer-logs", "Key": "access_logs.s3.bucket" }, { "Value": "myapp", "Key": "access_logs.s3.prefix" }, { "Value": "60", "Key": "idle_timeout.timeout_seconds" }, { "Value": "false", "Key": "deletion_protection.enabled" } ] }-
Untuk detail API, lihat ModifyLoadBalancerAttributes
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanmodify-rule.
- AWS CLI
-
Untuk memodifikasi aturan
modify-ruleContoh berikut memperbarui tindakan dan kondisi untuk aturan yang ditentukan.aws elbv2 modify-rule \ --actionsType=forward,TargetGroupArn=arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067\ --conditions Field=path-pattern,Values='/images/*' --rule-arnarn:aws:elasticloadbalancing:us-west-2:123456789012:listener-rule/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2/9683b2d02a6cabeeOutput:
{ "Rules": [ { "Priority": "10", "Conditions": [ { "Field": "path-pattern", "Values": [ "/images/*" ] } ], "RuleArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:listener-rule/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2/9683b2d02a6cabee", "IsDefault": false, "Actions": [ { "TargetGroupArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067", "Type": "forward" } ] } ] }-
Untuk detail API, lihat ModifyRule
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanmodify-target-group-attributes.
- AWS CLI
-
Untuk mengubah batas waktu tunda deregistrasi
Contoh ini menetapkan batas waktu tunda deregistrasi ke nilai yang ditentukan untuk kelompok target yang ditentukan.
Perintah:
aws elbv2 modify-target-group-attributes --target-group-arnarn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067--attributesKey=deregistration_delay.timeout_seconds,Value=600Output:
{ "Attributes": [ { "Value": "false", "Key": "stickiness.enabled" }, { "Value": "600", "Key": "deregistration_delay.timeout_seconds" }, { "Value": "lb_cookie", "Key": "stickiness.type" }, { "Value": "86400", "Key": "stickiness.lb_cookie.duration_seconds" } ] }-
Untuk detail API, lihat ModifyTargetGroupAttributes
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanmodify-target-group.
- AWS CLI
-
Untuk mengubah konfigurasi pemeriksaan kesehatan untuk grup target
modify-target-groupContoh berikut mengubah konfigurasi pemeriksaan kesehatan yang digunakan untuk mengevaluasi kesehatan target untuk kelompok sasaran yang ditentukan. Perhatikan bahwa karena cara CLI mem-parsing koma, Anda harus mengelilingi rentang--matcheropsi dengan tanda kutip tunggal alih-alih tanda kutip ganda.aws elbv2 modify-target-group \ --target-group-arnarn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-https-targets/2453ed029918f21f\ --health-check-protocolHTTPS\ --health-check-port443\ --matcher HttpCode='200,299'Output:
{ "TargetGroups": [ { "TargetGroupArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-https-targets/2453ed029918f21f", "TargetGroupName": "my-https-targets", "Protocol": "HTTPS", "Port": 443, "VpcId": "vpc-3ac0fb5f", "HealthCheckProtocol": "HTTPS", "HealthCheckPort": "443", "HealthCheckEnabled": true, "HealthCheckIntervalSeconds": 30, "HealthCheckTimeoutSeconds": 5, "HealthyThresholdCount": 5, "UnhealthyThresholdCount": 2, "Matcher": { "HttpCode": "200,299" }, "LoadBalancerArns": [ "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188" ], "TargetType": "instance", "ProtocolVersion": "HTTP1", "IpAddressType": "ipv4" } ] }Untuk informasi selengkapnya, lihat Grup sasaran di Panduan Penyeimbang Beban Aplikasi.
-
Untuk detail API, lihat ModifyTargetGroup
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanregister-targets.
- AWS CLI
-
Contoh 1: Untuk mendaftarkan target dengan grup target dengan ID instance
register-targetsContoh berikut mendaftarkan contoh yang ditentukan dengan kelompok target. Kelompok sasaran harus memiliki jenis targetinstance.aws elbv2 register-targets \ --target-group-arnarn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067\ --targetsId=i-1234567890abcdef0Id=i-0abcdef1234567890Contoh 2: Untuk mendaftarkan target dengan grup target menggunakan penggantian port
register-targetsContoh berikut mendaftarkan instance tertentu dengan kelompok target menggunakan beberapa port. Ini memungkinkan Anda untuk mendaftarkan kontainer pada instance yang sama dengan target dalam grup target.aws elbv2 register-targets \ --target-group-arnarn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-internal-targets/3bb63f11dfb0faf9\ --targetsId=i-0598c7d356eba48d7,Port=80Id=i-0598c7d356eba48d7,Port=766Contoh 3: Untuk mendaftarkan target dengan grup target berdasarkan alamat IP
register-targetsContoh berikut mendaftarkan alamat IP yang ditentukan dengan kelompok target. Kelompok sasaran harus memiliki jenis targetip.aws elbv2 register-targets \ --target-group-arnarn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-tcp-ip-targets/8518e899d173178f\ --targetsId=10.0.1.15Id=10.0.1.23Contoh 4: Untuk mendaftarkan fungsi Lambda sebagai target
register-targetsContoh berikut mendaftarkan alamat IP yang ditentukan dengan kelompok target. Kelompok sasaran harus memiliki jenis targetlambda. Anda harus memberikan izin Elastic Load Balancing untuk menjalankan fungsi Lambda.aws elbv2 register-targets \ --target-group-arnarn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-tcp-ip-targets/8518e899d173178f\ --targetsId=arn:aws:lambda:us-west-2:123456789012:function:my-function-
Untuk detail API, lihat RegisterTargets
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanremove-listener-certificates.
- AWS CLI
-
Untuk menghapus sertifikat dari pendengar yang aman
Contoh ini menghapus sertifikat yang ditentukan dari pendengar aman yang ditentukan.
Perintah:
aws elbv2 remove-listener-certificates --listener-arnarn:aws:elasticloadbalancing:us-west-2:123456789012:listener/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2--certificatesCertificateArn=arn:aws:acm:us-west-2:123456789012:certificate/5cc54884-f4a3-4072-80be-05b9ba72f705-
Untuk detail API, lihat RemoveListenerCertificates
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanremove-tags.
- AWS CLI
-
Untuk menghapus tag dari penyeimbang beban
remove-tagsContoh berikut menghapusprojectdandepartmenttag dari penyeimbang beban yang ditentukan.aws elbv2 remove-tags \ --resource-arnsarn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188\ --tag-keysprojectdepartment-
Untuk detail API, lihat RemoveTags
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanset-ip-address-type.
- AWS CLI
-
Untuk mengatur jenis alamat penyeimbang beban
Contoh ini menetapkan jenis alamat penyeimbang beban yang ditentukan ke
dualstack. Subnet penyeimbang beban harus memiliki blok IPv6 CIDR yang terkait.Perintah:
aws elbv2 set-ip-address-type --load-balancer-arnarn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188--ip-address-typedualstackOutput:
{ "IpAddressType": "dualstack" }-
Untuk detail API, lihat SetIpAddressType
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanset-rule-priorities.
- AWS CLI
-
Untuk menetapkan prioritas aturan
Contoh ini menetapkan prioritas aturan yang ditentukan.
Perintah:
aws elbv2 set-rule-priorities --rule-prioritiesRuleArn=arn:aws:elasticloadbalancing:us-west-2:123456789012:listener-rule/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2/1291d13826f405c3,Priority=5Output:
{ "Rules": [ { "Priority": "5", "Conditions": [ { "Field": "path-pattern", "Values": [ "/img/*" ] } ], "RuleArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:listener-rule/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2/1291d13826f405c3", "IsDefault": false, "Actions": [ { "TargetGroupArn": "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067", "Type": "forward" } ] } ] }-
Untuk detail API, lihat SetRulePriorities
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanset-security-groups.
- AWS CLI
-
Untuk mengaitkan grup keamanan dengan penyeimbang beban
Contoh ini mengaitkan grup keamanan yang ditentukan dengan penyeimbang beban yang ditentukan.
Perintah:
aws elbv2 set-security-groups --load-balancer-arnarn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188--security-groupssg-5943793cOutput:
{ "SecurityGroupIds": [ "sg-5943793c" ] }-
Untuk detail API, lihat SetSecurityGroups
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanset-subnets.
- AWS CLI
-
Untuk mengaktifkan Availability Zones untuk load balancer
Contoh ini memungkinkan Availability Zone untuk subnet yang ditentukan untuk load balancer yang ditentukan.
Perintah:
aws elbv2 set-subnets --load-balancer-arnarn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188--subnetssubnet-8360a9e7subnet-b7d581c0Output:
{ "AvailabilityZones": [ { "SubnetId": "subnet-8360a9e7", "ZoneName": "us-west-2a" }, { "SubnetId": "subnet-b7d581c0", "ZoneName": "us-west-2b" } ] }-
Untuk detail API, lihat SetSubnets
di Referensi AWS CLI Perintah.
-