【问题标题】:Property validation failure in CloudformationCloudformation 中的属性验证失败
【发布时间】:2020-06-03 23:57:29
【问题描述】:

以下 sn-p 来自 Cloudformation 形成模板:

...
LambdaFunctionAssociations:
  - !If
    - ProtectDistribution
    -
      - EventType: viewer-request
        LambdaFunctionARN: !GetAtt LambdaEdgeProtection.Outputs.CheckAuthHandler
      - EventType: origin-response
        LambdaFunctionARN: !GetAtt LambdaEdgeProtection.Outputs.HttpHeadersHandler
    - !Ref AWS::NoValue
...

它是 CloudFront 分配的 DistributionConfig 内的 DefaultCacheBehavior 的一部分。尝试创建堆栈时出现此错误:

Property validation failure: [Value of property {/DistributionConfig/DefaultCacheBehavior/LambdaFunctionAssociations/0} does not match type {Object}]

请问我哪里出错了?

【问题讨论】:

    标签: amazon-web-services amazon-cloudformation amazon-cloudfront


    【解决方案1】:

    在代码的- !If 条件中,您已经在 if 条件之前声明了数组,如果条件为真,- - EventType: viewer-request 在这里您再次提供数组,这是错误的。 你应该这样试试,

    ...
    LambdaFunctionAssociations:
      - !If
        - ProtectDistribution
        - EventType: viewer-request
          LambdaFunctionARN: !GetAtt LambdaEdgeProtection.Outputs.CheckAuthHandler
        - !Ref AWS::NoValue
      - !If
        - ProtectDistribution
        - EventType: origin-response
          LambdaFunctionARN: !GetAtt LambdaEdgeProtection.Outputs.HttpHeadersHandler
        - !Ref AWS::NoValue 
    ...
    

    【讨论】:

      猜你喜欢
      • 2019-11-02
      • 2019-04-23
      • 2021-04-16
      • 2020-09-20
      • 2021-05-31
      • 2012-05-31
      • 2021-12-06
      • 2020-08-17
      • 1970-01-01
      相关资源
      最近更新 更多