【问题标题】:The specified provider "google" does not exist指定的提供商“google”不存在
【发布时间】:2020-02-05 11:22:41
【问题描述】:

我正在尝试建立一个将托管在 Google 云平台上的无服务器项目。这是serverless.yml 的样子

plugins: # List of plugins of use on application
    - serverless-offline # Get your serverless configuration and run the server local
    - serverless-plugin-typescript-express

# Project name on the infrastructure created
service: ansaar-auth

provider:
  name: google # Provider name, where the infrastructure has be created
  runtime: nodejs # The node version where the lambda functions going to run
  project: ansaar-auth
  credentials: ~/.gcloud/auth.json
  # stage: dev # Control the environment of application
  # region: us-east-1 # Default region where the lambda functions running

  functions: # The array with definitions of lambda functions of the your application 
  getUsers: # Lambda function name
    handler: src/server.handler # The function name mapped of the application
    events: # Array of events that call the function
      - http: # Type of event, the http event selected, it's event is a endpoint mapped on api gateway
          path: users
          method: get

凭据设置为according to the docs,但由于某些原因,部署无法正常工作,并且总是抛出以下错误:

Serverless Error ---------------------------------------

  The specified provider "google" does not exist.

有谁知道如何修复它并将项目成功部署到 GCP?

【问题讨论】:

    标签: google-cloud-platform google-cloud-functions serverless-framework


    【解决方案1】:

    如需使用谷歌云功能,请安装serverless-google-cloudfunctions插件。

    您可以使用serverless create --template google-nodejs --path gcp 生成样本serverless.yml

    应该是这样的:

    service: gcp
    
    provider:
      name: google
      stage: dev
      runtime: nodejs8
      region: us-central1
      project: my-project
      # The GCF credentials can be a little tricky to set up. Luckily we've documented this for you here:
      # https://serverless.com/framework/docs/providers/google/guide/credentials/
      #
      # the path to the credentials file needs to be absolute
      credentials: ~/.gcloud/keyfile.json
    
    plugins:
      - serverless-google-cloudfunctions
    
    # needs more granular excluding in production as only the serverless provider npm
    # package should be excluded (and not the whole node_modules directory)
    package:
      exclude:
        - node_modules/**
        - .gitignore
        - .git/**
    
    functions:
      first:
        handler: http
        events:
          - http: path
    

    这是完整的快速入门指南:https://serverless.com/framework/docs/providers/google/guide/quick-start/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-08
      • 1970-01-01
      • 1970-01-01
      • 2012-08-20
      相关资源
      最近更新 更多