Rollback integration with aws code pipeline which is deploying a React app on S3

Viewed 788

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?

1 Answers

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.

Related