3

I have a code pipeline in AWS which performers CI/CD for my react app and deploy it into the s3 bucket.

Now I am curious how can I achieve a rollback in this flow.

my current code pipeline flow is:

git bucket(repo) - > Code build(to build the app into static hosting) - > code deploy action(with action provider s3).

In case anything goes wrong, how can I achieve a rollback into this CI/CD pipeline?

sumanth shetty
  • 1,851
  • 5
  • 24
  • 57
  • Can you clarify your setup? CodeDeploy can't deploy to S3, only to EC2/ECS and Lambda. – Marcin Oct 05 '20 at 07:41
  • My action is "deploy" which deploys on S3, not the code deploy application. – sumanth shetty Oct 05 '20 at 07:47
  • @Marcin Could you please help me with this : https://stackoverflow.com/questions/64387705/how-lambda-function-and-api-gateway-handle-disaster-recovery?noredirect=1#comment113855414_64387705 – sumanth shetty Oct 16 '20 at 11:36

1 Answers1

5

CodePipeline (CP) does not have build-in mechanism for rollbacks. Thus in your case I see three options:

  • if the target S3 bucket is versioned, you can roll back "manually" by deleting latest version of each object. This way you will effectively move back to a previous deployed version of your application.

  • You have to roll back on your bitbucket in a same way you would reverse last PR or commit. The change in bitbucket should trigger your CP to do new deployment, but of old version from the git repository.

  • The other option, could involve your CodeBuild to do a backup of your currently deployed files in the bucket while building new version of the app. This way each run of CP would also create a backup of an existing version to other bucket. Then the roll-back would be as simple as just copying files from one bucket to the other.

Marcin
  • 215,873
  • 14
  • 235
  • 294