【问题标题】:Beanstalk .ebextensions Error - Unresolved resource dependencies in the Resources block of the templateBeanstalk .ebextensions 错误 - 模板的资源块中未解决的资源依赖关系
【发布时间】: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


    【解决方案1】:

    条件在 Beanstalk 中似乎没有按预期工作。 因此,我最终为每个环境设置了域名和重定向,并使用 Beanstalk 中的环境属性(变量)添加了这个资源:

    Resources:
        ALBListenerSSLRule:
            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:
                - "Fn::GetOptionSetting":
                      Namespace: "aws:elasticbeanstalk:application:environment"
                      OptionName: "ENV_DOMAIN_NAME"
                      DefaultValue: {"Ref":"AWS::NoValue"}
              ListenerArn:
                  Ref: AWSEBV2LoadBalancerListener
              Priority: 1
    

    【讨论】:

      猜你喜欢
      • 2020-10-22
      • 2018-11-14
      • 1970-01-01
      • 2020-03-30
      • 1970-01-01
      • 2019-03-28
      • 2020-03-25
      • 1970-01-01
      • 2020-01-10
      相关资源
      最近更新 更多