我正在尝试使用Cloudformation SAM堆栈设置AWS Codepipeline,该堆栈部署到Lambda并通过Pipeline控制台执行此操作 . 管道从Codecommit流程传递克隆,而使用Codebuild构建流程,但在使用Cloudformation进行部署时失败 .
我收到以下错误消息:
Action execution failed Invalid TemplatePath: MyAppBuild::samTemplate.yml
我一直在密切关注文档(http://docs.aws.amazon.com/lambda/latest/dg/automating-deployment.html),并且在codepipeline设置表单(模板文件)的字段16中,我一直在放samTemplate.yml .
我的repo的根目录中也有samTemplate.yml(它也是项目的根目录) .
我已将Codebuild输出工件名称与Cloudformation输入工件名称进行匹配,并且它们完全匹配 .
我在这里错过了什么吗?如何让Cloudformation部署过程识别sam模板?
EDIT 1 我've switched to using Codestar instead of directly using CodePipeline. Nothing special in my buildspec.yml, but it' s如果有人有兴趣的话 .
version: 0.2
phases:
install:
commands:
- echo "install"
pre_build:
commands:
- echo "pre_build"
build:
commands:
- aws cloudformation package --template template.yml --s3-bucket $S3_BUCKET --output-template template-export.json
artifacts:
type: zip
files:
- template-export.json
对于任何刚接触CodeBuild的人来说,要记住的一件事是,作为结果创建的zip文件是构建操作的根级目录,而IS文件是转移到最终部署的zip文件(在我的例子中,Lambda) .
3 回答
我相信构建阶段的输出是需要传递到CloudFormation操作的内容 .
在本教程中,构建输出称为
NewSamTemplate.yaml
因此,请尝试将TemplatePath更新为
MyAppBuild::NewSamTemplate.yml
您需要在buildspec.yml中添加aws cloudformation package命令 .
其中YourSamTemplate.yml是项目根目录中samTemplate.yml的名称 . 和YourOutputSamTemplate.yml是在 Cloud 形成包命令完成后你想要输出文件的新名称 .
然后在下一个阶段,您需要将输入工件定义为aws codebuild阶段的输出,然后使用此输入工件来映射模板 .
就我而言,错误在文件名中 . 而不是
template.yml
实际文件是template.yaml