Cloudformation:ELB 侦听器规则创建失败 "Invalid request provided"
Cloudformation: ELB listener rule creation fails with "Invalid request provided"
我正在尝试建立一个由应用程序负载均衡器、目标组和 ECS 服务组成的小型 Cloudformation 堆栈。但是,堆栈无法创建 WidgetsServiceLbListenerRule
资源并出现以下错误:
"Invalid request provided: AWS::ElasticLoadBalancingV2::ListenerRule Validation exception" (RequestToken: 98057bbb-ad4f-5f09-3e89-cc6b645c6e7f, HandlerErrorCode: InvalidRequest)
为什么监听器规则创建失败?
这里是相关的堆栈代码:
Resources:
# The load balancer
Lb:
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
Properties:
Name: !Join ['', [!Ref Env, '-rest-api-lb-rev', !Ref Rev]]
Scheme: internet-facing
SecurityGroups:
- !Ref LbSg
Subnets:
- Fn::ImportValue: !Sub "${VpcStackName}-PubSubnet1Id"
- Fn::ImportValue: !Sub "${VpcStackName}-PubSubnet2Id"
- Fn::ImportValue: !Sub "${VpcStackName}-PubSubnet3Id"
Type: application
LbListener:
Type: AWS::ElasticLoadBalancingV2::Listener
Properties:
DefaultActions:
- Type: fixed-response
FixedResponseConfig:
ContentType: text/plain
MessageBody: The specified route doesn't exist
StatusCode: 404
LoadBalancerArn: !Ref Lb
Port: 80
Protocol: HTTP
# Widgets service
WidgetsServiceLbTargetGroup:
Type: AWS::ElasticLoadBalancingV2::TargetGroup
Properties:
HealthCheckPath: /actuator/health
Name: !Join ['', [!Ref Env, '-widgets-rev', !Ref Rev]]
Port: 80
Protocol: HTTP
VpcId:
Fn::ImportValue: !Sub "${VpcStackName}-VpcId"
# THIS ONE FAILS TO CREATE
WidgetsServiceLbListenerRule:
Type: AWS::ElasticLoadBalancingV2::ListenerRule
Properties:
Actions:
- Type: forward
TargetGroupArn: !Ref WidgetsServiceLbTargetGroup
Conditions:
- Field: path-pattern
Values:
- '/widgets*'
ListenerArn: Ref !LbListener
Priority: 1
<ECS service and other assets omitted for brevity>
更多信息
- 我们的 AWS 帐户中有几个现有堆栈,它们使用几乎完全相同的代码。这些和这个之间没有任何有意义的区别,它们工作正常。
- 我创建了一个没有
WidgetsServiceLbListenerRule
的堆栈,然后尝试将其作为更改集添加回去。这也产生了同样的错误。
- 我能够使用以下 AWS CLI 命令成功创建规则:
aws --profile clexp elbv2 create-rule --listener-arn <arn> --priority 1 --conditions file://conditions.json --actions file://actions.json
conditions.json:
[{"Type": "forward","TargetGroupArn": "<arn>"}]
actions.json:
[{"Field": "path-pattern","Values": ["/widgets*"]}]
非常感谢任何帮助。
而不是:
ListenerArn: Ref !LbListener
应该是:
ListenerArn: !Ref LbListener
我正在尝试建立一个由应用程序负载均衡器、目标组和 ECS 服务组成的小型 Cloudformation 堆栈。但是,堆栈无法创建 WidgetsServiceLbListenerRule
资源并出现以下错误:
"Invalid request provided: AWS::ElasticLoadBalancingV2::ListenerRule Validation exception" (RequestToken: 98057bbb-ad4f-5f09-3e89-cc6b645c6e7f, HandlerErrorCode: InvalidRequest)
为什么监听器规则创建失败?
这里是相关的堆栈代码:
Resources:
# The load balancer
Lb:
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
Properties:
Name: !Join ['', [!Ref Env, '-rest-api-lb-rev', !Ref Rev]]
Scheme: internet-facing
SecurityGroups:
- !Ref LbSg
Subnets:
- Fn::ImportValue: !Sub "${VpcStackName}-PubSubnet1Id"
- Fn::ImportValue: !Sub "${VpcStackName}-PubSubnet2Id"
- Fn::ImportValue: !Sub "${VpcStackName}-PubSubnet3Id"
Type: application
LbListener:
Type: AWS::ElasticLoadBalancingV2::Listener
Properties:
DefaultActions:
- Type: fixed-response
FixedResponseConfig:
ContentType: text/plain
MessageBody: The specified route doesn't exist
StatusCode: 404
LoadBalancerArn: !Ref Lb
Port: 80
Protocol: HTTP
# Widgets service
WidgetsServiceLbTargetGroup:
Type: AWS::ElasticLoadBalancingV2::TargetGroup
Properties:
HealthCheckPath: /actuator/health
Name: !Join ['', [!Ref Env, '-widgets-rev', !Ref Rev]]
Port: 80
Protocol: HTTP
VpcId:
Fn::ImportValue: !Sub "${VpcStackName}-VpcId"
# THIS ONE FAILS TO CREATE
WidgetsServiceLbListenerRule:
Type: AWS::ElasticLoadBalancingV2::ListenerRule
Properties:
Actions:
- Type: forward
TargetGroupArn: !Ref WidgetsServiceLbTargetGroup
Conditions:
- Field: path-pattern
Values:
- '/widgets*'
ListenerArn: Ref !LbListener
Priority: 1
<ECS service and other assets omitted for brevity>
更多信息
- 我们的 AWS 帐户中有几个现有堆栈,它们使用几乎完全相同的代码。这些和这个之间没有任何有意义的区别,它们工作正常。
- 我创建了一个没有
WidgetsServiceLbListenerRule
的堆栈,然后尝试将其作为更改集添加回去。这也产生了同样的错误。 - 我能够使用以下 AWS CLI 命令成功创建规则:
aws --profile clexp elbv2 create-rule --listener-arn <arn> --priority 1 --conditions file://conditions.json --actions file://actions.json
conditions.json:
[{"Type": "forward","TargetGroupArn": "<arn>"}]
actions.json:
[{"Field": "path-pattern","Values": ["/widgets*"]}]
非常感谢任何帮助。
而不是:
ListenerArn: Ref !LbListener
应该是:
ListenerArn: !Ref LbListener