AWS :: Serverless :: Lambda @ Edge事件处理程序的功能lambda版本

问题描述 投票:0回答:1

我正在尝试使用AWS SAM框架创建一个lambda用作CloudFront事件处理程序。似乎AWS::Serverless::Function不支持Version属性。我看到的错误:

com.amazonaws.services.cloudfront.model.InvalidLambdaFunctionAssociationException: The function ARN must reference a specific function version. (The ARN must end with the version number.)

我发现this answer促使我尝试了。我的CloudFormation YAML文件的相关部分:

Resources:
  CloudFrontFunction:
    Type: AWS::Serverless::Function 
    Properties:
      CodeUri: cloudfront-handler/hello_world/
      Handler: app.lambda_handler
      Runtime: python3.7

Outputs:
  CloudFrontFunctionArn: 
      Description: CloudFront Function ARN with Version
      Value: !Join [':', [!GetAtt CloudFrontFunction.Arn, !GetAtt CloudFrontFunction.Version]]

当我sam deploy时出现以下错误。

Waiting for changeset to be created..
Error: Failed to create changeset for the stack: my-sam-app, ex: Waiter ChangeSetCreateComplete failed: Waiter encountered a terminal failure state Status: FAILED. Reason: Template error: resource CloudFrontFunction does not support attribute type Version in Fn::GetAtt

AWS::Lambda::Function上可用的属性为documented here,并将Version列为属性之一。因此,似乎AWS::Serverless::Function不支持获取版本。如何解决此问题,以便部署使用AWS SAM框架实现的CloudFront事件处理程序?

amazon-web-services amazon-cloudformation amazon-cloudfront aws-sam
1个回答
0
投票

默认情况下,该功能将自动部署版本。相反,您将需要指定AutoPublishAlias属性。

更多可用信息here

© www.soinside.com 2019 - 2024. All rights reserved.