问题描述
我只需要使用 CloudFormation 创建一个 TargetGroup 和 ListenerRule,但我收到错误。
我的 CloudFormation:
TargetGroup:
Type: AWS::ElasticLoadBalancingV2::TargetGroup
Properties:
Name: !Sub ${StackName}-alb
VpcId: !Ref VpcId
Port: !Ref ContainerPort
Protocol: HTTP
Matcher:
HttpCode: 200
HealthCheckIntervalSeconds: 10
HealthCheckPath: !Ref HealthCheckPath
HealthCheckProtocol: HTTP
HealthCheckTimeoutSeconds: 5
HealthyThresholdCount: 2
targettype: ip
TargetGroupAttributes:
- Key: deregistration_delay.timeout_seconds
Value: 30
ListenerRule:
Type: AWS::ElasticLoadBalancingV2::ListenerRule
DependsOn:
- TargetGroup
Properties:
Actions:
- Type: forward
TargetGroupArn: !Ref TargetGroup
Conditions:
- Field: host-header
Values:
- "www.mydominian.*"
ListenerArn: !Ref ListenerArn
Priority: 164
Invalid request provided 所以,错误是图像
解决方法
AWS::StackName
看起来好像缺少 AWS::
前缀
建议尝试使用 CloudFormation Linter 中的 VSCode 在创作模板以及自动完成和文档链接时内联查看其中一些错误:
[cfn-lint] E1019: Parameter StackName for Fn::Sub not found at Resources/TargetGroup/Properties/Name/Fn::Sub