CodePipeline 无法找到 SAM 模板 yaml 文件
CodePipeline unable to locate SAM template yaml file
我正在尝试使用部署到 Lambda 的 Cloudformation SAM 堆栈设置 AWS Codepipeline,并通过管道控制台执行此操作。管道通过 Codecommit 过程中的克隆和使用 Codebuild 的构建过程,但是在使用 Cloudformation 进行部署时失败。
我收到以下错误消息:
Action execution failed
Invalid TemplatePath: MyAppBuild::samTemplate.yml
我一直在密切关注文档 (http://docs.aws.amazon.com/lambda/latest/dg/automating-deployment.html),在代码管道设置表单(模板文件)的字段 16 中,我一直在 samTemplate.yml.
我的 repo 的根目录(也是项目的根目录)中也有 samTemplate.yml。
我已将 Codebuild 输出工件名称与 Cloudformation 输入工件名称匹配,它们完全匹配。
我是不是漏掉了什么?如何让 Cloudformation 部署过程识别 sam 模板?
编辑 1 我已经改用 Codestar 而不是直接使用 CodePipeline。我的 buildspec.yml 没什么特别的,但如果有人感兴趣,它在下面。
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 文件是构建操作的根级目录,是传输到最终部署的 zip 文件(在我的案例,Lambda)。
我相信构建阶段的输出是需要传递到 CloudFormation 操作中的内容。
在教程中,构建输出称为 NewSamTemplate.yaml
因此请尝试将您的 TemplatePath 更新为 MyAppBuild::NewSamTemplate.yml
您需要在buildspec.yml.
中添加aws cloudformation package命令
aws cloudformation package --debug --template-file <YourSamTemplate.yml> --s3-bucket <YourbucketName> --output-template-file <YourOutputSamTemplate.yml>
其中 YourSamTemplate.yml 是项目根目录中 samTemplate.yml 的名称。
YourOutputSamTemplate.yml 是云形成包命令完成后您要给输出文件的新名称。
然后在下一阶段,您需要将输入工件定义为 aws codebuild 阶段的输出,然后使用此输入工件来映射您的模板。
build-output::YourOutputSamTemplate.yml
就我而言,错误出在文件名中。而不是 template.yml
实际文件是 template.yaml
我正在尝试使用部署到 Lambda 的 Cloudformation SAM 堆栈设置 AWS Codepipeline,并通过管道控制台执行此操作。管道通过 Codecommit 过程中的克隆和使用 Codebuild 的构建过程,但是在使用 Cloudformation 进行部署时失败。
我收到以下错误消息:
Action execution failed
Invalid TemplatePath: MyAppBuild::samTemplate.yml
我一直在密切关注文档 (http://docs.aws.amazon.com/lambda/latest/dg/automating-deployment.html),在代码管道设置表单(模板文件)的字段 16 中,我一直在 samTemplate.yml.
我的 repo 的根目录(也是项目的根目录)中也有 samTemplate.yml。
我已将 Codebuild 输出工件名称与 Cloudformation 输入工件名称匹配,它们完全匹配。
我是不是漏掉了什么?如何让 Cloudformation 部署过程识别 sam 模板?
编辑 1 我已经改用 Codestar 而不是直接使用 CodePipeline。我的 buildspec.yml 没什么特别的,但如果有人感兴趣,它在下面。
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 文件是构建操作的根级目录,是传输到最终部署的 zip 文件(在我的案例,Lambda)。
我相信构建阶段的输出是需要传递到 CloudFormation 操作中的内容。
在教程中,构建输出称为 NewSamTemplate.yaml
因此请尝试将您的 TemplatePath 更新为 MyAppBuild::NewSamTemplate.yml
您需要在buildspec.yml.
中添加aws cloudformation package命令 aws cloudformation package --debug --template-file <YourSamTemplate.yml> --s3-bucket <YourbucketName> --output-template-file <YourOutputSamTemplate.yml>
其中 YourSamTemplate.yml 是项目根目录中 samTemplate.yml 的名称。 YourOutputSamTemplate.yml 是云形成包命令完成后您要给输出文件的新名称。
然后在下一阶段,您需要将输入工件定义为 aws codebuild 阶段的输出,然后使用此输入工件来映射您的模板。
build-output::YourOutputSamTemplate.yml
就我而言,错误出在文件名中。而不是 template.yml
实际文件是 template.yaml