AWS:Lambda的CodeDeploy无法读取应用程序规范 [英] AWS: CodeDeploy for Lambda can't read appspec

查看:69
本文介绍了AWS:Lambda的CodeDeploy无法读取应用程序规范的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置CodePipeline来管理非常简单的Lambda函数的部署.

I'm attempting to setup CodePipeline to manage the deployment of a very simple Lambda function.

我完全陷入了部署步骤的问题,无法弄清楚可能出了什么问题.

I'm completely stuck on a problem with the deployment step, and cannot figure out what could be wrong.

当管道尝试运行CodeDeploy操作时,它失败并显示错误...

When the pipeline attempts to run the CodeDeploy action, it fails with the error...

BundleType必须为YAML或JSON

这是我的应用规格...

This is my appspec...

version: 0.0
Resources:
  - my-function:
      Type: AWS::Lambda::Function
      Properties:
        Name: "my-function"

我的管道没有构建步骤,因为它只是一个简单的js文件,没有依赖关系,因此不需要构建.

My pipeline doesn't have a build step, as it's just a simple js file, with no dependencies, so no build is required.

我尝试添加要部署到S3的操作,并且可以确认要发送到s3的zip文件包含appspec.yml和index.js,并且它们都在根目录中.

I've tried adding an action to deploy to S3, and I can confirm that the zip file that's being sent to s3 contains the appspec.yml and index.js and that these are both in the root.

我见过的大多数示例都使用一个buildspec,但是我不确定为什么需要这个,或者如果我有一个,甚至会做什么.

Most of the examples I've seen use a buildspec, but I'm not sure why I would need this, or what it would even do if I had one.

推荐答案

设置没有问题,这是服务的缺陷,您无法在CodePipeline操作中使用CodeDeploy来部署Lambda函数.

There is nothing wrong with your setup, it is a shortcoming of the services that you cannot use CodeDeploy in a CodePipeline action to Deploy a Lambda function.

原因是因为CodeDeploy期望Lambda部署使用JSON或YAML appspec文件,但是当前CodePipeline支持ZIP作为捆绑类型,因此会引发错误.

The reason is because CodeDeploy expects a JSON or YAML appspec file for the Lambda deployment, but currently CodePipeline supports ZIP as a bundle type so the error is thrown.

要解决此问题,客户可以通过CloudFormation部署操作(准确地说是SAM)在CodePipeline中部署Lambda.请参阅有关此推荐方法的本教程:

To workaround, customers deploy Lambda in a CodePipeline is via CloudFormation deploy action (SAM to be exact). Please see this tutorial on this recommended approach:

这篇关于AWS:Lambda的CodeDeploy无法读取应用程序规范的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆