validation - 调试 CloudFormation 验证问题

标签 validation debugging aws-cloudformation

我正在使用 linter 并且我的模板显示有效,但我的部署失败并出现“AWS::ElasticLoadBalancingV2::ListenerRule 验证异常”。 Cloud Formation 控制台中似乎没有任何地方可以进一步深入了解此异常。如何确定我的部署无效的原因?


云形成模板

Parameters:
  Env:
    Type: String

Mappings:
  EnvMap:
    sandbox:
      ...

Resources:
  HttpsListener:
    Type: AWS::ElasticLoadBalancingV2::Listener
    Properties:
      Certificates:
        - CertificateArn: !FindInMap [EnvMap, !Ref Env, CertificateArn]
      DefaultActions:
        - Type: forward
          ForwardConfig:
            # TODO: read all this stuff off HTTP listener
            TargetGroupStickinessConfig:
              Enabled: false
            TargetGroups:
              - TargetGroupArn:
                  !FindInMap [EnvMap, !Ref Env, LoadBalancerDefaultTargetArn]
                Weight: 1
          TargetGroupArn:
            !FindInMap [EnvMap, !Ref Env, LoadBalancerDefaultTargetArn]
      LoadBalancerArn: !FindInMap [EnvMap, !Ref Env, LoadBalancerArn]
      Port: 443
      Protocol: HTTPS

  HttpsListenerRule:
    Type: AWS::ElasticLoadBalancingV2::ListenerRule
    Properties:
      Actions:
        - Type: forward
          ForwardConfig:
            TargetGroupStickinessConfig:
              Enabled: false
            TargetGroups:
              - TargetGroupArn:
                  !FindInMap [EnvMap, !Ref Env, LoadBalancerRouteTargetArn]
                Weight: 1
          TargetGroupArn:
            !FindInMap [EnvMap, !Ref Env, LoadBalancerRouteTargetArn]
      Conditions:
        - Field: path-pattern
          PathPatternConfig:
            Values:
              - /*
          Values:
            - /*
      ListenerArn: !Ref HttpsListener
      Priority: 50000

错误

事件中的“状态原因”。

Resource handler returned message: "Invalid request provided: AWS::ElasticLoadBalancingV2::ListenerRule Validation exception" (RequestToken: 16bd4239-0d41-b16f-2963-b0a774009dfd, HandlerErrorCode: InvalidRequest)

最佳答案

尝试从 Conditions 键中删除 PathConfigPattern:

HttpsListenerRule:
  Type: AWS::ElasticLoadBalancingV2::ListenerRule
  Properties:
    Actions:
      - Type: "forward"
        ForwardConfig:
          TargetGroupStickinessConfig:
            Enabled: false
          TargetGroups:
            - TargetGroupArn: !FindInMap [ EnvMap, !Ref Env, LoadBalancerRouteTargetArn ]
              Weight: 1
        TargetGroupArn: !FindInMap [ EnvMap, !Ref Env, LoadBalancerRouteTargetArn ]
        Order: 1
    Conditions:
      - Field: path-pattern
        Values:
          - "/*"
    ListenerArn: !Ref HttpsListener
    Priority: 50000

此外,请确保您的 EnvMap map 如下所示:

Parameters:
  Env:
    Type: String
    Default: sandbox

Mappings:
  EnvMap:
    sandbox:
      LoadBalancerRouteTargetArn: "arn:aws:elasticloadbalancing:eu-west-1:111111111111:targetgroup/my-tg-1/222222222222"
    prod:
      LoadBalancerRouteTargetArn: "arn:aws:elasticloadbalancing:eu-west-1:333333333333:targetgroup/my-tg-2/444444444444"

关于validation - 调试 CloudFormation 验证问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70040373/

相关文章:

c# - 服务器和客户端验证差异增加了额外的跨度

javascript - 使用 jquery 表单验证进行密码验证 jquery.form-validator.js

python - 使用 IPython 调试时变量为某个值时中断?

ios - 在 swift 中使用新的 Podfile 时如何忽略警告?

amazon-web-services - 如何在 AWS CloudFormation 中使用 sub 进行参数化?

forms - 在 CodeIgniter 上,如何仅使用正确的值重新填充表单?

.net - .net 验证器失败后调用 javascript

Android Studio 调试器启动/加载时间过长

amazon-web-services - CICD 的 AWS API Gateway 动态 StageName

amazon-web-services - 在 AWS Cloudformation 中,我收到类似 "Parameters of resource [ABC] don' t 与嵌套堆栈的实际参数匹配的错误