serverless-appsync-plugin“管道”部署错误

问题描述

我正在使用无服务器来使用“ PIPELINE”部署Appsync API,以用作API lambda函数。该插件https://github.com/sid88in/serverless-appsync-plugin用于部署具有“管道”功能的Appsync。我使用了文档中的描述,但是当我尝试在自己中进行部署时出现错误错误:CloudFormation模板无效:模板错误:Fn :: GetAtt实例引用了未定义的资源GraphQlDsmeInfo

functions:
  graphlql:
    handler: handler.meInfo
    name: meInfo

custom:
  accountId: testId
  appSync:
    name:  test-AppSync
    authenticationType: API_KEY
    mappingTemplates:
      - type: Query
        field: meInfo
        request: 'meInfo-request-mapping-template.vtl'
        response: 'meInfo-response-mapping-template.vtl'
        kind: PIPELINE
        functions:
          - meInfo
    functionConfigurations:
      - dataSource: meInfo
        name: 'meInfo'
        request: 'meInfo-request-mapping-template.vtl'
        response: 'meInfo-response-mapping-template.vtl'

有人可以帮我用管道类型配置'serverless-appsync-plugin'吗?

解决方法

您需要指定函数中使用的data source

似乎您已将处理程序部署为Lambda函数。如果没有,首先您应该为Lambda配置一个单独的serverless.yml配置并进行部署。然后,您需要将此Lambda附加为AppSync数据源,以便您的AppSync配置如下所示:

custom:
  accountId: testId
  appSync:
    name:  test-AppSync
    authenticationType: API_KEY
    dataSources:
      - type: AWS_LAMBDA
        name: Lambda_Name
        description: 'Lambda Description'
        config:
          lambdaFunctionArn: 'arn:aws:lambda:xxxx'
          serviceRoleArn: 'arn:aws:iam::xxxx'
    mappingTemplates:
      - type: Query
        field: meInfo
        request: 'meInfo-request-mapping-template.vtl'
        response: 'meInfo-response-mapping-template.vtl'
        kind: PIPELINE
        functions:
          - meInfo
    functionConfigurations:
      - dataSource: Lambda_Name
        name: 'meInfo'
        request: 'meInfo-request-mapping-template.vtl'
        response: 'meInfo-response-mapping-template.vtl'

有一篇文章详细描述了该过程,可能会有用:https://medium.com/hackernoon/running-a-scalable-reliable-graphql-endpoint-with-serverless-24c3bb5acb43