AWS 文档 AWS SDK示例 GitHub 存储库中还有更多SDK示例
本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
ModifyRule
与 a 一起使用 CLI
以下代码示例演示如何使用 ModifyRule
。
- CLI
-
- AWS CLI
-
修改规则
以下
modify-rule
示例更新了指定规则的操作和条件。aws elbv2 modify-rule \ --actions
Type=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/9683b2d02a6cabee
输出:
{ "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" } ] } ] }
-
有关API详细信息,请参阅 “ModifyRule AWS CLI
命令参考”。
-
- PowerShell
-
- 用于 PowerShell
-
示例 1:此示例修改了指定的监听器规则配置。
$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
输出:
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
-
有关API详细信息,请参阅 AWS Tools for PowerShell Cmdlet 参考ModifyRule中的。
-
ModifyLoadBalancerAttributes
ModifyTargetGroup