我使用 CloudFormation 创建了一个 AWS::CloudFront::Function(此处为模板)。然后我尝试按照 LambdaFunctionAssociation 文档 :
与发行版关联DistributionConfig:
DefaultCacheBehavior:
LambdaFunctionAssociations:
EventType: viewer-request
LambdaFunctionARN: !GetAtt Function_Logical_ID.FunctionMetadata.FunctionARN
我收到以下错误:
Invalid request provided: The function ARN must reference a specific function version. (The ARN must end with the version number.)
如何使用 CloudFormation 关联 CloudFront Function?
我的错误是我使用了
LambdaFunctionAssociations
而不是FunctionAssociations
(文档在这里):
FunctionAssociations
用于 CloudFront 功能;LambdaFunctionAssociations
适用于 Lambda@Edge。然后我改成下面的模板,它起作用了:
DistributionConfig:
DefaultCacheBehavior:
FunctionAssociations:
EventType: viewer-request
FunctionARN: !GetAtt Function_Logical_ID.FunctionMetadata.FunctionARN