【发布时间】:2020-05-15 02:56:27
【问题描述】:
我想要做的是仅在 Beanstalk 环境名称为“prod”或“prod-2”时添加 ALB ListenerRule。如果 Beanstalk 环境名称不同,我将跳过此资源并继续而不创建它。
这是我的 .ebextensions/00-testing-condition.config :
"Conditions" : {
"createRedirect" : {"Fn::Or" : [ {"Fn::Equals" : [{"Ref" : "AWSEBEnvironmentName"}, "prod"]}, {"Fn::Equals" : [{"Ref" : "AWSEBEnvironmentName"}, "prod-2"]} ]}
}
Resources:
ALBListenerSSLRule:
Condition: createRedirect
Type: AWS::ElasticLoadBalancingV2::ListenerRule
Properties:
Actions:
- RedirectConfig:
Host: "#{host}"
Path: "/#{path}"
Port: 443
Protocol: "HTTPS"
Query: "#{query}"
StatusCode: HTTP_301
Type: "redirect"
Conditions:
- Field: host-header
Values:
- "MYDOMAINNAME.com"
ListenerArn:
Ref: AWSEBV2LoadBalancerListener
Priority: 1
因此:如果环境名称为 prod 或 prod-2 且没有任何问题,则会创建 ListenerRule。但是,如果名称不同(因此该语句为假),我会在 Beanstalk 中收到以下错误:
Service:AmazonCloudFormation, Message:Template format error: Unresolved resource dependencies [ALBListenerSSLRule] in the Resources block of the template
关于什么是错的任何想法?
【问题讨论】:
标签: amazon-web-services amazon-elastic-beanstalk amazon-cloudformation