在 codepipeline 上工作时出现错误 "File does not exist in artifact [SourceArtifact]"

Getting an error "File does not exist in artifact [SourceArtifact]" when working on codepipeline

我在“添加源阶段”上创建代码管道时使用 S3 作为源。

在 codepiline 的“添加部署阶段”期间,我将文件的“对象 URL”作为工件名称包括在内,但是当我尝试创建管道时失败并显示错误“文件不存在”存在于工件 [SourceArtifact] 中”,尽管该文件在 s3

中可用

CodePipeline 中的 Cloudformation 部署任务期望源工件采用 .zip 格式。对工件中文件的引用将是 zip 文件中脚本的路径。

根据 AWS 文档:

When you use Amazon Simple Storage Service (Amazon S3) as the source repository, CodePipeline requires you to zip your source files before uploading them to an S3 bucket. The zipped file is a CodePipeline artifact that can contain an AWS CloudFormation template, a template configuration file, or both.

因此,要正确引用和处理 Cloudformation 脚本,请按照以下步骤操作:

  1. 将您的 CloudFormation 脚本(即 cf.yaml)添加到 .zip 文件(即 cf.zip)
  2. 将您的 zip 文件上传到 S3
  3. 将 .zip 文件设置为源 S3 工件的路径(即 cf.zip)
  4. 在部署阶段引用源工件,但对于文件名,请引用 zip 中的文本文件(即 cf.yaml)
  5. 执行管道

Edit the artifact and upload it to an S3 Bucket