Elastic Load Balancing - Exemplos da versão 2 usando ferramentas para PowerShell - AWS Exemplos de código do SDK

Há mais exemplos de AWS SDK disponíveis no repositório AWS Doc SDK Examples GitHub .

As traduções são geradas por tradução automática. Em caso de conflito entre o conteúdo da tradução e da versão original em inglês, a versão em inglês prevalecerá.

Elastic Load Balancing - Exemplos da versão 2 usando ferramentas para PowerShell

Os exemplos de código a seguir mostram como realizar ações e implementar cenários comuns usando o Ferramentas da AWS para PowerShell com o Elastic Load Balancing - Versão 2.

Ações são trechos de código de programas maiores e devem ser executadas em contexto. Embora as ações mostrem como chamar perfis de serviço individuais, você pode ver as ações no contexto em seus cenários relacionados.

Cada exemplo inclui um link para o código-fonte completo, em que você pode encontrar instruções sobre como configurar e executar o código.

Tópicos

Ações

O código de exemplo a seguir mostra como usar Add-ELB2ListenerCertificate.

Ferramentas para PowerShell

Exemplo 1: Este exemplo adiciona um certificado adicional ao Listener especificado.

Add-ELB2ListenerCertificate -ListenerArn 'arn:aws:elasticloadbalancing:us-east-1:123456789012:listener/app/test-alb/3651b4394dd9a24f/3873f123b98f7618' -Certificate @{CertificateArn = 'arn:aws:acm:us-east-1:123456789012:certificate/19478bd5-491d-47d4-b1d7-5217feba1d97'}

Saída:

CertificateArn IsDefault -------------- --------- arn:aws:acm:us-east-1:123456789012:certificate/19478bd5-491d-47d4-b1d7-5217feba1d97 False
  • Para obter detalhes da API, consulte AddListenerCertificatesem Referência de Ferramentas da AWS para PowerShell cmdlet.

O código de exemplo a seguir mostra como usar Add-ELB2Tag.

Ferramentas para PowerShell

Exemplo 1: Este exemplo adiciona um novo Tag ao AWS.Tools.ElasticLoadBalancingV2 recurso especificado.

Add-ELB2Tag -ResourceArn 'arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/app/test-alb/3651b4394dd9a24f' -Tag @{Key = 'productVersion'; Value = '1.0.0'}
  • Para obter detalhes da API, consulte AddTagsem Referência de Ferramentas da AWS para PowerShell cmdlet.

O código de exemplo a seguir mostra como usar Edit-ELB2Listener.

Ferramentas para PowerShell

Exemplo 1: Este exemplo modifica a ação padrão dos ouvintes especificados para resposta fixa.

$newDefaultAction = [Amazon.ElasticLoadBalancingV2.Model.Action]@{ "FixedResponseConfig" = @{ "ContentType" = "text/plain" "MessageBody" = "Hello World" "StatusCode" = "200" } "Type" = [Amazon.ElasticLoadBalancingV2.ActionTypeEnum]::FixedResponse } Edit-ELB2Listener -ListenerArn 'arn:aws:elasticloadbalancing:us-east-1:123456789012:listener/app/testALB/3e2f03b558e19676/d19f2f14974db685' -Port 8080 -DefaultAction $newDefaultAction

Saída:

Certificates : {} DefaultActions : {Amazon.ElasticLoadBalancingV2.Model.Action} ListenerArn : arn:aws:elasticloadbalancing:us-east-1:123456789012:listener/app/testALB/3e2f03b558e19676/d19f2f14974db685 LoadBalancerArn : arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/app/testALB/3e2f03b558e19676 Port : 8080 Protocol : HTTP SslPolicy :
  • Para obter detalhes da API, consulte ModifyListenerem Referência de Ferramentas da AWS para PowerShell cmdlet.

O código de exemplo a seguir mostra como usar Edit-ELB2LoadBalancerAttribute.

Ferramentas para PowerShell

Exemplo 1: Esse exemplo modifica os atributos do balanceador de carga especificado.

Edit-ELB2LoadBalancerAttribute -LoadBalancerArn 'arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/app/test-alb/3651b4394dd9a24f' -Attribute @{Key = 'deletion_protection.enabled'; Value = 'true'}

Saída:

Key Value --- ----- deletion_protection.enabled true access_logs.s3.enabled false access_logs.s3.bucket access_logs.s3.prefix idle_timeout.timeout_seconds 60 routing.http2.enabled true routing.http.drop_invalid_header_fields.enabled false

O código de exemplo a seguir mostra como usar Edit-ELB2Rule.

Ferramentas para PowerShell

Exemplo 1: Este exemplo modifica as configurações especificadas da regra do Listener.

$newRuleCondition = [Amazon.ElasticLoadBalancingV2.Model.RuleCondition]@{ "PathPatternConfig" = @{ "Values" = "/login1","/login2","/login3" } "Field" = "path-pattern" } Edit-ELB2Rule -RuleArn 'arn:aws:elasticloadbalancing:us-east-1:123456789012:listener-rule/app/testALB/3e2f03b558e19676/1c84f02aec143e80/f4f51dfaa033a8cc' -Condition $newRuleCondition

Saída:

Actions : {Amazon.ElasticLoadBalancingV2.Model.Action} Conditions : {Amazon.ElasticLoadBalancingV2.Model.RuleCondition} IsDefault : False Priority : 10 RuleArn : arn:aws:elasticloadbalancing:us-east-1:123456789012:listener-rule/app/testALB/3e2f03b558e19676/1c84f02aec143e80/f4f51dfaa033a8cc
  • Para obter detalhes da API, consulte ModifyRuleem Referência de Ferramentas da AWS para PowerShell cmdlet.

O código de exemplo a seguir mostra como usar Edit-ELB2TargetGroup.

Ferramentas para PowerShell

Exemplo 1: Este exemplo modifica as propriedades do grupo-alvo especificado.

Edit-ELB2TargetGroup -TargetGroupArn 'arn:aws:elasticloadbalancing:us-east-1:123456789012:targetgroup/test-tg/a4e04b3688be1970' -HealthCheckIntervalSecond 60 -HealthCheckPath '/index.html' -HealthCheckPort 8080

Saída:

HealthCheckEnabled : True HealthCheckIntervalSeconds : 60 HealthCheckPath : /index.html HealthCheckPort : 8080 HealthCheckProtocol : HTTP HealthCheckTimeoutSeconds : 5 HealthyThresholdCount : 5 LoadBalancerArns : {} Matcher : Amazon.ElasticLoadBalancingV2.Model.Matcher Port : 80 Protocol : HTTP TargetGroupArn : arn:aws:elasticloadbalancing:us-east-1:123456789012:targetgroup/test-tg/a4e04b3688be1970 TargetGroupName : test-tg TargetType : instance UnhealthyThresholdCount : 2 VpcId : vpc-2cfd7000
  • Para obter detalhes da API, consulte ModifyTargetGroupem Referência de Ferramentas da AWS para PowerShell cmdlet.

O código de exemplo a seguir mostra como usar Edit-ELB2TargetGroupAttribute.

Ferramentas para PowerShell

Exemplo 1: Este exemplo modifica o atributo deregistration_delay do grupo-alvo especificado.

Edit-ELB2TargetGroupAttribute -TargetGroupArn 'arn:aws:elasticloadbalancing:us-east-1:123456789012:targetgroup/test-tg/a4e04b3688be1970' -Attribute @{Key = 'deregistration_delay.timeout_seconds'; Value = 600}

Saída:

Key Value --- ----- stickiness.enabled false deregistration_delay.timeout_seconds 600 stickiness.type lb_cookie stickiness.lb_cookie.duration_seconds 86400 slow_start.duration_seconds 0 load_balancing.algorithm.type round_robin

O código de exemplo a seguir mostra como usar Get-ELB2AccountLimit.

Ferramentas para PowerShell

Exemplo 1: Esse comando lista os limites ELB2 da conta para uma determinada região.

Get-ELB2AccountLimit

Saída:

Max Name --- ---- 3000 target-groups 1000 targets-per-application-load-balancer 50 listeners-per-application-load-balancer 100 rules-per-application-load-balancer 50 network-load-balancers 3000 targets-per-network-load-balancer 500 targets-per-availability-zone-per-network-load-balancer 50 listeners-per-network-load-balancer 5 condition-values-per-alb-rule 5 condition-wildcards-per-alb-rule 100 target-groups-per-application-load-balancer 5 target-groups-per-action-on-application-load-balancer 1 target-groups-per-action-on-network-load-balancer 50 application-load-balancers
  • Para obter detalhes da API, consulte DescribeAccountLimitsem Referência de Ferramentas da AWS para PowerShell cmdlet.

O código de exemplo a seguir mostra como usar Get-ELB2Listener.

Ferramentas para PowerShell

Exemplo 1: Este exemplo descreve os ouvintes do ALB/NLB especificado.

Get-ELB2Listener -LoadBalancerArn 'arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/app/test-alb/3651b4394dd9a24f'

Saída:

Certificates : {} DefaultActions : {Amazon.ElasticLoadBalancingV2.Model.Action} ListenerArn : arn:aws:elasticloadbalancing:us-east-1:123456789012:listener/app/test-alb/3651b4394dd9a24f/1dac07c21187d41e LoadBalancerArn : arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/app/test-alb/3651b4394dd9a24f Port : 80 Protocol : HTTP SslPolicy : Certificates : {Amazon.ElasticLoadBalancingV2.Model.Certificate} DefaultActions : {Amazon.ElasticLoadBalancingV2.Model.Action} ListenerArn : arn:aws:elasticloadbalancing:us-east-1:123456789012:listener/app/test-alb/3651b4394dd9a24f/66e10e3aaf5b6d9b LoadBalancerArn : arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/app/test-alb/3651b4394dd9a24f Port : 443 Protocol : HTTPS SslPolicy : ELBSecurityPolicy-2016-08
  • Para obter detalhes da API, consulte DescribeListenersem Referência de Ferramentas da AWS para PowerShell cmdlet.

O código de exemplo a seguir mostra como usar Get-ELB2ListenerCertificate.

Ferramentas para PowerShell

Exemplo 1: Este exemplo descreve o certificado para o ouvinte especificado.

Get-ELB2ListenerCertificate -ListenerArn 'arn:aws:elasticloadbalancing:us-east-1:123456789012:listener/app/test-alb/3651b4394dd9a24f/66e10e3aaf5b6d9b'

Saída:

CertificateArn IsDefault -------------- --------- arn:aws:acm:us-east-1:123456789012:certificate/5fc7c092-68bf-4862-969c-22fd48b6e17c True

O código de exemplo a seguir mostra como usar Get-ELB2LoadBalancer.

Ferramentas para PowerShell

Exemplo 1: Esse exemplo exibe todos os balanceadores de carga de uma determinada região.

Get-ELB2LoadBalancer

Saída:

AvailabilityZones : {us-east-1c} CanonicalHostedZoneId : Z26RNL4JYFTOTI CreatedTime : 6/22/18 11:21:50 AM DNSName : test-elb1234567890-238d34ad8d94bc2e.elb.us-east-1.amazonaws.com IpAddressType : ipv4 LoadBalancerArn : arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/net/test-elb1234567890/238d34ad8d94bc2e LoadBalancerName : test-elb1234567890 Scheme : internet-facing SecurityGroups : {} State : Amazon.ElasticLoadBalancingV2.Model.LoadBalancerState Type : network VpcId : vpc-2cf00000
  • Para obter detalhes da API, consulte DescribeLoadBalancersem Referência de Ferramentas da AWS para PowerShell cmdlet.

O código de exemplo a seguir mostra como usar Get-ELB2LoadBalancerAttribute.

Ferramentas para PowerShell

Exemplo 1: Esse comando descreve os atributos de um determinado balanceador de carga.

Get-ELB2LoadBalancerAttribute -LoadBalancerArn 'arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/net/test-elb/238d34ad8d94bc2e'

Saída:

Key Value --- ----- access_logs.s3.enabled false load_balancing.cross_zone.enabled true access_logs.s3.prefix deletion_protection.enabled false access_logs.s3.bucket

O código de exemplo a seguir mostra como usar Get-ELB2Rule.

Ferramentas para PowerShell

Exemplo 1: Este exemplo descreve as regras do ouvinte para o ARN do ouvinte especificado.

Get-ELB2Rule -ListenerArn 'arn:aws:elasticloadbalancing:us-east-1:123456789012:listener/app/test-alb/3651b4394dd9a24f/66e10e3aaf5b6d9b'

Saída:

Actions : {Amazon.ElasticLoadBalancingV2.Model.Action} Conditions : {Amazon.ElasticLoadBalancingV2.Model.RuleCondition} IsDefault : False Priority : 1 RuleArn : arn:aws:elasticloadbalancing:us-east-1:123456789012:listener-rule/app/test-alb/3651b4394dd9a24f/66e10e3aaf5b6d9b/2286fff5055e0f79 Actions : {Amazon.ElasticLoadBalancingV2.Model.Action} Conditions : {Amazon.ElasticLoadBalancingV2.Model.RuleCondition} IsDefault : False Priority : 2 RuleArn : arn:aws:elasticloadbalancing:us-east-1:123456789012:listener-rule/app/test-alb/3651b4394dd9a24f/66e10e3aaf5b6d9b/14e7b036567623ba Actions : {Amazon.ElasticLoadBalancingV2.Model.Action} Conditions : {} IsDefault : True Priority : default RuleArn : arn:aws:elasticloadbalancing:us-east-1:123456789012:listener-rule/app/test-alb/3651b4394dd9a24f/66e10e3aaf5b6d9b/853948cf3aa9b2bf
  • Para obter detalhes da API, consulte DescribeRulesem Referência de Ferramentas da AWS para PowerShell cmdlet.

O código de exemplo a seguir mostra como usar Get-ELB2SSLPolicy.

Ferramentas para PowerShell

Exemplo 1: Este exemplo lista todas as políticas de ouvinte disponíveis para a ElasticLoadBalancing V2.

Get-ELB2SSLPolicy

Saída:

Ciphers Name SslProtocols ------- ---- ------------ {ECDHE-ECDSA-AES128-GCM-SHA256, ECDHE-RSA-AES128-GCM-SHA256, ECDHE-ECDSA-AES128-SHA256, ECDHE-RSA-AES128-SHA256} ELBSecurityPolicy-2016-08 {TLSv1, TLSv1.1, TLSv1.2} {ECDHE-ECDSA-AES128-GCM-SHA256, ECDHE-RSA-AES128-GCM-SHA256, ECDHE-ECDSA-AES128-SHA256, ECDHE-RSA-AES128-SHA256} ELBSecurityPolicy-TLS-1-2-2017-01 {TLSv1.2} {ECDHE-ECDSA-AES128-GCM-SHA256, ECDHE-RSA-AES128-GCM-SHA256, ECDHE-ECDSA-AES128-SHA256, ECDHE-RSA-AES128-SHA256} ELBSecurityPolicy-TLS-1-1-2017-01 {TLSv1.1, TLSv1.2} {ECDHE-ECDSA-AES128-GCM-SHA256, ECDHE-RSA-AES128-GCM-SHA256, ECDHE-ECDSA-AES128-SHA256, ECDHE-RSA-AES128-SHA256} ELBSecurityPolicy-TLS-1-2-Ext-2018-06 {TLSv1.2} {ECDHE-ECDSA-AES128-GCM-SHA256, ECDHE-RSA-AES128-GCM-SHA256, ECDHE-ECDSA-AES128-SHA256, ECDHE-RSA-AES128-SHA256} ELBSecurityPolicy-FS-2018-06 {TLSv1, TLSv1.1, TLSv1.2} {ECDHE-ECDSA-AES128-GCM-SHA256, ECDHE-RSA-AES128-GCM-SHA256, ECDHE-ECDSA-AES128-SHA256, ECDHE-RSA-AES128-SHA256} ELBSecurityPolicy-2015-05 {TLSv1, TLSv1.1, TLSv1.2} {ECDHE-ECDSA-AES128-GCM-SHA256, ECDHE-RSA-AES128-GCM-SHA256, ECDHE-ECDSA-AES128-SHA256, ECDHE-RSA-AES128-SHA256} ELBSecurityPolicy-TLS-1-0-2015-04 {TLSv1, TLSv1.1, TLSv1.2} {ECDHE-ECDSA-AES128-GCM-SHA256, ECDHE-RSA-AES128-GCM-SHA256, ECDHE-ECDSA-AES128-SHA256, ECDHE-RSA-AES128-SHA256} ELBSecurityPolicy-FS-1-2-Res-2019-08 {TLSv1.2} {ECDHE-ECDSA-AES128-GCM-SHA256, ECDHE-RSA-AES128-GCM-SHA256, ECDHE-ECDSA-AES128-SHA256, ECDHE-RSA-AES128-SHA256} ELBSecurityPolicy-FS-1-1-2019-08 {TLSv1.1, TLSv1.2} {ECDHE-ECDSA-AES128-GCM-SHA256, ECDHE-RSA-AES128-GCM-SHA256, ECDHE-ECDSA-AES128-SHA256, ECDHE-RSA-AES128-SHA256} ELBSecurityPolicy-FS-1-2-2019-08 {TLSv1.2}
  • Para obter detalhes da API, consulte DescribeSslPoliciesem Referência de Ferramentas da AWS para PowerShell cmdlet.

O código de exemplo a seguir mostra como usar Get-ELB2Tag.

Ferramentas para PowerShell

Exemplo 1: Este exemplo lista as tags do recurso especificado.

Get-ELB2Tag -ResourceArn 'arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/app/test-alb/3651b4394dd9a24f'

Saída:

ResourceArn Tags ----------- ---- arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/app/test-alb/3651b4394dd9a24f {stage, internalName, version}
  • Para obter detalhes da API, consulte DescribeTagsem Referência de Ferramentas da AWS para PowerShell cmdlet.

O código de exemplo a seguir mostra como usar Get-ELB2TargetGroup.

Ferramentas para PowerShell

Exemplo 1: Este exemplo descreve o grupo-alvo especificado.

Get-ELB2TargetGroup -TargetGroupArn 'arn:aws:elasticloadbalancing:us-east-1:123456789012:targetgroup/test-tg/a4e04b3688be1970'

Saída:

HealthCheckEnabled : True HealthCheckIntervalSeconds : 30 HealthCheckPath : / HealthCheckPort : traffic-port HealthCheckProtocol : HTTP HealthCheckTimeoutSeconds : 5 HealthyThresholdCount : 5 LoadBalancerArns : {arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/app/test-alb/3651b4394dd9a24f} Matcher : Amazon.ElasticLoadBalancingV2.Model.Matcher Port : 80 Protocol : HTTP TargetGroupArn : arn:aws:elasticloadbalancing:us-east-1:123456789012:targetgroup/test-tg/a4e04b3688be1970 TargetGroupName : test-tg TargetType : instance UnhealthyThresholdCount : 2 VpcId : vpc-2cfd7000
  • Para obter detalhes da API, consulte DescribeTargetGroupsem Referência de Ferramentas da AWS para PowerShell cmdlet.

O código de exemplo a seguir mostra como usar Get-ELB2TargetGroupAttribute.

Ferramentas para PowerShell

Exemplo 1: Este exemplo descreve os atributos do grupo-alvo especificado.

Get-ELB2TargetGroupAttribute -TargetGroupArn 'arn:aws:elasticloadbalancing:us-east-1:123456789012:targetgroup/test-tg/a4e04b3688be1970'

Saída:

Key Value --- ----- stickiness.enabled false deregistration_delay.timeout_seconds 300 stickiness.type lb_cookie stickiness.lb_cookie.duration_seconds 86400 slow_start.duration_seconds 0 load_balancing.algorithm.type round_robin

O código de exemplo a seguir mostra como usar Get-ELB2TargetHealth.

Ferramentas para PowerShell

Exemplo 1: Este exemplo retorna o status de saúde dos alvos presentes no grupo-alvo especificado.

Get-ELB2TargetHealth -TargetGroupArn 'arn:aws:elasticloadbalancing:us-east-1:123456789012:targetgroup/test-tg/a4e04b3688be1970'

Saída:

HealthCheckPort Target TargetHealth --------------- ------ ------------ 80 Amazon.ElasticLoadBalancingV2.Model.TargetDescription Amazon.ElasticLoadBalancingV2.Model.TargetHealth
  • Para obter detalhes da API, consulte DescribeTargetHealthem Referência de Ferramentas da AWS para PowerShell cmdlet.

O código de exemplo a seguir mostra como usar New-ELB2Listener.

Ferramentas para PowerShell

Exemplo 1: Este exemplo cria um novo ouvinte do ALB com a ação padrão 'Encaminhar' para enviar tráfego para o grupo-alvo especificado.

$defaultAction = [Amazon.ElasticLoadBalancingV2.Model.Action]@{ ForwardConfig = @{ TargetGroups = @( @{ TargetGroupArn = "arn:aws:elasticloadbalancing:us-east-1:123456789012:targetgroup/testAlbTG/3d61c2f20aa5bccb" } ) TargetGroupStickinessConfig = @{ DurationSeconds = 900 Enabled = $true } } Type = "Forward" } New-ELB2Listener -LoadBalancerArn 'arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/app/testALB/3e2f03b558e19676' -Port 8001 -Protocol "HTTP" -DefaultAction $defaultAction

Saída:

Certificates : {} DefaultActions : {Amazon.ElasticLoadBalancingV2.Model.Action} ListenerArn : arn:aws:elasticloadbalancing:us-east-1:123456789012:listener/app/testALB/3e2f03b558e19676/1c84f02aec143e80 LoadBalancerArn : arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/app/testALB/3e2f03b558e19676 Port : 8001 Protocol : HTTP SslPolicy :
  • Para obter detalhes da API, consulte CreateListenerem Referência de Ferramentas da AWS para PowerShell cmdlet.

O código de exemplo a seguir mostra como usar New-ELB2LoadBalancer.

Ferramentas para PowerShell

Exemplo 1: Este exemplo cria um novo balanceador de carga de aplicativos voltado para a Internet com duas sub-redes.

New-ELB2LoadBalancer -Type application -Scheme internet-facing -IpAddressType ipv4 -Name 'New-Test-ALB' -SecurityGroup 'sg-07c3414abb8811cbd' -subnet 'subnet-c37a67a6','subnet-fc02eea0'

Saída:

AvailabilityZones : {us-east-1b, us-east-1a} CanonicalHostedZoneId : Z35SXDOTRQ7X7K CreatedTime : 12/28/19 2:58:03 PM DNSName : New-Test-ALB-1391502222.us-east-1.elb.amazonaws.com IpAddressType : ipv4 LoadBalancerArn : arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/app/New-Test-ALB/dab2e4d90eb51493 LoadBalancerName : New-Test-ALB Scheme : internet-facing SecurityGroups : {sg-07c3414abb8811cbd} State : Amazon.ElasticLoadBalancingV2.Model.LoadBalancerState Type : application VpcId : vpc-2cfd7000
  • Para obter detalhes da API, consulte CreateLoadBalancerem Referência de Ferramentas da AWS para PowerShell cmdlet.

O código de exemplo a seguir mostra como usar New-ELB2Rule.

Ferramentas para PowerShell

Exemplo 1: Este exemplo cria uma nova regra de ouvinte com ação de resposta fixa com base no valor do cabeçalho do cliente para o ouvinte especificado.

$newRuleAction = [Amazon.ElasticLoadBalancingV2.Model.Action]@{ "FixedResponseConfig" = @{ "ContentType" = "text/plain" "MessageBody" = "Hello World" "StatusCode" = "200" } "Type" = [Amazon.ElasticLoadBalancingV2.ActionTypeEnum]::FixedResponse } $newRuleCondition = [Amazon.ElasticLoadBalancingV2.Model.RuleCondition]@{ "httpHeaderConfig" = @{ "HttpHeaderName" = "customHeader" "Values" = "header2","header1" } "Field" = "http-header" } New-ELB2Rule -ListenerArn 'arn:aws:elasticloadbalancing:us-east-1:123456789012:listener/app/testALB/3e2f03b558e19676/1c84f02aec143e80' -Action $newRuleAction -Condition $newRuleCondition -Priority 10

Saída:

Actions : {Amazon.ElasticLoadBalancingV2.Model.Action} Conditions : {Amazon.ElasticLoadBalancingV2.Model.RuleCondition} IsDefault : False Priority : 10 RuleArn : arn:aws:elasticloadbalancing:us-east-1:123456789012:listener-rule/app/testALB/3e2f03b558e19676/1c84f02aec143e80/f4f51dfaa033a8cc
  • Para obter detalhes da API, consulte CreateRuleem Referência de Ferramentas da AWS para PowerShell cmdlet.

O código de exemplo a seguir mostra como usar New-ELB2TargetGroup.

Ferramentas para PowerShell

Exemplo 1: Este exemplo cria um novo grupo-alvo com os parâmetros fornecidos.

New-ELB2TargetGroup -HealthCheckEnabled 1 -HealthCheckIntervalSeconds 30 -HealthCheckPath '/index.html' -HealthCheckPort 80 -HealthCheckTimeoutSecond 5 -HealthyThresholdCount 2 -UnhealthyThresholdCount 5 -Port 80 -Protocol 'HTTP' -TargetType instance -VpcId 'vpc-2cfd7000' -Name 'NewTargetGroup'

Saída:

HealthCheckEnabled : True HealthCheckIntervalSeconds : 30 HealthCheckPath : /index.html HealthCheckPort : 80 HealthCheckProtocol : HTTP HealthCheckTimeoutSeconds : 5 HealthyThresholdCount : 2 LoadBalancerArns : {} Matcher : Amazon.ElasticLoadBalancingV2.Model.Matcher Port : 80 Protocol : HTTP TargetGroupArn : arn:aws:elasticloadbalancing:us-east-1:123456789012:targetgroup/NewTargetGroup/534e484681d801bf TargetGroupName : NewTargetGroup TargetType : instance UnhealthyThresholdCount : 5 VpcId : vpc-2cfd7000
  • Para obter detalhes da API, consulte CreateTargetGroupem Referência de Ferramentas da AWS para PowerShell cmdlet.

O código de exemplo a seguir mostra como usar Register-ELB2Target.

Ferramentas para PowerShell

Exemplo 1: Esse exemplo registra a instância 'i-0672a4c4cdeae3111' com o grupo de destino especificado.

Register-ELB2Target -TargetGroupArn 'arn:aws:elasticloadbalancing:us-east-1:123456789012:targetgroup/test-tg/a4e04b3688be1970' -Target @{Port = 80; Id = 'i-0672a4c4cdeae3111'}
  • Para obter detalhes da API, consulte RegisterTargetsem Referência de Ferramentas da AWS para PowerShell cmdlet.

O código de exemplo a seguir mostra como usar Remove-ELB2Listener.

Ferramentas para PowerShell

Exemplo 1: Este exemplo exclui o ouvinte especificado.

Remove-ELB2Listener -ListenerArn 'arn:aws:elasticloadbalancing:us-east-1:123456789012:listener/app/test-alb/3651b4394dd9a24f/66e10e3aaf5b6d9b'

Saída:

Confirm Are you sure you want to perform this action? Performing the operation "Remove-ELB2Listener (DeleteListener)" on target "arn:aws:elasticloadbalancing:us-east-1:123456789012:listener/app/test-alb/3651b4394dd9a24f/66e10e3aaf5b6d9b". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): y

Exemplo 2: Este exemplo remove o ouvinte especificado do balanceador de carga.

Remove-ELB2Listener -ListenerArn 'arn:aws:elasticloadbalancing:us-east-1:123456789012:listener/app/test-alb/3651b4394dd9a24f/3873f123b98f7618'

Saída:

Confirm Are you sure you want to perform this action? Performing the operation "Remove-ELB2Listener (DeleteListener)" on target "arn:aws:elasticloadbalancing:us-east-1:123456789012:listener/app/test-alb/3651b4394dd9a24f/3873f123b98f7618". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): y
  • Para obter detalhes da API, consulte DeleteListenerem Referência de Ferramentas da AWS para PowerShell cmdlet.

O código de exemplo a seguir mostra como usar Remove-ELB2ListenerCertificate.

Ferramentas para PowerShell

Exemplo 1: Este exemplo remove o certificado especificado do grupo-alvo especificado.

Remove-ELB2ListenerCertificate -Certificate @{CertificateArn = 'arn:aws:acm:us-east-1:123456789012:certificate/19478bd5-491d-47d4-b1d7-5217feba1d97'} -ListenerArn 'arn:aws:elasticloadbalancing:us-east-1:123456789012:listener/app/test-alb/3651b4394dd9a24f/3873f123b98f7618'

Saída:

Confirm Are you sure you want to perform this action? Performing the operation "Remove-ELB2ListenerCertificate (RemoveListenerCertificates)" on target "arn:aws:elasticloadbalancing:us-east-1:123456789012:listener/app/test-alb/3651b4394dd9a24f/3873f123b98f7618". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): y

O código de exemplo a seguir mostra como usar Remove-ELB2LoadBalancer.

Ferramentas para PowerShell

Exemplo 1: Este exemplo exclui o balanceador de carga especificado.

Remove-ELB2LoadBalancer -LoadBalancerArn 'arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/app/test-alb/3651b4394dd9a24f'

Saída:

Confirm Are you sure you want to perform this action? Performing the operation "Remove-ELB2LoadBalancer (DeleteLoadBalancer)" on target "arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/app/test-alb/3651b4394dd9a24f". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): y
  • Para obter detalhes da API, consulte DeleteLoadBalancerem Referência de Ferramentas da AWS para PowerShell cmdlet.

O código de exemplo a seguir mostra como usar Remove-ELB2Rule.

Ferramentas para PowerShell

Exemplo 1: Este exemplo remove a regra especificada do Listener

Remove-ELB2Rule -RuleArn 'arn:aws:elasticloadbalancing:us-east-1:123456789012:listener-rule/app/test-alb/3651b4394dd9a24f/3873f123b98f7618/4b25eb10a42e33ab'

Saída:

Confirm Are you sure you want to perform this action? Performing the operation "Remove-ELB2Rule (DeleteRule)" on target "arn:aws:elasticloadbalancing:us-east-1:123456789012:listener-rule/app/test-alb/3651b4394dd9a24f/3873f123b98f7618/4b25eb10a42e33ab". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): y
  • Para obter detalhes da API, consulte DeleteRuleem Referência de Ferramentas da AWS para PowerShell cmdlet.

O código de exemplo a seguir mostra como usar Remove-ELB2Tag.

Ferramentas para PowerShell

Exemplo 1: Esse exemplo remove a tag da chave especificada.

Remove-ELB2Tag -ResourceArn 'arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/app/test-alb/3651b4394dd9a24f' -TagKey 'productVersion'

Saída:

Confirm Are you sure you want to perform this action? Performing the operation "Remove-ELB2Tag (RemoveTags)" on target "arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/app/test-alb/3651b4394dd9a24f". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): y
  • Para obter detalhes da API, consulte RemoveTagsem Referência de Ferramentas da AWS para PowerShell cmdlet.

O código de exemplo a seguir mostra como usar Remove-ELB2TargetGroup.

Ferramentas para PowerShell

Exemplo 1: Este exemplo remove o grupo-alvo especificado.

Remove-ELB2TargetGroup -TargetGroupArn 'arn:aws:elasticloadbalancing:us-east-1:123456789012:targetgroup/testsssss/4e0b6076bc6483a7'

Saída:

Confirm Are you sure you want to perform this action? Performing the operation "Remove-ELB2TargetGroup (DeleteTargetGroup)" on target "arn:aws:elasticloadbalancing:us-east-1:123456789012:targetgroup/testsssss/4e0b6076bc6483a7". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): y
  • Para obter detalhes da API, consulte DeleteTargetGroupem Referência de Ferramentas da AWS para PowerShell cmdlet.

O código de exemplo a seguir mostra como usar Set-ELB2IpAddressType.

Ferramentas para PowerShell

Exemplo 1: Este exemplo altera o tipo de endereço IP do balanceador de carga de 'IPv4' para 'DualStack'.

Set-ELB2IpAddressType -LoadBalancerArn 'arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/app/test-alb/3651b4394dd9a24f' -IpAddressType dualstack

Saída:

Value ----- dualstack
  • Para obter detalhes da API, consulte SetIpAddressTypeem Referência de Ferramentas da AWS para PowerShell cmdlet.

O código de exemplo a seguir mostra como usar Set-ELB2RulePriority.

Ferramentas para PowerShell

Exemplo 1: Esse exemplo altera a prioridade da regra de ouvinte especificada.

Set-ELB2RulePriority -RulePriority -RulePriority @{Priority = 11; RuleArn = 'arn:aws:elasticloadbalancing:us-east-1:123456789012:listener-rule/app/test-alb/3651b4394dd9a24f/a4eb199fa5046f80/dbf4c6dcef3ec6f8'}

Saída:

Actions : {Amazon.ElasticLoadBalancingV2.Model.Action} Conditions : {Amazon.ElasticLoadBalancingV2.Model.RuleCondition} IsDefault : False Priority : 11 RuleArn : arn:aws:elasticloadbalancing:us-east-1:123456789012:listener-rule/app/test-alb/3651b4394dd9a24f/a4eb199fa5046f80/dbf4c6dcef3ec6f8
  • Para obter detalhes da API, consulte SetRulePrioritiesem Referência de Ferramentas da AWS para PowerShell cmdlet.

O código de exemplo a seguir mostra como usar Set-ELB2SecurityGroup.

Ferramentas para PowerShell

Exemplo 1: Este exemplo adiciona o grupo de segurança 'sg-07c3414abb8811cbd' ao balanceador de carga especificado.

Set-ELB2SecurityGroup -LoadBalancerArn 'arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/app/test-alb/3651b4394dd9a24f' -SecurityGroup 'sg-07c3414abb8811cbd'

Saída:

sg-07c3414abb8811cbd
  • Para obter detalhes da API, consulte SetSecurityGroupsem Referência de Ferramentas da AWS para PowerShell cmdlet.

O código de exemplo a seguir mostra como usar Set-ELB2Subnet.

Ferramentas para PowerShell

Exemplo 1: Este exemplo modifica as sub-redes do balanceador de carga especificado.

Set-ELB2Subnet -LoadBalancerArn 'arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/app/test-alb/3651b4394dd9a24f' -Subnet 'subnet-7d8a0a51','subnet-c37a67a6'

Saída:

LoadBalancerAddresses SubnetId ZoneName --------------------- -------- -------- {} subnet-7d8a0a51 us-east-1c {} subnet-c37a67a6 us-east-1b
  • Para obter detalhes da API, consulte SetSubnetsem Referência de Ferramentas da AWS para PowerShell cmdlet.

O código de exemplo a seguir mostra como usar Unregister-ELB2Target.

Ferramentas para PowerShell

Exemplo 1: Este exemplo cancela o registro da instância 'i-0672a4c4cdeae3111' do grupo de destino especificado.

$targetDescription = New-Object Amazon.ElasticLoadBalancingV2.Model.TargetDescription $targetDescription.Id = 'i-0672a4c4cdeae3111' Unregister-ELB2Target -Target $targetDescription -TargetGroupArn 'arn:aws:elasticloadbalancing:us-east-1:123456789012:targetgroup/test-tg/a4e04b3688be1970'
  • Para obter detalhes da API, consulte DeregisterTargetsem Referência de Ferramentas da AWS para PowerShell cmdlet.