amazon-web-services - 用于 aws 代码管道中的无服务器框架的 Buildspec.yaml
问题描述
我正在尝试使用无服务器框架的 CI/CD 管道。
我为 SAM 框架做了类似的事情并让它工作。SAM框架有打包和部署两个步骤(部署由cloudformation操作处理)
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
但我不太确定无服务器应该如何工作。我知道无服务器只有“部署”阶段,没有包等等。
我不知道如何在 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
任何人都可以帮助我构建和部署其中的一部分吗?
解决方案
基于评论和聊天讨论。
有几个问题导致问题:
- 失踪
serverless.yml
。通过重命名template.yml
为serverless.yml
. - 无服务器提供商中的配置文件错误。已通过将其删除来解决。
- CodeBuild 角色中缺少权限。这已通过向角色添加 codeformation、s3 和 cloudwatch 日志权限得到纠正。
推荐阅读
- for-loop - 如何使这个 for 循环在 Dart 中正常工作?
- reactjs - 反应构建一次并在任何地方部署可配置的 URL
- java - 你如何检查一个单词是否有一个回文的字谜?
- azure - 关于 Microsoft Teams 选项卡中的隐式授权流程和 ID/访问令牌处理的说明
- docker - Docker 似乎无法识别我的 daemon.json 文件
- python - 清理 JSON 并导出到 JSONL 的挑战
- latex - 引文、表格和方程式超出投影仪中的页面宽度
- apache-spark - 通过 PySpark 获取 S3 中的最新文件
- python - 使用时间索引帧屏蔽 DatetimeIndex DataFrame
- java - 对 By/BySelector 使用 Optional 进行空检查