如何向基本的S3 CodeBuild部署中添加回滚功能 [英] How to add rollback functionality to a basic S3 CodeBuild deploy

查看:111
本文介绍了如何向基本的S3 CodeBuild部署中添加回滚功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已按照此说明在aws中获得了非常基本的ci工作流程.它可以完美运行,但是我想拥有一个额外的功能,即回滚.首先,我虽然可以开箱即用"地工作,但对于我而言,如果我在CodeBuild中选择要回滚到的上一个作业并单击重试",则不会收到此错误消息:错误使用工件类型CodePipelines时,必须设置ArtifactsOverride".我还尝试通过管道历史记录"页面再次重新运行整个管道,但这只是没有任何功能的内部版本列表.

I have followed this instruction to get a very basic ci workflow in aws. It works flawless but I want to have a extra functionality, rollback. First i though it would work "out-of-the-box", but not in my case, if I select the the previous job in CodeBuild that i want to rollback to and hit "Retry" i get this error message: "Error ArtifactsOverride must be set when using artifacts type CodePipelines". I have also tried to rerun the whole pipeline again with pipeline history page, but it's just a list of builds without any functionality.

我的问题是:如何向我的工作流程添加回滚功能.它不必在同一管道中,等等.但是它不应该碰到git.

My questions is: how to add a rollback function to my workflow. It doesn't have to be in the same pipeline etc. But it should not touch git.

推荐答案

AWS CloudFormation

AWS CloudFormation now supports rolling back based in a CloudWatch alarm.

我将CloudFront发行版放在您的S3存储桶的前面,原始路径设置为该存储桶中的文件夹.每次从CodeBuild部署到S3时,都会部署到一个随机的新S3文件夹.

I'd put a CloudFront distribution in front of your S3 bucket with the origin path set to a folder within that bucket. Every time you deploy to S3 from CodeBuild you deploy to a random new S3 folder.

然后从CodeBuild步骤中将文件夹名称作为输出工件传递到JSON文件中.您可以将此工件用作通过管道中的CloudFormation操作更新的CloudFormation模板参数.

You then pass the folder name in a JSON file as an output artifact from your CodeBuild step. You can use this artifact as a parameter to a CloudFormation template updated by a CloudFormation action in your pipeline.

CloudFormation模板将更新 OriginPath字段到包含新部署的文件夹中.

The CloudFormation template would update the OriginPath field of your CloudFront distribution to the folder containing your new deployment.

如果触发警报,则CloudFormation模板将回滚并翻转回旧文件夹.

If the alarm fires then the CloudFormation template would roll back and flip back to the old folder.

此方法有几个优点:

  • 在部署过程中,客户只能看到新版本或旧版本,而在部署过程中,客户只能看到潜在的混合文件.
  • 部署逻辑更简单,因为您每次都上载一组新文件,而不是弄清楚哪些文件是新文件以及哪些文件需要删除.
  • 回滚非常简单,因为您可以回滚到仍然存在的文件,而不是重新部署旧文件.

您的管道需要同时包含CodeBuild和顺序的CloudFormation操作.

Your pipeline would need to contain both the CodeBuild and a sequential CloudFormation action.

这篇关于如何向基本的S3 CodeBuild部署中添加回滚功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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