Buildspec.yaml 用于 aws 代码管道中的无服务器框架

Buildspec.yaml for serverless framework in aws code pipleline

我正在尝试 CI/CD 无服务器框架的管道。

我已经为 SAM 框架做了类似的事情并且让它工作了。 SAM框架有打包和部署两个步骤(部署由cloudformation actions处理)

version: 0.2
phases:
  install:
    runtime-versions:
        nodejs: 10
        #trying after adding the art effect in code deploy  
  build:
    commands:
      - npm install time
      - export BUCKET=lambda-loadeo-git
      - aws cloudformation package --template-file template.yml --s3-bucket $BUCKET --output-template-file outputtemplate.yml
artifacts:
  type: zip
  files:
    - template.yml
    - outputtemplate.yml

但我不太确定无服务器应该如何工作。 我知道无服务器只有 'deploy' 阶段,没有包和所有。

我不知道 CI/CD 中的无服务器部署是如何处理的。在无服务器部署命令中出现错误。

这是我的 buildspec.yaml 文件

version: 0.1
phases:
  install:
    commands:
      - npm install
      - npm install -g mocha
      - npm install -g serverless
  build:
    commands:
      - serverless deploy 
  post_build:
    commands:

      - echo build complete

正在尝试部署此模板:

service: serverless
frameworkVersion: '2'

provider:
  name: aws
  runtime: python2.7
  profile: default 


functions:
  getInfo:
    handler: handler.getInfo
    events:
     - http:
        path: users/info
        method: get

  createInfo:
    handler: handlerpost.createInfo
    events:
     - http:
        path: users/create
        method: post

  patchInfo:
    handler: handlerpatch.patchInfo
    events:
     - http:
        path: users/update
        method: patch

谁能帮我构建和部署其中的一部分?

基于评论和聊天讨论。

几个问题导致了问题:

  1. 失踪 serverless.yml。通过将 template.yml 重命名为 serverless.yml.
  2. 解决了这个问题
  3. 无服务器提供程序中的配置文件错误。此问题已通过移除得到解决。
  4. CodeBuild 角色中缺少权限。这已通过向角色添加代码形成、s3 和 cloudwatch 日志权限得到纠正。