1

我正在开发一个项目,我必须使用无服务器框架来部署带有 lambda 解析器的 AppSync。我的无服务器 YAML 文件如下所示。

service: sls-appsync-backend

plugins:
   - serverless-appsync-plugin
   - serverless-offline
   - serverless-pseudo-parameters

provider:
  name: aws
  runtime: nodejs12.x
  region: ap-southeast-2

functions:
  graphql:
    handler: src/handler.graphql

custom:
  accountId: #{AWS::AccountId}
  appSync:
    name: sls-appsync-api
    authenticationType: AMAZON_COGNITO_USER_POOLS
    userPoolConfig:
      awsRegion:  us-east-1
      defaultAction: ALLOW
      userPoolId:  { Ref: CognitoUserPool } 
    mappingTemplates:
      - dataSource: awsLambdaDataSource
        type: Query #Query, Mutation, Subscription
        field: helloWorld
        request: "helloWorld-request-mapping-template.txt"
        response: "helloWorld-response-mapping-template.txt"
    schema: # defaults schema.graphql
    serviceRole: "AppSyncServiceRole"
    dataSources:
      - type: AWS_LAMBDA
        name: awsLambdaDataSource
        description: 'Lambda DataSource'
        config:
          lambdaFunctionArn: { Fn::GetAtt: [GraphqlLambdaFunction, Arn] } # Where GraphqlLambdaFunction is the lambda function cloudformation resource created by serverless for the serverless function named graphql
          serviceRoleArn: { Fn::GetAtt: [AppSyncLambdaServiceRole, Arn] }

我想在我的本地机器上运行它以进行调试和测试。我被困在这里,有人可以帮忙吗?

4

0 回答 0