Vitaliy
Vitaliy

Reputation: 3

serverless-appsync-plugin 'pipeline' deployment error

I am using serverless to deploy an Appsync API using 'PIPELINE', for use as an API lambda-functions. This plugin https://github.com/sid88in/serverless-appsync-plugin is used to deploy Appsync with the ability to use 'pipeline'. I used the description from the documentation however when I try to do deploy it in myself I have an error: Error: The CloudFormation template is invalid: Template error: instance of Fn::GetAtt references undefined resource 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'

Could somebody help me to configure 'serverless-appsync-plugin ' with pipeline kind?

Upvotes: 0

Views: 440

Answers (1)

sashko
sashko

Reputation: 1682

You need to specify the data source used in your function.

It seems you've deployed the handler as Lambda function. If not, first you should have a separate serverless.yml config for your Lambda and deploy it. Then you need to attach this Lambda as AppSync data source, so your AppSync config would look like this:

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'

There is an article which describes the process in details that might be useful: https://medium.com/hackernoon/running-a-scalable-reliable-graphql-endpoint-with-serverless-24c3bb5acb43

Upvotes: 1

Related Questions