You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AWS CLI创建ELB监听器规则报--conditions参数解析错误

错误原因

aws elbv2 create-rule 命令的--conditions和--actions都属于结构化参数,不支持直接传入裸字符串、裸ARN值。当前写法直接把域名test.com传给--conditions、把目标组ARN直接传给--actions,CLI在解析结构化参数时默认需要读取键=值格式的内容,找不到=分隔符时就会抛出「期待输入'=',收到EOF结束符」的解析错误。

正确配置方式

配置Host头匹配的转发规则时,两个结构化参数需要按AWS规定的简写语法或JSON结构传值:

  • --conditions:明确指定匹配字段为host-header,再传入要匹配的域名值列表
  • --actions:明确指定动作类型为forward,再传入目标组ARN

修正后的可执行命令如下:

aws elbv2 create-rule \
--listener-arn arn:aws:elasticloadbalancing:ap-south-1:123456789:listener/app/testing-alb/6sdfgsgs5fg45s4fg5sd \
--conditions Field=host-header,Values='test.com' \
--priority 5 \
--actions Type=forward,TargetGroupArn=arn:aws:elasticloadbalancing:ap-south-1:123456789:targetgroup/tgtest-1/hsdjif444225 \
--region ap-south-1 \
--output json

补充说明

  • 如果需要同时匹配多个域名,在Values中用逗号分隔即可,例如Values='test.com,www.test.com'
  • 如果对简写语法不熟悉,也可以直接传入JSON格式的参数值,例如--conditions '[{"Field":"host-header","Values":["test.com"]}]',--actions同理传入对应JSON数组即可
  • 包含特殊字符的参数值建议用单引号包裹,避免被Shell提前转义导致解析异常

内容的提问来源于stack exchange,提问作者Praveen Sivakumar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.29 20:09:11