属性 Cloudformation 验证失败
Property validation failure in Cloudformation
以下代码段来自 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}]
请问我哪里出错了?
在代码的 - !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
...
以下代码段来自 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}]
请问我哪里出错了?
在代码的 - !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
...