aws-lambda - AWS lambda SAM 部署错误 - 模板格式错误 : Unresolved resource dependencies

标签 aws-lambda ffmpeg aws-sam-cli

我正在尝试使用 SAM cli 部署 aws lambda 函数。我在 sam 模板中定义了一些层。使用 sam local start-api 进行本地测试效果很好。但是使用 sam deploy --guided 命令进行部署会引发以下错误Error: Failed to create changeset for the stack: sam-app, ex: Waiter ChangeSetCreateComplete failed: Waiter encountered a terminal failure state: For expression "Status" we matched expected path: "FAILED" Status: FAILED. Reason: Template format error: Unresolved resource dependencies [arn:aws:lambda:us-west-1:338231645678:layer:ffmpeg:1] in the Resources block of the templateSAM模板如下

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
  video-processor-functions

  Functions to generate gif and thumbnail from uploaded videos
  
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
  Function:
    Timeout: 3
    Tracing: Active

Resources:
  VideoProcessorFunctions:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      CodeUri: src/
      Handler: app.lambdaHandler
      Runtime: nodejs14.x
      # timeout in seconds - 2 minutes
      Timeout: 120
      Layers:
        - !Ref VideoProcessorDepLayer
        - !Ref arn:aws:lambda:us-west-1:338231645678:layer:ffmpeg:1
      Architectures:
        - x86_64
      Events:
        HelloWorld:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            Path: /hello
            Method: get

  VideoProcessorDepLayer:
    Type: AWS::Serverless::LayerVersion
    Properties:
      LayerName: mh-video-processor-dependencies
      Description: Dependencies for sam app [video-processor-functions]
      ContentUri: dependencies/
      CompatibleRuntimes:
        - nodejs14.17
      LicenseInfo: 'MIT'
      RetentionPolicy: Retain

Outputs:
  # ServerlessRestApi is an implicit API created out of Events key under Serverless::Function
  # Find out more about other implicit resources you can reference within SAM
  # https://github.com/awslabs/serverless-application-model/blob/master/docs/internals/generated_resources.rst#api
  HelloWorldApi:
    Description: "API Gateway endpoint URL for Prod stage for Hello World function"
    Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/hello/"
  VideoProcessorFunctions:
    Description: "Generate GIF and Thumnail from Video"
    Value: !GetAtt VideoProcessorFunctions.Arn
  VideoProcessorFunctionsIamRole:
    Description: "Implicit IAM Role created for MH Video Processor function"
    Value: !GetAtt VideoProcessorFunctionsRole.Arn

任何想法我做错了什么?

最佳答案

您正在尝试引用一个不存在的逻辑 ID。
只需将图层的'ffmpeg'的ARN:

Layers:
    - !Ref VideoProcessorDepLayer
    - arn:aws:lambda:us-west-1:338231645678:layer:ffmpeg:1

关于aws-lambda - AWS lambda SAM 部署错误 - 模板格式错误 : Unresolved resource dependencies,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72454265/

相关文章:

javascript - 停止或终止 Node 媒体服务器

amazon-web-services - SAM 模板 - 使用现有 Cognito 用户池的 API 授权者

amazon-web-services - 通过 intellij 插件将 Lambda 更新到 AWS

amazon-web-services - 无法在 Docker 下运行 AWS SAM CLI

python - 如何更改 AWS 中 API 授权方的错误消息?

amazon-web-services - 每个路由具有1个Lambda函数更好吗?或1个处理子路线的Lambda?

ios - 如何在iOS的AWS Lambda中发送请求 header 数据

php - ffmpeg 无法初始化模块 windows 7 32 位

ffmpeg - 当输入是实时相机设备时,使用输入帧率选项(在 FFmpeg 中)时的预期行为是什么?

python - AWS lambda CLI 'update-function-code' 不更新 lambda_handler 文件