I've created an AWS::CloudFront::Function using CloudFormation (template here). Then I've tried to associate with a distribution following the LambdaFunctionAssociation docs:
DistributionConfig:
DefaultCacheBehavior:
LambdaFunctionAssociations:
EventType: viewer-request
LambdaFunctionARN: !GetAtt Function_Logical_ID.FunctionMetadata.FunctionARN
And I get the following error: Invalid request provided: The function ARN must reference a specific function version. (The ARN must end with the version number.)
How to associate a CloudFront Function using CloudFormation?
I've created an AWS::CloudFront::Function using CloudFormation (template here). Then I've tried to associate with a distribution following the LambdaFunctionAssociation docs:
DistributionConfig:
DefaultCacheBehavior:
LambdaFunctionAssociations:
EventType: viewer-request
LambdaFunctionARN: !GetAtt Function_Logical_ID.FunctionMetadata.FunctionARN
And I get the following error: Invalid request provided: The function ARN must reference a specific function version. (The ARN must end with the version number.)
How to associate a CloudFront Function using CloudFormation?
Share Improve this question asked Nov 18, 2024 at 21:26 Pedro ArantesPedro Arantes 5,3695 gold badges29 silver badges64 bronze badges1 Answer
Reset to default 1My mistake was that I was using LambdaFunctionAssociations
instead of FunctionAssociations
(docs here):
FunctionAssociations
are for CloudFront functions;LambdaFunctionAssociations
are for Lambda@Edge.
Then I changed to the template below and it worked:
DistributionConfig:
DefaultCacheBehavior:
FunctionAssociations:
EventType: viewer-request
FunctionARN: !GetAtt Function_Logical_ID.FunctionMetadata.FunctionARN